【c# – 来自Jobject Newtonsoft的继承】教程文章相关的互联网学习教程文章

c# – Json.Net根据值选择Object【代码】

我有一个看起来像这样的Json对象:{wvw_matches: [{wvw_match_id: "1-4",red_world_id: 1011,blue_world_id: 1003,green_world_id: 1002,start_time: "2013-09-14T01:00:00Z",end_time: "2013-09-21T01:00:00Z"},{wvw_match_id: "1-2",red_world_id: 1017,blue_world_id: 1021,green_world_id: 1009,start_time: "2013-09-14T01:00:00Z",end_time: "2013-09-21T01:00:00Z"}] }它包含的数组中的对象比上面显示的示例多得多.无论如何...

c# – ObjectCreationExpressionSyntax.Type的SemanticModel.GetTypeInfo()返回null【代码】

我试图从ObjectCreationExpressionSyntax对象获取类型信息但失败了. 下面是重现问题的示例(请参阅代码中的“ti.Type为null”):using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.MSBuild;namespace RoslynExample {class Program{static void Main(string[] args){string solutionPath = @"..\..\..\RoslynExample.sln";MSBuildWor...

c# – 找一个GameObjects Vector3【代码】

最近我一直在研究保存/加载功能.我想要做的是在按下“保存”按钮后保存当前的Vector3.但是,我似乎无法弄清楚如何找到GameObjects Vector3. 互联网上有很多教程,但它们都在JS中.解决方法:gameObject的Vector3是它的transform.position.所以,如果您有参考,您可以使用:Vector3 lastPosition = gameObject.transform.position;或者,如果保存脚本在gameObject上,则可以直接引用变换:Vector3 lastPosition = transform.position;更多信...

c# – 将Object [,]转换为String [,]【代码】

我试图将对象[,]数组(例如其中的一些整数)转换为字符串[,]数组.我写了这段代码,但Visual Studio给了我一个错误说:Cannot implicitly convert String[] to String[,].我应该给Array.ConvertAll函数什么参数?非常感谢.object[,] input = GetSelectedRange();string[,] dst = Array.ConvertAll<object[,], string[,]>(input, x => x.ToString() );解决方法:如果你的项目是object [] []而不是object [,],那将会容易得多.但对于对象[,...

c# – 如何在GameObject上动态设置随机材质【代码】

我是团结的新手,我只是想知道如何设置C#的材料? 我有一个预制模型,我可以从编辑器更改纹理没问题.我想要做的是在生成预制件实例时随机设置材料. 这是我要改变的字段:我正在使用以下代码创建它们:Instantiate(eggPrefab, spawnPos, Quaternion.identity);(其中eggPrefab是一个公共变换). 我希望这是足够的信息! 谢谢.解决方法:我认为将随机材料行为与创建行为混合是过于复杂的事情.只需创建一个在Start上随机化GameObject材质的...

c# – 在DDD中如何通过DTO传递Value Objects?【代码】

在我的域中,每个域实体可能有许多值对象.我创建了价值对象来代表金钱,重量,数量,长度,数量,百分比等. 这些值对象中的每一个都包含数值和度量单位.例如. money包含货币值和货币($,euro,…),weight包含数值和重量单位(kilo,pound,…) 在用户界面中,这些也是并排显示的:字段名称,其值后跟其附带的单位,通常在属性面板中.域实体具有暴露给UI的等效DTO. 我一直在寻找将DTO中的值对象传递到UI的最佳方法. >我是否只是将特定值对象公开为...

在C#中将Soap XML解析为Object【代码】

我有以下SOAP XMLstring soap = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns='http://schemas.abudhabi.ae/sso/2010/11'>" +"<soapenv:Header/>" +"<soapenv:Body>" +"<ns:GetUserProfileResponse>" +"<!--Optional:-->" +"<ns:userid>?</ns:userid>" +"<!--Optional:-->" +"<ns:firstNameAr>?</ns:firstNameAr>" +"<!--Optional:-->" +"<ns:firstNameEn>?</ns:firstNameEn>" +"<!--O...

c# – 如何根据密钥存在的jobjects列表中获取对象列表?【代码】

这是我的代码: – List<JObject> students =[{"id":"101","name":"one","parent_id":"1"},{"id":"102","name":"two","parent_id":"2"},{"id":"103","name":"three"},{"id":"104","name":"four"}];我使用Linq尝试了以下代码,但没有工作List<JObject> newStudents = students.Where(x => x.Property("parent_id").ToString() == null).ToList();List<JObject> existedStudents = students.Where(x => x.Property("parent_id").ToStr...

c# – 如何使用x:Object和何时?【代码】

当通过标记扩展x:由docs指定的非默认构造函数的参数传递参数时,我可以看到使用具体数据类型,例如x:Int32或x:String,但是x:Object的用例是什么?更重要的是,使用它,标签之间应该放什么? &LT X:对象> ??? &LT / X:对象> 在整数或字符串的情况下,很自然地将它们视为变量赋值,然后将变量传递给构造函数.但是在Object的情况下,这样的变量通常由另一个用户定义的类构造,那么如何指定要创建的类?解决方法:从技术上讲,您可以将x:O...

c# – IL使用Reflection.Emit调用params object []参数的方法【代码】

我正在编写一个需要后续类型构建的库.库使用平台.Net core 2.0 我使用Reflection.Emit生成某些类型的问题public class GeneratedA : A, IA {public void DoInterface(string arg0, bool arg1, int arg2, object arg3, List<float> arg4, params object[] otherArgs){DoClass(arg0, arg1, arg2, arg3, arg4, otherArgs);} }对于这些类型:public interface IA {void DoInterface(string arg0, bool arg1, int arg2, object arg3, Li...

将ObjectiveC类绑定到C#问题【代码】

将ObjectiveC类绑定到C#问题 monotouch项目描述了如何绑定Objective-C类型以与MonoTouch一起使用.我们未能为AdMob库执行此操作(另请参阅monotouch-binding-for-admob blog at sabonrai dot wordpress dot com. 所以我们决定创建尽可能小的测试项目.我们用两个简单的方法编写了一个简单的objc类,一个返回一个字符串,另一个返回一个整数. 这是TstLib.h:#import <Cocoa/Cocoa.h> @interface TstCls : NSObject { } - (NSString *) Ve...

c# – System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject在序列化时忽略NonSerialized属性【代码】

如果我尝试使用System.Runtime.Serialization.Json.DataContractJsonSerializer序列化以下ClassToSerialize类的对象[DataContract,Serializable] public class ClassToSerialize {[NonSerialized] private bool _mf;public bool IsMf{ get { return _mf};set{ _mf = value;} }[DataMember]public char PrimaryExc { get; set; } }public class TestClass {ClassToSerialize obj = new ClassToSerialize{PrimaryExchange = ...

c# – 如果ObjectDataSource不是大型应用程序的答案,那是什么?

在This Question上引用Andrew Hare的答案.Object data sources are nice for smallprojects but they do not scale well asyou are embedding data-layerinformation in the UI layer of yourapplication. I would suggest that youonly use them for very smallapplications and scratch-pad testingstuff. If you make a design decisionto use them be prepared to strugglewith scaling and maintenance issues inthe future.应...

c# – ObjectSet.AddObject()与EntityCollection.Add()【代码】

假设我有两个EntitySets,“团队”和“玩家”. 我正在为系统添加新的团队,为了争论,让我说我从一个文件中添加了一千个团队(包含重复项). 该系统包含100个团队.我的目标是避免重复,而不为每个添加的团队调用SaveChanges(). 该过程是查询newteam尚不存在,然后添加新团队(如果不存在).var team = (from t in context.Teamswhere t.Name == newTeam.Nameselect t).FirstOrDefault();if (team==null) --Add New Team如果我使用context.Te...

c# – 在JSON.Net 4.0中使用JObject和JProperty【代码】

我试图以这种格式反序列化JSON:{"data": [{"installed": 1,"user_likes": 1,"user_education_history": 1,"friends_education_history": 1,"bookmarked": 1}] }到这样一个简单的字符串数组:{"installed","user_likes","user_education_history","friends_education_history","bookmarked" }使用JSON.NET 4.0 我已经使用`CustomCreationConverter’工作了public class ListConverter : CustomCreationConverter<List<string>> { p...