internal void AddInternal(int index, object content, bool skipParentCheck) { if (this.IsMultiContent(content)) { IEnumerable enumerable = (IEnumerable)content; int index1 = index; foreach (object content1 in enumerable) { this.AddInternal(index1, content1, skipParentCheck); ++index1; } } else { JToken fromContent = JContainer.CreateFromContent(content); this.InsertItem(index, fromContent, skipParentCheck); } }
public JProperty(string name, object content) { ValidationUtils.ArgumentNotNull((object) name, nameof(name)); this._name = name; this.Value = this.IsMultiContent(content) ? (JToken) new JArray(content) : JContainer.CreateFromContent(content); }
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 { (enumerator1 as IDisposable)?.Dispose(); } case MergeArrayHandling.Union: Dictionary <JToken, bool> dictionary = new Dictionary <JToken, bool>((IEqualityComparer <JToken>)JToken.EqualityComparer); foreach (JToken index in (IEnumerable <JToken>)target) { dictionary[index] = true; } IEnumerator enumerator2 = content.GetEnumerator(); try { while (enumerator2.MoveNext()) { JToken current = (JToken)enumerator2.Current; if (!dictionary.ContainsKey(current)) { dictionary[current] = true; target.Add((object)current); } } break; } finally { (enumerator2 as IDisposable)?.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 { (enumerator3 as IDisposable)?.Dispose(); } case MergeArrayHandling.Merge: int num = 0; IEnumerator enumerator4 = content.GetEnumerator(); try { while (enumerator4.MoveNext()) { object current = enumerator4.Current; if (num < target.Count) { JContainer jcontainer = target[(object)num] as JContainer; if (jcontainer != null) { 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 { (enumerator4 as IDisposable)?.Dispose(); } default: throw new ArgumentOutOfRangeException(nameof(settings), "Unexpected merge array handling when merging JSON."); } }