當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。