当前位置: 首页>>代码示例>>C#>>正文


C# JObject类代码示例

本文整理汇总了C#中JObject的典型用法代码示例。如果您正苦于以下问题:C# JObject类的具体用法?C# JObject怎么用?C# JObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JObject类属于命名空间,在下文中一共展示了JObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CSharpTest

 public static JObject CSharpTest(RPCRequestInfo c, JObject p)
 {
     Thread.Sleep ((int)p ["ms"].AsNumber (0.0));
     return new JObject {
         { "hello", "world" }
     };
 }
开发者ID:dnorman,项目名称:scamp,代码行数:7,代码来源:TestService.cs

示例2: LoadFromJson

    public void LoadFromJson(JObject source)
    {
        // This is where the automatic deserialization takes place. We just tell the Jobject that we want an object of the type RelfectionData and it will handle the rest
        var reflectionDataObject = source.Deserialize<ReflectionData>();

        // This is just a simple method a created to read the data from reflectionDataObject back into this object
        reflectionDataObject.ToMonoBehavior(this);
    }
开发者ID:bonahona,项目名称:BonaJson,代码行数:8,代码来源:ReflectionExample.cs

示例3: TransactionInfo

        public TransactionInfo(JObject data) : base(data)
        {

            this.From = new Guid(data["From"].ToString());
            this.To = new Guid(data["To"].ToString());
            this.ConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["ConstraintKind"].ToString());
            if (this.ConstraintKind != ConstraintKinds.None) this.Constraint = data["Constraint"].ToString();

        }
开发者ID:yanyitec,项目名称:Yanyitec,代码行数:9,代码来源:TransactionInfo.cs

示例4: Example

        public void Example()
        {
            #region Usage
            JObject o = new JObject
            {
                { "Cpu", "Intel" },
                { "Memory", 32 },
                {
                    "Drives", new JArray
                    {
                        "DVD",
                        "SSD"
                    }
                }
            };

            Console.WriteLine(o.ToString());
            // {
            //   "Cpu": "Intel",
            //   "Memory": 32,
            //   "Drives": [
            //     "DVD",
            //     "SSD"
            //   ]
            // }
            #endregion
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:27,代码来源:CreateJsonCollectionInitializer.cs

示例5: RPCException

 public RPCException(string code, string msg, RPCException orig, JObject data = null)
 {
     ErrorCode = code;
     ErrorMessage = msg + ": " + orig.ErrorMessage;
     ErrorData = data ?? new JObject ();
     ErrorData ["orig"] = orig.AsHeader ();
 }
开发者ID:dnorman,项目名称:scamp,代码行数:7,代码来源:RPCException.cs

示例6: Download

        public Download(Uri uri, string key, CookieContainer cc, JObject song)
        {
            m_uri = uri;
            m_key = key;
            m_cc = cc;
            m_song = song;

            song["Status"] = "Opening file";
            string filename = (string)song["ArtistName"] + " - " + (string)song["Name"] + ".mp3";
            m_logger = new Logger(this.GetType().ToString() + " " + filename);
            string dst = "";
            string path = "";
            if (Main.PATH.Length != 0)
                path = Main.PATH + Path.DirectorySeparatorChar;
            dst = path + filename;
            try
            {
                m_path = dst;
                m_fs = new FileStream(dst, FileMode.Create);
            }
            catch (Exception ex)
            {
                char[] invalf = Path.GetInvalidFileNameChars();
                foreach (char c in invalf)
                    filename = filename.Replace(c, '_');
                dst = path + filename;
                try
                {
                    m_path = dst;
                    m_fs = new FileStream(dst, FileMode.Create);
                }
                catch (Exception exc)
                {
                    for (int i = 0; i < dst.Length; i++)
                    {
                        if (!Char.IsLetterOrDigit(dst[i]))
                            filename = filename.Replace(dst[i], '_');
                        dst = path + filename;
                    }
                    try
                    {
                        m_path = dst;
                        m_fs = new FileStream(dst, FileMode.Create);
                    }
                    catch (Exception exc2)
                    {
                        throw new Exception("Could not save the file buddy. (" + exc2.Message + ")");
                    }
                }
            }

            m_logger.Info("Starting download");
            song["Status"] = "Starting download";
            Segment s = new Segment(uri, cc, key, 0, SEGMENT_SIZE-1, m_path);
            m_segments.Add(s);
            s.Progress += new EventHandler(s_Progress);
            s.HeadersReceived += new Segment.HeadersReceivedHandler(s_HeadersReceived);
            s.Start();
            m_start = DateTime.Now;
        }
开发者ID:engina,项目名称:SharkIT,代码行数:60,代码来源:Download.cs

示例7: ToJson

 public JObject ToJson()
 {
     JObject json = new JObject();
     json["stack"] = StackScript.ToHexString();
     json["redeem"] = RedeemScript.ToHexString();
     return json;
 }
开发者ID:butine,项目名称:research,代码行数:7,代码来源:Script.cs

示例8: ProccessDefination

 public ProccessDefination(JObject data) : base(data)
 {
     this.StartAlias = data["StartAlias"].ToString();
     this.FinishAlias = data["FinishAlias"].ToString();
     var rtIdData = data["RuntimeId"];
     if (rtIdData != null) this.RuntimeId = new Guid(rtIdData.ToString());
 }
开发者ID:yanyitec,项目名称:Yanyitec,代码行数:7,代码来源:ProccessDefination.cs

示例9: CreateResponse

 private static JObject CreateResponse(JObject id)
 {
     JObject response = new JObject();
     response["jsonrpc"] = "2.0";
     response["id"] = id;
     return response;
 }
开发者ID:qlw,项目名称:AntShares,代码行数:7,代码来源:RpcServer.cs

示例10: Example

        public void Example()
        {
            #region Usage
            JObject o = new JObject
            {
                { "name1", "value1" },
                { "name2", "value2" }
            };

            JsonWriter writer = o.CreateWriter();
            writer.WritePropertyName("name3");
            writer.WriteStartArray();
            writer.WriteValue(1);
            writer.WriteValue(2);
            writer.WriteEndArray();

            Console.WriteLine(o.ToString());
            // {
            //   "name1": "value1",
            //   "name2": "value2",
            //   "name3": [
            //     1,
            //     2
            //   ]
            // }
            #endregion
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:27,代码来源:CreateWriter.cs

示例11: Example

        public void Example()
        {
            #region Usage
            JValue s1 = new JValue("A string");
            JValue s2 = new JValue("A string");
            JValue s3 = new JValue("A STRING");

            Console.WriteLine(JToken.DeepEquals(s1, s2));
            // true

            Console.WriteLine(JToken.DeepEquals(s2, s3));
            // false

            JObject o1 = new JObject
            {
                { "Integer", 12345 },
                { "String", "A string" },
                { "Items", new JArray(1, 2) }
            };

            JObject o2 = new JObject
            {
                { "Integer", 12345 },
                { "String", "A string" },
                { "Items", new JArray(1, 2) }
            };

            Console.WriteLine(JToken.DeepEquals(o1, o2));
            // true

            Console.WriteLine(JToken.DeepEquals(s1, o1["String"]));
            // true
            #endregion
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:34,代码来源:DeepEquals.cs

示例12: GetTypeFromJObject

		private IElasticCoreType GetTypeFromJObject(JObject po, JsonSerializer serializer)
		{
			JToken typeToken;
			serializer.TypeNameHandling = TypeNameHandling.None;
			if (po.TryGetValue("type", out typeToken))
			{
				var type = typeToken.Value<string>().ToLowerInvariant();
				switch (type)
				{
					case "string":
						return serializer.Deserialize(po.CreateReader(), typeof(StringMapping)) as StringMapping;
					case "float":
					case "double":
					case "byte":
					case "short":
					case "integer":
					case "long":
						return serializer.Deserialize(po.CreateReader(), typeof(NumberMapping)) as NumberMapping;
					case "date":
						return serializer.Deserialize(po.CreateReader(), typeof(DateMapping)) as DateMapping;
					case "boolean":
						return serializer.Deserialize(po.CreateReader(), typeof(BooleanMapping)) as BooleanMapping;
					case "binary":
						return serializer.Deserialize(po.CreateReader(), typeof(BinaryMapping)) as BinaryMapping;
				}
			}
			return null;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:28,代码来源:ElasticCoreTypeConverter.cs

示例13: ToJson

 public JObject ToJson()
 {
     JObject json = new JObject();
     json["usage"] = Usage;
     json["data"] = Data.ToHexString();
     return json;
 }
开发者ID:butine,项目名称:research,代码行数:7,代码来源:TransactionAttribute.cs

示例14: FromJson

        public static ProcessDefination FromJson(JObject data) {
            var entity = new ProcessDefination();
            entity.Id = new Guid(data["Id"].ToString());
            entity.ActivityDefinationId = new Guid(data["ActivityDefinationId"].ToString());
            entity.ActivityId = new Guid(data["ActivityId"].ToString());
            entity.Description = data["Description"].ToString();
            var arr = data["ActivedActivityIds"] as JArray;
            if (arr != null) {
                entity.ActivedActivityIds = new List<Guid>();
                foreach (JToken item in arr) {
                    entity.ActivedActivityIds.Add(new Guid(item.ToString()));
                }
            }
            var extra = data["Extra"] as JObject;
            if (extra != null)
            {
                entity.Extras = new Dictionary<string, string>();
                foreach (var pair in extra)
                {
                    entity.Extras.Add(pair.Key, pair.Value.ToString());
                }
            }

            return entity;
        }
开发者ID:yanyitec,项目名称:Yanyitec,代码行数:25,代码来源:ProcessDefination.cs

示例15: TransactionDefination

        public TransactionDefination(JObject data) : base(data)
        {
            this.FromAlias = data["FromAlias"].ToString();
            this.ToAlias = data["ToAlias"].ToString();
            this.ConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["ConstraintKind"].ToString());
            if (this.ConstraintKind != ConstraintKinds.None) this.Constraint = data["Constraint"]?.ToString();

        }
开发者ID:yanyitec,项目名称:Yanyitec,代码行数:8,代码来源:TransactionDefination.cs


注:本文中的JObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。