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


C# JObject.GetEnumerator方法代码示例

本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.GetEnumerator方法的具体用法?C# JObject.GetEnumerator怎么用?C# JObject.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newtonsoft.Json.Linq.JObject的用法示例。


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

示例1: VisitObject

        JToken VisitObject(JObject jObject)
        {
            var e = jObject.GetEnumerator();
            bool addComma = false;

            sb.Append("{");

            while (e.MoveNext())
            {
                var kv = e.Current;

                if (addComma)
                    sb.Append(", ");
                else
                    addComma = true;

                sb.Append(kv.Key);
                sb.Append(": ");
                Visit(kv.Value);
            }

            sb.Append("}");

            return jObject;
        }
开发者ID:jlyonsmith,项目名称:Tson,代码行数:25,代码来源:TsonJTokenVisitor.cs

示例2: ApplyConfig

 public void ApplyConfig(JObject values)
 {
     IEnumerator<KeyValuePair<string, JToken>> it = values.GetEnumerator();
     while (it.MoveNext())
     {
         switch (it.Current.Key)
         {
             case "prefix": Prefix = it.Current.Value.ToString(); break;
             case "name": Name = it.Current.Value.ToString(); break;
             case "title": Title = it.Current.Value.ToString(); break;
             case "pagebreak": Pagebreak = (bool)it.Current.Value; break;
             case "notitle": Notitle = (bool)it.Current.Value; break;
             case "noheader": Noheader = (bool)it.Current.Value; break;
             case "wiki": Wiki = it.Current.Value.ToString(); break;
             case "entrypicture": EntryPicture = (bool)it.Current.Value; break;
         }
     }
 }
开发者ID:EusthEnoptEron,项目名称:BakaPrince,代码行数:18,代码来源:Page.cs

示例3: AssertJsonAreEqual

 private static void AssertJsonAreEqual(JObject expectedJson, JObject actualJson, string path)
 {
     Assert.AreEqual(expectedJson.Count, actualJson.Count, "Count of json object at " + path);
     for (var expectedElementsEnumerator = expectedJson.GetEnumerator(); expectedElementsEnumerator.MoveNext(); )
     {
         JToken actualElement = null;
         Assert.IsTrue(actualJson.TryGetValue(expectedElementsEnumerator.Current.Key, out actualElement), "Couldn't find " + path + "[" + expectedElementsEnumerator.Current.Key + "]");
         AssertJsonAreEqual(expectedElementsEnumerator.Current.Value, actualElement, path + "[" + expectedElementsEnumerator.Current.Key + "]");
     }
 }
开发者ID:yaozd,项目名称:JSON-RPC.NET,代码行数:10,代码来源:Test.cs

示例4: PutFolderData

        private void PutFolderData(String folder, JObject data)
        {
            IEnumerator<KeyValuePair<String, JToken>> enumer = data.GetEnumerator();

            foreach (String fileName in Directory.GetFiles(folder, "*.js"))
            {
                File.Delete(fileName);
            }

            while (enumer.MoveNext())
            {
                String fileName = enumer.Current.Key + ".js";
                String content = enumer.Current.Value.Value<String>();

                StreamWriter sw = new StreamWriter(System.IO.Path.Combine(folder, fileName), false, Encoding.UTF8);
                sw.Write(content);
                sw.Close();
            }
        }
开发者ID:Zinal001,项目名称:Screeps-Script-Importer-Exporter,代码行数:19,代码来源:API.cs

示例5: buildElements

 protected List<TJSONPair> buildElements(JObject o)
 {
     try {
         String pname;
         List<TJSONPair> res = new List<TJSONPair>();
         IEnumerator<KeyValuePair<String,JToken>> keys = o.GetEnumerator();
         while (keys.MoveNext())
         {
             pname = keys.Current.Key;
             JToken jtk = keys.Current.Value;
             JTokenType jttype = keys.Current.Value.Type;
             switch (jttype) {
                 case JTokenType.Null: {
                     res.Add(new TJSONPair(pname, new TJSONNull()));
                     break;
                 }
                 case JTokenType.String:
                 {
                     res.Add(new TJSONPair(pname, new TJSONString(jtk.Value<string>())));
                     break;
                 }
                 case JTokenType.Float:
                 {
                     res.Add(new TJSONPair(pname, new TJSONNumber(jtk.Value<float>())));
                     break;
                 }
                 case JTokenType.Integer:
                 {
                     res.Add(new TJSONPair(pname, new TJSONNumber(jtk.Value<Int32>())));
                     break;
                 }
                 case JTokenType.Array:
                 {
                     res.Add(new TJSONPair(pname, new TJSONArray(jtk.Value<JArray>())));
                     break;
                 }
                 case JTokenType.Object:
                 {
                     res.Add(new TJSONPair(pname, new TJSONObject(jtk.Value<JObject>())));
                     break;
                 }
                 case JTokenType.Boolean:
                 {
                     if (jtk.Value<bool>())
                         res.Add(new TJSONPair(pname, new TJSONTrue()));
                     else
                         res.Add(new TJSONPair(pname, new TJSONFalse()));
                     break;
                 }
             }
         }
         return res;
     } catch (Exception) {
         return null;
     }
 }
开发者ID:pnwdelphi,项目名称:December2012,代码行数:56,代码来源:TJSONObject.cs


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