Пример #1
0
        private void AddParent(JContainer container)
        {
            if (_parent == null)
            {
                _token = container;
            }
            else
            {
                _parent.Add(container);
            }

            _parent = container;
        }
Пример #2
0
        private static JProperty ReadProperty([Nullable(1)] JsonReader r, JsonLoadSettings settings, IJsonLineInfo lineInfo, [Nullable(1)] JContainer parent)
        {
            DuplicatePropertyNameHandling duplicatePropertyNameHandling = (settings != null) ? settings.DuplicatePropertyNameHandling : DuplicatePropertyNameHandling.Replace;
            JObject   jobject   = (JObject)parent;
            string    text      = r.Value.ToString();
            JProperty jproperty = jobject.Property(text, StringComparison.Ordinal);

            if (jproperty != null)
            {
                if (duplicatePropertyNameHandling == DuplicatePropertyNameHandling.Ignore)
                {
                    return(null);
                }
                if (duplicatePropertyNameHandling == DuplicatePropertyNameHandling.Error)
                {
                    throw JsonReaderException.Create(r, "Property with the name '{0}' already exists in the current JSON object.".FormatWith(CultureInfo.InvariantCulture, text));
                }
            }
            JProperty jproperty2 = new JProperty(text);

            jproperty2.SetLineInfo(lineInfo, settings);
            if (jproperty == null)
            {
                parent.Add(jproperty2);
            }
            else
            {
                jproperty.Replace(jproperty2);
            }
            return(jproperty2);
        }
Пример #3
0
        /// <summary>
        /// <para>Merge the right token into the left</para>
        /// </summary>
        /// <param name="left">Token to be merged into</param>
        /// <param name="right">Token to merge, overwriting the left</param>
        /// <param name="options">Options for merge</param>
        public static void MergeInto(
            this JContainer left, JToken right, MergeOptions options)
        {
            foreach (var rightChild in right.Children <JProperty>())
            {
                var rightChildProperty = rightChild;
                var leftPropertyValue  = left.SelectToken(rightChildProperty.Name);

                // add on demand only. This will keep low memory usage.
                if (leftPropertyValue == null && options.ADD_NONE_EXISTING)
                {
                    // no matching property, just add
                    left.Add(rightChild);
                }
                else
                {
                    if (leftPropertyValue == null && !options.ADD_NONE_EXISTING)
                    {
                        // becoz we don't want to add so continue checking for next property.
                        continue;
                    }
                    var leftProperty = (JProperty)leftPropertyValue.Parent;
                    var leftArray    = leftPropertyValue as JArray;
                    var rightArray   = rightChildProperty.Value as JArray;
                    if (leftArray != null && rightArray != null)
                    {
                        switch (options.ArrayHandling)
                        {
                        case MergeOptionArrayHandling.Concat:
                            foreach (var rightValue in rightArray)
                            {
                                leftArray.Add(rightValue);
                            }
                            break;

                        case MergeOptionArrayHandling.Overwrite:

                            leftProperty.Value = rightChildProperty.Value;
                            break;
                        }
                    }
                    else
                    {
                        var leftObject = leftPropertyValue as JObject;
                        //only set property if it not null
                        if (leftObject == null && !string.IsNullOrEmpty(rightChildProperty.Value.ToString()))
                        {
                            // replace value
                            leftProperty.Value = rightChildProperty.Value;
                        }

                        else
                        {
                            // recurse object
                            MergeInto(leftObject, rightChildProperty.Value, options);
                        }
                    }
                }
            }
        }
Пример #4
0
        internal void AddValue(JValue value, JsonToken token)
        {
            if (_parent != null)
            {
                _parent.Add(value);
                _current = _parent.Last;

                if (_parent.Type == JTokenType.Property)
                {
                    _parent = _parent.Parent;
                }
            }
            else
            {
                _value   = value ?? JValue.CreateNull();
                _current = _value;
            }
        }
 static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Newtonsoft.Json.Linq.JContainer obj = (Newtonsoft.Json.Linq.JContainer)ToLua.CheckObject <Newtonsoft.Json.Linq.JContainer>(L, 1);
         object arg0 = ToLua.ToVarObject(L, 2);
         obj.Add(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #6
0
        internal void AddValue(JValue value, JsonToken token)
        {
            if (_parent != null)
            {
                _parent.Add(value);

                if (_parent.Type == JTokenType.Property)
                {
                    _parent = _parent.Parent;
                }
            }
            else
            {
                _value = value ?? new JValue((object)null);
            }
        }
Пример #7
0
        internal static void MergeEnumerableContent(JContainer target, IEnumerable content, JsonMergeSettings settings)
        {
            switch (settings.MergeArrayHandling)
            {
            case MergeArrayHandling.Concat:
                foreach (JToken item in content)
                {
                    target.Add(item);
                }
                break;

            case MergeArrayHandling.Union:
#if !NET20
                HashSet <JToken> items = new HashSet <JToken>(target, EqualityComparer);

                foreach (JToken item in content)
                {
                    if (items.Add(item))
                    {
                        target.Add(item);
                    }
                }
#else
                IDictionary <JToken, bool> items = new Dictionary <JToken, bool>(EqualityComparer);
                foreach (JToken t in target)
                {
                    items[t] = true;
                }

                foreach (JToken item in content)
                {
                    if (!items.ContainsKey(item))
                    {
                        items[item] = true;
                        target.Add(item);
                    }
                }
#endif
                break;

            case MergeArrayHandling.Replace:
                target.ClearItems();
                foreach (JToken item in content)
                {
                    target.Add(item);
                }
                break;

            case MergeArrayHandling.Merge:
                int i = 0;
                foreach (object targetItem in content)
                {
                    if (i < target.Count)
                    {
                        JToken sourceItem = target[i];

                        JContainer existingContainer = sourceItem as JContainer;
                        if (existingContainer != null)
                        {
                            existingContainer.Merge(targetItem, settings);
                        }
                        else
                        {
                            if (targetItem != null)
                            {
                                JToken contentValue = CreateFromContent(targetItem);
                                if (contentValue.Type != JTokenType.Null)
                                {
                                    target[i] = contentValue;
                                }
                            }
                        }
                    }
                    else
                    {
                        target.Add(targetItem);
                    }

                    i++;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(settings), "Unexpected merge array handling when merging JSON.");
            }
        }
Пример #8
0
        internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings)
        {
            JProperty property1;
            JValue    value2;
            JProperty property;

            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo lineInfo = r as IJsonLineInfo;
            JContainer    parent   = this;

Label_0014:
            property1 = parent as JProperty;
            if (property1 == null)
            {
            }
            if (null.Value != null)
            {
                if (parent == this)
                {
                    return;
                }
                parent = parent.Parent;
            }
            switch (r.TokenType)
            {
            case JsonToken.None:
                goto Label_0247;

            case JsonToken.StartObject:
            {
                JObject content = new JObject();
                content.SetLineInfo(lineInfo, settings);
                parent.Add(content);
                parent = content;
                goto Label_0247;
            }

            case JsonToken.StartArray:
            {
                JArray content = new JArray();
                content.SetLineInfo(lineInfo, settings);
                parent.Add(content);
                parent = content;
                goto Label_0247;
            }

            case JsonToken.StartConstructor:
            {
                JConstructor content = new JConstructor(r.Value.ToString());
                content.SetLineInfo(lineInfo, settings);
                parent.Add(content);
                parent = content;
                goto Label_0247;
            }

            case JsonToken.PropertyName:
            {
                string name = r.Value.ToString();
                property = new JProperty(name);
                property.SetLineInfo(lineInfo, settings);
                JProperty property2 = ((JObject)parent).Property(name);
                if (property2 != null)
                {
                    property2.Replace(property);
                    break;
                }
                parent.Add(property);
                break;
            }

            case JsonToken.Comment:
                if ((settings != null) && (settings.CommentHandling == CommentHandling.Load))
                {
                    value2 = JValue.CreateComment(r.Value.ToString());
                    value2.SetLineInfo(lineInfo, settings);
                    parent.Add(value2);
                }
                goto Label_0247;

            case JsonToken.Integer:
            case JsonToken.Float:
            case JsonToken.String:
            case JsonToken.Boolean:
            case JsonToken.Date:
            case JsonToken.Bytes:
                value2 = new JValue(r.Value);
                value2.SetLineInfo(lineInfo, settings);
                parent.Add(value2);
                goto Label_0247;

            case JsonToken.Null:
                value2 = JValue.CreateNull();
                value2.SetLineInfo(lineInfo, settings);
                parent.Add(value2);
                goto Label_0247;

            case JsonToken.Undefined:
                value2 = JValue.CreateUndefined();
                value2.SetLineInfo(lineInfo, settings);
                parent.Add(value2);
                goto Label_0247;

            case JsonToken.EndObject:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_0247;
                }
                return;

            case JsonToken.EndArray:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_0247;
                }
                return;

            case JsonToken.EndConstructor:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_0247;
                }
                return;

            default:
                throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
            }
            parent = property;
Label_0247:
            if (r.Read())
            {
                goto Label_0014;
            }
        }
Пример #9
0
        // Token: 0x06001269 RID: 4713 RVA: 0x000648AC File Offset: 0x00062AAC
        internal void ReadContentFrom(JsonReader r, [Nullable(2)] JsonLoadSettings settings)
        {
            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo lineInfo   = r as IJsonLineInfo;
            JContainer    jcontainer = this;

            for (;;)
            {
                JProperty jproperty = jcontainer as JProperty;
                if (jproperty != null && jproperty.Value != null)
                {
                    if (jcontainer == this)
                    {
                        break;
                    }
                    jcontainer = jcontainer.Parent;
                }
                switch (r.TokenType)
                {
                case JsonToken.None:
                    goto IL_218;

                case JsonToken.StartObject:
                {
                    JObject jobject = new JObject();
                    jobject.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jobject);
                    jcontainer = jobject;
                    goto IL_218;
                }

                case JsonToken.StartArray:
                {
                    JArray jarray = new JArray();
                    jarray.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jarray);
                    jcontainer = jarray;
                    goto IL_218;
                }

                case JsonToken.StartConstructor:
                {
                    JConstructor jconstructor = new JConstructor(r.Value.ToString());
                    jconstructor.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jconstructor);
                    jcontainer = jconstructor;
                    goto IL_218;
                }

                case JsonToken.PropertyName:
                {
                    JProperty jproperty2 = JContainer.ReadProperty(r, settings, lineInfo, jcontainer);
                    if (jproperty2 != null)
                    {
                        jcontainer = jproperty2;
                        goto IL_218;
                    }
                    r.Skip();
                    goto IL_218;
                }

                case JsonToken.Comment:
                    if (settings != null && settings.CommentHandling == CommentHandling.Load)
                    {
                        JValue jvalue = JValue.CreateComment(r.Value.ToString());
                        jvalue.SetLineInfo(lineInfo, settings);
                        jcontainer.Add(jvalue);
                        goto IL_218;
                    }
                    goto IL_218;

                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.String:
                case JsonToken.Boolean:
                case JsonToken.Date:
                case JsonToken.Bytes:
                {
                    JValue jvalue = new JValue(r.Value);
                    jvalue.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jvalue);
                    goto IL_218;
                }

                case JsonToken.Null:
                {
                    JValue jvalue = JValue.CreateNull();
                    jvalue.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jvalue);
                    goto IL_218;
                }

                case JsonToken.Undefined:
                {
                    JValue jvalue = JValue.CreateUndefined();
                    jvalue.SetLineInfo(lineInfo, settings);
                    jcontainer.Add(jvalue);
                    goto IL_218;
                }

                case JsonToken.EndObject:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto IL_218;

                case JsonToken.EndArray:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto IL_218;

                case JsonToken.EndConstructor:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto IL_218;
                }
                goto Block_4;
IL_218:
                if (!r.Read())
                {
                    return;
                }
            }
            return;

Block_4:
            throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
        }
Пример #10
0
        // Token: 0x06001298 RID: 4760 RVA: 0x00064E40 File Offset: 0x00063040
        internal static void MergeEnumerableContent(JContainer target, IEnumerable content, [Nullable(2)] JsonMergeSettings settings)
        {
            switch ((settings != null) ? settings.MergeArrayHandling : MergeArrayHandling.Concat)
            {
            case MergeArrayHandling.Concat:
                using (IEnumerator enumerator = content.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object obj      = enumerator.Current;
                        JToken content2 = (JToken)obj;
                        target.Add(content2);
                    }
                    return;
                }
                break;

            case MergeArrayHandling.Union:
                break;

            case MergeArrayHandling.Replace:
                goto IL_CB;

            case MergeArrayHandling.Merge:
                goto IL_11A;

            default:
                goto IL_1CC;
            }
            HashSet <JToken> hashSet = new HashSet <JToken>(target, JToken.EqualityComparer);

            using (IEnumerator enumerator = content.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    object obj2   = enumerator.Current;
                    JToken jtoken = (JToken)obj2;
                    if (hashSet.Add(jtoken))
                    {
                        target.Add(jtoken);
                    }
                }
                return;
            }
IL_CB:
            if (target == content)
            {
                return;
            }
            target.ClearItems();
            using (IEnumerator enumerator = content.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    object obj3     = enumerator.Current;
                    JToken content3 = (JToken)obj3;
                    target.Add(content3);
                }
                return;
            }
IL_11A:
            int num = 0;

            using (IEnumerator enumerator = content.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    object obj4 = enumerator.Current;
                    if (num < target.Count)
                    {
                        JContainer jcontainer = target[num] as JContainer;
                        if (jcontainer != null)
                        {
                            jcontainer.Merge(obj4, settings);
                        }
                        else if (obj4 != null)
                        {
                            JToken jtoken2 = JContainer.CreateFromContent(obj4);
                            if (jtoken2.Type != JTokenType.Null)
                            {
                                target[num] = jtoken2;
                            }
                        }
                    }
                    else
                    {
                        target.Add(obj4);
                    }
                    num++;
                }
                return;
            }
IL_1CC:
            throw new ArgumentOutOfRangeException("settings", "Unexpected merge array handling when merging JSON.");
        }
Пример #11
0
        internal static void MergeEnumerableContent(
            JContainer target,
            IEnumerable content,
            JsonMergeSettings settings)
        {
            switch (settings.MergeArrayHandling)
            {
            case MergeArrayHandling.Concat:
                IEnumerator enumerator1 = content.GetEnumerator();
                try
                {
                    while (enumerator1.MoveNext())
                    {
                        JToken current = (JToken)enumerator1.Current;
                        target.Add((object)current);
                    }
                    break;
                }
                finally
                {
                    if (enumerator1 is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }

            case MergeArrayHandling.Union:
                HashSet <JToken> jtokenSet   = new HashSet <JToken>((IEnumerable <JToken>)target, (IEqualityComparer <JToken>)JToken.EqualityComparer);
                IEnumerator      enumerator2 = content.GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        JToken current = (JToken)enumerator2.Current;
                        if (jtokenSet.Add(current))
                        {
                            target.Add((object)current);
                        }
                    }
                    break;
                }
                finally
                {
                    if (enumerator2 is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }

            case MergeArrayHandling.Replace:
                target.ClearItems();
                IEnumerator enumerator3 = content.GetEnumerator();
                try
                {
                    while (enumerator3.MoveNext())
                    {
                        JToken current = (JToken)enumerator3.Current;
                        target.Add((object)current);
                    }
                    break;
                }
                finally
                {
                    if (enumerator3 is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }

            case MergeArrayHandling.Merge:
                int         num         = 0;
                IEnumerator enumerator4 = content.GetEnumerator();
                try
                {
                    while (enumerator4.MoveNext())
                    {
                        object current = enumerator4.Current;
                        if (num < target.Count)
                        {
                            if (target[(object)num] is JContainer jcontainer)
                            {
                                jcontainer.Merge(current, settings);
                            }
                            else if (current != null)
                            {
                                JToken fromContent = JContainer.CreateFromContent(current);
                                if (fromContent.Type != JTokenType.Null)
                                {
                                    target[(object)num] = fromContent;
                                }
                            }
                        }
                        else
                        {
                            target.Add(current);
                        }
                        ++num;
                    }
                    break;
                }
                finally
                {
                    if (enumerator4 is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }

            default:
                throw new ArgumentOutOfRangeException(nameof(settings), "Unexpected merge array handling when merging JSON.");
            }
        }
Пример #12
0
        private async Task ReadContentFromAsync(JsonReader reader, JsonLoadSettings settings, CancellationToken cancellationToken = default)
        {
            IJsonLineInfo lineInfo = reader as IJsonLineInfo;

            JContainer parent = this;

            do
            {
                if (parent is JProperty p && p.Value != null)
                {
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                }

                switch (reader.TokenType)
                {
                case JsonToken.None:
                    // new reader. move to actual content
                    break;

                case JsonToken.StartArray:
                    JArray a = new JArray();
                    a.SetLineInfo(lineInfo, settings);
                    parent.Add(a);
                    parent = a;
                    break;

                case JsonToken.EndArray:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartObject:
                    JObject o = new JObject();
                    o.SetLineInfo(lineInfo, settings);
                    parent.Add(o);
                    parent = o;
                    break;

                case JsonToken.EndObject:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartConstructor:
                    JConstructor constructor = new JConstructor(reader.Value.ToString());
                    constructor.SetLineInfo(lineInfo, settings);
                    parent.Add(constructor);
                    parent = constructor;
                    break;

                case JsonToken.EndConstructor:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.String:
                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.Date:
                case JsonToken.Boolean:
                case JsonToken.Bytes:
                    JValue v = new JValue(reader.Value);
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.Comment:
                    if (settings != null && settings.CommentHandling == CommentHandling.Load)
                    {
                        v = JValue.CreateComment(reader.Value.ToString());
                        v.SetLineInfo(lineInfo, settings);
                        parent.Add(v);
                    }
                    break;

                case JsonToken.Null:
                    v = JValue.CreateNull();
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.Undefined:
                    v = JValue.CreateUndefined();
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.PropertyName:
                    JProperty property = ReadProperty(reader, settings, lineInfo, parent);
                    if (property != null)
                    {
                        parent = property;
                    }
                    else
                    {
                        await reader.SkipAsync();
                    }
                    break;

                default:
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
                }
            } while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false));
        }
Пример #13
0
        internal static void MergeEnumerableContent(JContainer target, IEnumerable content, JsonMergeSettings settings)
        {
            switch (settings.MergeArrayHandling)
            {
            case MergeArrayHandling.Concat:
                foreach (JToken token in content)
                {
                    target.Add(token);
                }
                break;

            case MergeArrayHandling.Union:
            {
                HashSet <JToken> set = new HashSet <JToken>(target, JToken.EqualityComparer);
                foreach (JToken token2 in content)
                {
                    if (set.Add(token2))
                    {
                        target.Add(token2);
                    }
                }
                break;
            }

            case MergeArrayHandling.Replace:
                target.ClearItems();
                foreach (JToken token3 in content)
                {
                    target.Add(token3);
                }
                break;

            case MergeArrayHandling.Merge:
            {
                int num = 0;
                foreach (object obj2 in content)
                {
                    if (num < target.Count)
                    {
                        JContainer container = target[num] as JContainer;
                        if (container != null)
                        {
                            container.Merge(obj2, settings);
                        }
                        else if (obj2 != null)
                        {
                            JToken token4 = CreateFromContent(obj2);
                            if (token4.Type != JTokenType.Null)
                            {
                                target[num] = token4;
                            }
                        }
                    }
                    else
                    {
                        target.Add(obj2);
                    }
                    num++;
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("settings", "Unexpected merge array handling when merging JSON.");
            }
        }
Пример #14
0
        internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings)
        {
            ValidationUtils.ArgumentNotNull(r, nameof(r));
            IJsonLineInfo lineInfo = r as IJsonLineInfo;

            JContainer parent = this;

            do
            {
                if ((parent as JProperty)?.Value != null)
                {
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                }

                switch (r.TokenType)
                {
                case JsonToken.None:
                    // new reader. move to actual content
                    break;

                case JsonToken.StartArray:
                    JArray a = new JArray();
                    a.SetLineInfo(lineInfo, settings);
                    parent.Add(a);
                    parent = a;
                    break;

                case JsonToken.EndArray:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartObject:
                    JObject o = new JObject();
                    o.SetLineInfo(lineInfo, settings);
                    parent.Add(o);
                    parent = o;
                    break;

                case JsonToken.EndObject:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartConstructor:
                    JConstructor constructor = new JConstructor(r.Value.ToString());
                    constructor.SetLineInfo(lineInfo, settings);
                    parent.Add(constructor);
                    parent = constructor;
                    break;

                case JsonToken.EndConstructor:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.String:
                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.Date:
                case JsonToken.Boolean:
                case JsonToken.Bytes:
                    JValue v = new JValue(r.Value);
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.Comment:
                    if (settings != null && settings.CommentHandling == CommentHandling.Load)
                    {
                        v = JValue.CreateComment(r.Value.ToString());
                        v.SetLineInfo(lineInfo, settings);
                        parent.Add(v);
                    }
                    break;

                case JsonToken.Null:
                    v = JValue.CreateNull();
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.Undefined:
                    v = JValue.CreateUndefined();
                    v.SetLineInfo(lineInfo, settings);
                    parent.Add(v);
                    break;

                case JsonToken.PropertyName:
                    string    propertyName = r.Value.ToString();
                    JProperty property     = new JProperty(propertyName);
                    property.SetLineInfo(lineInfo, settings);
                    JObject parentObject = (JObject)parent;
                    // handle multiple properties with the same name in JSON
                    JProperty existingPropertyWithName = parentObject.Property(propertyName);
                    if (existingPropertyWithName == null)
                    {
                        parent.Add(property);
                    }
                    else
                    {
                        existingPropertyWithName.Replace(property);
                    }
                    parent = property;
                    break;

                case JsonToken.SmallDec:
                case JsonToken.PercentValV2:
                    try
                    {
                        v = new JValue(r.Value);
                        v.SetLineInfo(lineInfo, settings);
                        parent.Add(v);
                        break;
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine("Exception called from JContainer->ReadContentFrom of type " + ex.ToString());
                        throw;
                    }
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));

                default:
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
                }
            } while (r.Read());
        }
Пример #15
0
        internal void ReadContentFrom(JsonReader r)
        {
            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo lineInfo = r as IJsonLineInfo;

            JContainer parent = this;

            do
            {
                if (parent is JProperty && ((JProperty)parent).Value != null)
                {
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                }

                switch (r.TokenType)
                {
                case JsonToken.None:
                    // new reader. move to actual content
                    break;

                case JsonToken.StartArray:
                    JArray a = new JArray();
                    a.SetLineInfo(lineInfo);
                    parent.Add(a);
                    parent = a;
                    break;

                case JsonToken.EndArray:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartObject:
                    JObject o = new JObject();
                    o.SetLineInfo(lineInfo);
                    parent.Add(o);
                    parent = o;
                    break;

                case JsonToken.EndObject:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.StartConstructor:
                    JConstructor constructor = new JConstructor(r.Value.ToString());
                    constructor.SetLineInfo(constructor);
                    parent.Add(constructor);
                    parent = constructor;
                    break;

                case JsonToken.EndConstructor:
                    if (parent == this)
                    {
                        return;
                    }

                    parent = parent.Parent;
                    break;

                case JsonToken.String:
                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.Date:
                case JsonToken.Boolean:
                case JsonToken.Bytes:
                    JValue v = new JValue(r.Value);
                    v.SetLineInfo(lineInfo);
                    parent.Add(v);
                    break;

                case JsonToken.Comment:
                    v = JValue.CreateComment(r.Value.ToString());
                    v.SetLineInfo(lineInfo);
                    parent.Add(v);
                    break;

                case JsonToken.Null:
                    v = new JValue(null, JTokenType.Null);
                    v.SetLineInfo(lineInfo);
                    parent.Add(v);
                    break;

                case JsonToken.Undefined:
                    v = new JValue(null, JTokenType.Undefined);
                    v.SetLineInfo(lineInfo);
                    parent.Add(v);
                    break;

                case JsonToken.PropertyName:
                    string    propertyName = r.Value.ToString();
                    JProperty property     = new JProperty(propertyName);
                    property.SetLineInfo(lineInfo);
                    JObject parentObject = (JObject)parent;
                    // handle multiple properties with the same name in JSON
                    JProperty existingPropertyWithName = parentObject.Property(propertyName);
                    if (existingPropertyWithName == null)
                    {
                        parent.Add(property);
                    }
                    else
                    {
                        existingPropertyWithName.Replace(property);
                    }
                    parent = property;
                    break;

                default:
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
                }
            }while (r.Read());
        }
Пример #16
0
        internal void ReadContentFrom(JsonReader r, JsonLoadSettings settings)
        {
            JValue jValue;
            bool   value;

            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo jsonLineInfo = r as IJsonLineInfo;
            JContainer    parent       = this;

            do
            {
                JProperty jProperty = parent as JProperty;
                if (jProperty != null)
                {
                    value = jProperty.Value;
                }
                else
                {
                    value = false;
                }
                if (value)
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                }
                switch (r.TokenType)
                {
                case JsonToken.None:
                {
                    continue;
                }

                case JsonToken.StartObject:
                {
                    JObject jObjects = new JObject();
                    jObjects.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jObjects);
                    parent = jObjects;
                    continue;
                }

                case JsonToken.StartArray:
                {
                    JArray jArrays = new JArray();
                    jArrays.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jArrays);
                    parent = jArrays;
                    continue;
                }

                case JsonToken.StartConstructor:
                {
                    JConstructor jConstructor = new JConstructor(r.Value.ToString());
                    jConstructor.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jConstructor);
                    parent = jConstructor;
                    continue;
                }

                case JsonToken.PropertyName:
                {
                    string    str        = r.Value.ToString();
                    JProperty jProperty1 = new JProperty(str);
                    jProperty1.SetLineInfo(jsonLineInfo, settings);
                    JProperty jProperty2 = ((JObject)parent).Property(str);
                    if (jProperty2 != null)
                    {
                        jProperty2.Replace(jProperty1);
                    }
                    else
                    {
                        parent.Add(jProperty1);
                    }
                    parent = jProperty1;
                    continue;
                }

                case JsonToken.Comment:
                {
                    if (settings == null || settings.CommentHandling != CommentHandling.Load)
                    {
                        continue;
                    }
                    jValue = JValue.CreateComment(r.Value.ToString());
                    jValue.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Raw:
                {
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
                }

                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.String:
                case JsonToken.Boolean:
                case JsonToken.Date:
                case JsonToken.Bytes:
                {
                    jValue = new JValue(r.Value);
                    jValue.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Null:
                {
                    jValue = JValue.CreateNull();
                    jValue.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Undefined:
                {
                    jValue = JValue.CreateUndefined();
                    jValue.SetLineInfo(jsonLineInfo, settings);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.EndObject:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                case JsonToken.EndArray:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                case JsonToken.EndConstructor:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                default:
                {
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.InvariantCulture, r.TokenType));
                }
                }
            }while (r.Read());
        }
Пример #17
0
        internal static void MergeEnumerableContent(JContainer target, IEnumerable content, JsonMergeSettings settings)
        {
            IEnumerator enumerator;
            IDisposable disposable;

            switch (settings.MergeArrayHandling)
            {
            case MergeArrayHandling.Concat:
            {
                enumerator = content.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        target.Add((JToken)enumerator.Current);
                    }
                    break;
                }
                finally
                {
                    disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                break;
            }

            case MergeArrayHandling.Union:
            {
                HashSet <JToken> jTokens = new HashSet <JToken>(target, JToken.EqualityComparer);
                enumerator = content.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        JToken current = (JToken)enumerator.Current;
                        if (!jTokens.Add(current))
                        {
                            continue;
                        }
                        target.Add(current);
                    }
                    break;
                }
                finally
                {
                    disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                break;
            }

            case MergeArrayHandling.Replace:
            {
                target.ClearItems();
                enumerator = content.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        target.Add((JToken)enumerator.Current);
                    }
                    break;
                }
                finally
                {
                    disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                break;
            }

            case MergeArrayHandling.Merge:
            {
                int num = 0;
                enumerator = content.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object obj = enumerator.Current;
                        if (num >= target.Count)
                        {
                            target.Add(obj);
                        }
                        else
                        {
                            JContainer item = target[num] as JContainer;
                            if (item != null)
                            {
                                item.Merge(obj, settings);
                            }
                            else if (obj != null)
                            {
                                JToken jTokens1 = JContainer.CreateFromContent(obj);
                                if (jTokens1.Type != JTokenType.Null)
                                {
                                    target[num] = jTokens1;
                                }
                            }
                        }
                        num++;
                    }
                    break;
                }
                finally
                {
                    disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException("settings", "Unexpected merge array handling when merging JSON.");
            }
            }
        }
Пример #18
0
        internal void ReadContentFrom(JsonReader r)
        {
            ValidationUtils.ArgumentNotNull((object)r, "r");
            IJsonLineInfo lineInfo   = r as IJsonLineInfo;
            JContainer    jcontainer = this;

            do
            {
                if (jcontainer is JProperty && ((JProperty)jcontainer).Value != null)
                {
                    if (jcontainer == this)
                    {
                        break;
                    }
                    jcontainer = jcontainer.Parent;
                }
                switch (r.TokenType)
                {
                case JsonToken.None:
                    continue;

                case JsonToken.StartObject:
                    JObject jobject = new JObject();
                    jobject.SetLineInfo(lineInfo);
                    jcontainer.Add((object)jobject);
                    jcontainer = (JContainer)jobject;
                    goto case 0;

                case JsonToken.StartArray:
                    JArray jarray = new JArray();
                    jarray.SetLineInfo(lineInfo);
                    jcontainer.Add((object)jarray);
                    jcontainer = (JContainer)jarray;
                    goto case 0;

                case JsonToken.StartConstructor:
                    JConstructor jconstructor = new JConstructor(r.Value.ToString());
                    jconstructor.SetLineInfo((IJsonLineInfo)jconstructor);
                    jcontainer.Add((object)jconstructor);
                    jcontainer = (JContainer)jconstructor;
                    goto case 0;

                case JsonToken.PropertyName:
                    string    name       = r.Value.ToString();
                    JProperty jproperty1 = new JProperty(name);
                    jproperty1.SetLineInfo(lineInfo);
                    JProperty jproperty2 = ((JObject)jcontainer).Property(name);
                    if (jproperty2 == null)
                    {
                        jcontainer.Add((object)jproperty1);
                    }
                    else
                    {
                        jproperty2.Replace((JToken)jproperty1);
                    }
                    jcontainer = (JContainer)jproperty1;
                    goto case 0;

                case JsonToken.Comment:
                    JValue comment = JValue.CreateComment(r.Value.ToString());
                    comment.SetLineInfo(lineInfo);
                    jcontainer.Add((object)comment);
                    goto case 0;

                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.String:
                case JsonToken.Boolean:
                case JsonToken.Date:
                case JsonToken.Bytes:
                    JValue jvalue1 = new JValue(r.Value);
                    jvalue1.SetLineInfo(lineInfo);
                    jcontainer.Add((object)jvalue1);
                    goto case 0;

                case JsonToken.Null:
                    JValue jvalue2 = new JValue((object)null, JTokenType.Null);
                    jvalue2.SetLineInfo(lineInfo);
                    jcontainer.Add((object)jvalue2);
                    goto case 0;

                case JsonToken.Undefined:
                    JValue jvalue3 = new JValue((object)null, JTokenType.Undefined);
                    jvalue3.SetLineInfo(lineInfo);
                    jcontainer.Add((object)jvalue3);
                    goto case 0;

                case JsonToken.EndObject:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto case 0;

                case JsonToken.EndArray:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto case 0;

                case JsonToken.EndConstructor:
                    if (jcontainer == this)
                    {
                        return;
                    }
                    jcontainer = jcontainer.Parent;
                    goto case 0;

                default:
                    throw new InvalidOperationException(StringUtils.FormatWith("The JsonReader should not be on a token of type {0}.", (IFormatProvider)CultureInfo.InvariantCulture, (object)r.TokenType));
                }
            }while (r.Read());
        }
        internal void ReadContentFrom(JsonReader r)
        {
            JValue jValue;

            object[]    tokenType;
            CultureInfo invariantCulture;

            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo jsonLineInfo = r as IJsonLineInfo;
            JContainer    parent       = this;

            do
            {
                if (parent is JProperty && ((JProperty)parent).Value != null)
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                }
                switch (r.TokenType)
                {
                case JsonToken.None:
                {
                    continue;
                }

                case JsonToken.StartObject:
                {
                    JObject jObjects = new JObject();
                    jObjects.SetLineInfo(jsonLineInfo);
                    parent.Add(jObjects);
                    parent = jObjects;
                    continue;
                }

                case JsonToken.StartArray:
                {
                    JArray jArrays = new JArray();
                    jArrays.SetLineInfo(jsonLineInfo);
                    parent.Add(jArrays);
                    parent = jArrays;
                    continue;
                }

                case JsonToken.StartConstructor:
                {
                    JConstructor jConstructor = new JConstructor(r.Value.ToString());
                    jConstructor.SetLineInfo(jConstructor);
                    parent.Add(jConstructor);
                    parent = jConstructor;
                    continue;
                }

                case JsonToken.PropertyName:
                {
                    string    str       = r.Value.ToString();
                    JProperty jProperty = new JProperty(str);
                    jProperty.SetLineInfo(jsonLineInfo);
                    JProperty jProperty1 = ((JObject)parent).Property(str);
                    if (jProperty1 != null)
                    {
                        jProperty1.Replace(jProperty);
                    }
                    else
                    {
                        parent.Add(jProperty);
                    }
                    parent = jProperty;
                    continue;
                }

                case JsonToken.Comment:
                {
                    jValue = JValue.CreateComment(r.Value.ToString());
                    jValue.SetLineInfo(jsonLineInfo);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Raw:
                {
                    invariantCulture = CultureInfo.InvariantCulture;
                    tokenType        = new object[] { r.TokenType };
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(invariantCulture, tokenType));
                }

                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.String:
                case JsonToken.Boolean:
                case JsonToken.Date:
                case JsonToken.Bytes:
                {
                    jValue = new JValue(r.Value);
                    jValue.SetLineInfo(jsonLineInfo);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Null:
                {
                    jValue = new JValue(null, JTokenType.Null);
                    jValue.SetLineInfo(jsonLineInfo);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.Undefined:
                {
                    jValue = new JValue(null, JTokenType.Undefined);
                    jValue.SetLineInfo(jsonLineInfo);
                    parent.Add(jValue);
                    continue;
                }

                case JsonToken.EndObject:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                case JsonToken.EndArray:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                case JsonToken.EndConstructor:
                {
                    if (parent == this)
                    {
                        return;
                    }
                    parent = parent.Parent;
                    continue;
                }

                default:
                {
                    invariantCulture = CultureInfo.InvariantCulture;
                    tokenType        = new object[] { r.TokenType };
                    throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(invariantCulture, tokenType));
                }
                }
            }while (r.Read());
        }
        internal void ReadContentFrom(JsonReader r)
        {
            ValidationUtils.ArgumentNotNull(r, "r");
            IJsonLineInfo lineInfo   = r as IJsonLineInfo;
            JContainer    jContainer = this;

            while (true)
            {
                if (jContainer is JProperty && ((JProperty)jContainer).Value != null)
                {
                    if (jContainer == this)
                    {
                        break;
                    }
                    jContainer = jContainer.Parent;
                }
                switch (r.TokenType)
                {
                case JsonToken.None:
                    goto IL_242;

                case JsonToken.StartObject:
                {
                    JObject jObject = new JObject();
                    jObject.SetLineInfo(lineInfo);
                    jContainer.Add(jObject);
                    jContainer = jObject;
                    goto IL_242;
                }

                case JsonToken.StartArray:
                {
                    JArray jArray = new JArray();
                    jArray.SetLineInfo(lineInfo);
                    jContainer.Add(jArray);
                    jContainer = jArray;
                    goto IL_242;
                }

                case JsonToken.StartConstructor:
                {
                    JConstructor jConstructor = new JConstructor(r.Value.ToString());
                    jConstructor.SetLineInfo(jConstructor);
                    jContainer.Add(jConstructor);
                    jContainer = jConstructor;
                    goto IL_242;
                }

                case JsonToken.PropertyName:
                {
                    string    name      = r.Value.ToString();
                    JProperty jProperty = new JProperty(name);
                    jProperty.SetLineInfo(lineInfo);
                    JObject   jObject2   = (JObject)jContainer;
                    JProperty jProperty2 = jObject2.Property(name);
                    if (jProperty2 == null)
                    {
                        jContainer.Add(jProperty);
                    }
                    else
                    {
                        jProperty2.Replace(jProperty);
                    }
                    jContainer = jProperty;
                    goto IL_242;
                }

                case JsonToken.Comment:
                {
                    JValue jValue = JValue.CreateComment(r.Value.ToString());
                    jValue.SetLineInfo(lineInfo);
                    jContainer.Add(jValue);
                    goto IL_242;
                }

                case JsonToken.Integer:
                case JsonToken.Float:
                case JsonToken.String:
                case JsonToken.Boolean:
                case JsonToken.Date:
                case JsonToken.Bytes:
                {
                    JValue jValue = new JValue(r.Value);
                    jValue.SetLineInfo(lineInfo);
                    jContainer.Add(jValue);
                    goto IL_242;
                }

                case JsonToken.Null:
                {
                    JValue jValue = new JValue(null, JTokenType.Null);
                    jValue.SetLineInfo(lineInfo);
                    jContainer.Add(jValue);
                    goto IL_242;
                }

                case JsonToken.Undefined:
                {
                    JValue jValue = new JValue(null, JTokenType.Undefined);
                    jValue.SetLineInfo(lineInfo);
                    jContainer.Add(jValue);
                    goto IL_242;
                }

                case JsonToken.EndObject:
                    if (jContainer == this)
                    {
                        return;
                    }
                    jContainer = jContainer.Parent;
                    goto IL_242;

                case JsonToken.EndArray:
                    if (jContainer == this)
                    {
                        return;
                    }
                    jContainer = jContainer.Parent;
                    goto IL_242;

                case JsonToken.EndConstructor:
                    if (jContainer == this)
                    {
                        return;
                    }
                    jContainer = jContainer.Parent;
                    goto IL_242;
                }
                goto Block_4;
IL_242:
                if (!r.Read())
                {
                    return;
                }
            }
            return;

Block_4:
            throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".FormatWith(CultureInfo.get_InvariantCulture(), new object[]
            {
                r.TokenType
            }));
        }
Пример #21
0
        internal void method_11(JsonReader jsonReader_0)
        {
            JValue    value2;
            JProperty property;

            Class203.smethod_2(jsonReader_0, "r");
            IJsonLineInfo info   = jsonReader_0 as IJsonLineInfo;
            JContainer    parent = this;

            goto Label_0204;
Label_01D8:
            if (!jsonReader_0.Read())
            {
                return;
            }
Label_0204:
            if ((parent is JProperty) && (((JProperty)parent).Value != null))
            {
                if (parent == this)
                {
                    return;
                }
                parent = parent.Parent;
            }
            switch (jsonReader_0.JsonToken_0)
            {
            case JsonToken.None:
                goto Label_01D8;

            case JsonToken.StartObject:
            {
                JObject content = new JObject();
                content.method_0(info);
                parent.Add(content);
                parent = content;
                goto Label_01D8;
            }

            case JsonToken.StartArray:
            {
                JArray array = new JArray();
                array.method_0(info);
                parent.Add(array);
                parent = array;
                goto Label_01D8;
            }

            case JsonToken.StartConstructor:
            {
                JConstructor constructor = new JConstructor(jsonReader_0.Object_0.ToString());
                constructor.method_0(constructor);
                parent.Add(constructor);
                parent = constructor;
                goto Label_01D8;
            }

            case JsonToken.PropertyName:
            {
                string name = jsonReader_0.Object_0.ToString();
                property = new JProperty(name);
                property.method_0(info);
                JProperty property2 = ((JObject)parent).Property(name);
                if (property2 != null)
                {
                    property2.Replace(property);
                    break;
                }
                parent.Add(property);
                break;
            }

            case JsonToken.Comment:
                value2 = JValue.CreateComment(jsonReader_0.Object_0.ToString());
                value2.method_0(info);
                parent.Add(value2);
                goto Label_01D8;

            case JsonToken.Integer:
            case JsonToken.Float:
            case JsonToken.String:
            case JsonToken.Boolean:
            case JsonToken.Date:
            case JsonToken.Bytes:
                value2 = new JValue(jsonReader_0.Object_0);
                value2.method_0(info);
                parent.Add(value2);
                goto Label_01D8;

            case JsonToken.Null:
                value2 = new JValue(null, JTokenType.Null);
                value2.method_0(info);
                parent.Add(value2);
                goto Label_01D8;

            case JsonToken.Undefined:
                value2 = new JValue(null, JTokenType.Undefined);
                value2.method_0(info);
                parent.Add(value2);
                goto Label_01D8;

            case JsonToken.EndObject:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_01D8;
                }
                return;

            case JsonToken.EndArray:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_01D8;
                }
                return;

            case JsonToken.EndConstructor:
                if (parent != this)
                {
                    parent = parent.Parent;
                    goto Label_01D8;
                }
                return;

            default:
                throw new InvalidOperationException("The JsonReader should not be on a token of type {0}.".smethod_0(CultureInfo.InvariantCulture, jsonReader_0.JsonToken_0));
            }
            parent = property;
            goto Label_01D8;
        }