private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
        {
            IDictionary<string, object> d = value as IDictionary<string, object>;
            if (d != null)
            {
                foreach (KeyValuePair<string, object> entry in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, entry.Key), entry.Value);
                }
                return;
            }

            IList l = value as IList;
            if (l != null)
            {
                if (l.Count != 0)
                {
                    for (int i = 0; i < l.Count; i++)
                    {
                        AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                    }
                }
                else
                {
                    backingStore.Add(prefix, value);
                }
                return;
            }

            // primitive
            backingStore.Add(prefix, value);
        }
Exemple #2
0
        private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
        {
            IDictionary <string, object> d = value as IDictionary <string, object>;

            if (d != null)
            {
                foreach (KeyValuePair <string, object> entry in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, entry.Key), entry.Value);
                }
                return;
            }

            IList l = value as IList;

            if (l != null)
            {
                if (l.Count != 0)
                {
                    for (int i = 0; i < l.Count; i++)
                    {
                        AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                    }
                }
                else
                {
                    backingStore.Add(prefix, value);
                }
                return;
            }

            // primitive
            backingStore.Add(prefix, value);
        }
Exemple #3
0
        private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                backingStore.Add(prefix, value);
            }

            var d = value as IDictionary <string, object>;

            if (d != null)
            {
                foreach (var entry in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, entry.Key), entry.Value);
                }
                return;
            }

            var l = value as IList;

            if (l != null)
            {
                for (int i = 0; i < l.Count; i++)
                {
                    AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                }
                return;
            }

            // primitive
            //backingStore.Add(prefix, value);
        }
Exemple #4
0
        private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
        {
            IDictionary <string, object> dictionary = value as IDictionary <string, object>;

            if (dictionary != null)
            {
                foreach (KeyValuePair <string, object> pair in dictionary)
                {
                    string newPrefix = MakePropertyKey(prefix, pair.Key);
                    AddToBackingStore(backingStore, newPrefix, pair.Value);
                }
            }
            else
            {
                IList list = value as IList;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        AddToBackingStore(backingStore, MakeArrayKey(prefix, i), list[i]);
                    }
                }
                else
                {
                    backingStore.Add(prefix, value);
                }
            }
        }
Exemple #5
0
        static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object?value)
        {
            if (value is IDictionary <string, object> d)
            {
                foreach (KeyValuePair <string, object> entry in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, entry.Key), entry.Value);
                }

                return;
            }

            if (value is IList l)
            {
                for (int i = 0; i < l.Count; i++)
                {
                    AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                }

                return;
            }

            // primitive

            backingStore.Add(prefix, value);
        }
    private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
    {
        IDictionary <string, object> strs = value as IDictionary <string, object>;

        if (strs != null)
        {
            foreach (KeyValuePair <string, object> keyValuePair in strs)
            {
                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
            }

            return;
        }

        IList lists = value as IList;

        if (lists == null)
        {
            backingStore.Add(prefix, value);
            return;
        }

        for (int i = 0; i < lists.Count; i++)
        {
            CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
        }
    }
Exemple #7
0
        private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
        {
            switch (value)
            {
            case IDictionary <string, object> d:
            {
                foreach (var entry in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, entry.Key), entry.Value);
                }
                return;
            }

            case IList l:
            {
                for (var i = 0; i < l.Count; i++)
                {
                    AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                }
                return;
            }

            default:
                backingStore.Add(prefix, value);
                break;
            }
        }
 private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
 {
     IDictionary<string, object> dictionary = value as IDictionary<string, object>;
     if (dictionary != null)
     {
         foreach (KeyValuePair<string, object> pair in dictionary)
         {
             string newPrefix = MakePropertyKey(prefix, pair.Key);
             AddToBackingStore(backingStore, newPrefix, pair.Value);
         }
     }
     else
     {
         IList list = value as IList;
         if (list != null)
         {
             for (int i = 0; i < list.Count; i++)
             {
                 AddToBackingStore(backingStore, MakeArrayKey(prefix, i), list[i]);
             }
         }
         else
         {
             backingStore.Add(prefix, value);
         }
     }
 }
Exemple #9
0
        private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, JToken value)
        {
            if (value.Type == JTokenType.Null)
            {
                return;
            }
            var d = value as JObject;

            if (d != null)
            {
                foreach (var v in d)
                {
                    AddToBackingStore(backingStore, MakePropertyKey(prefix, v.Key), v.Value);
                }
                return;
            }
            var l = value as JArray;

            if (l != null)
            {
                if (l.Count == 0)
                {
                    //解决空数组被解析成null的问题
                    backingStore.Add(prefix, new object[0]);
                }
                else
                {
                    for (var i = 0; i < l.Count; i++)
                    {
                        AddToBackingStore(backingStore, MakeArrayKey(prefix, i), l[i]);
                    }

                    /*var i = 0;
                     * foreach (var v in l)
                     * {
                     *  AddToBackingStore(backingStore, MakeArrayKey(prefix, i), v);
                     *  i++;
                     * }*/
                }
                return;
            }
            backingStore.Add(prefix, value.ToString());
        }