• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: toJObject

 // change the json string to json object
 public void toJObject(string feed, JObject JO)
 {
     JsonSerializer serializer = new JsonSerializer();
     using (JsonWriter writer = new JsonTextWriter(feed))
     {
         serializer.Serialize(writer, JO);
     }
 }
开发者ID:2Bmetro,项目名称:IVLE,代码行数:9,代码来源:LAPI.cs


示例17: WritePropertyWithNoValue

        public void WritePropertyWithNoValue()
        {
            var o = new JObject();
            o.Add(new JProperty("novalue"));

            StringAssert.Equal(@"{
  ""novalue"": null
}", o.ToString());
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:9,代码来源:JObjectTests.cs


示例18: ToJson

 public JObject ToJson(ushort index)
 {
     JObject json = new JObject();
     json["n"] = index;
     json["asset"] = AssetId.ToString();
     json["value"] = Value.ToDecimal();
     json["address"] = Wallet.ToAddress(ScriptHash);
     return json;
 }
开发者ID:butine,项目名称:research,代码行数:9,代码来源:TransactionOutput.cs


示例19: MoveTo

    public void MoveTo(int x, int y, int z)
    {
        JObject jRoot = new JObject();

        bool bRet = SavePosition(x, y, z);

        jRoot.Items.Add(KEY_RETURN, new JBoolean(bRet));
        jr.RespondJSON(jRoot);
    }
开发者ID:normanzb,项目名称:doufu-server,代码行数:9,代码来源:APIs.cs


示例20: ParallelActivityInfo

        public ParallelActivityInfo(JObject data) :base(data){
            var parallels = data["ParallelActivities"] as JArray;
            if (parallels != null) {
                foreach (var idstr in parallels) {
                    this._parallelActivities.Add(new Guid(idstr));
                }
            }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JPath类代码示例发布时间:2022-05-24
下一篇:
C# JMMServerBinary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap