/// <summary>Construct a JSONObject from a Map.</summary> /// <param name="map"> /// A map object that can be used to initialize the contents of /// the JSONObject. /// </param> /// <exception cref="JSONException"/> public JSONObject(System.Collections.Generic.IDictionary<string, object> map) { this.map = new System.Collections.Generic.Dictionary<string, object>(); if (map != null) { System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> i = map.GetEnumerator(); while (i.HasNext()) { System.Collections.Generic.KeyValuePair<string, object> entry = i.Next(); object value = entry.Value; if (value != null) { this.map[entry.Key] = Wrap(value); } } } }
private void SetUnpackedValueOfDictStaticKeyAndStaticItem(MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictStaticKeyAndStaticItemGetOnlyCollectionProperty unpackingContext, System.Collections.Generic.IDictionary <string, string> unpackedValue) { System.Collections.Generic.IDictionary <string, string> existent = default(System.Collections.Generic.IDictionary <string, string>); existent = unpackingContext.DictStaticKeyAndStaticItem; System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator = unpackedValue.GetEnumerator(); System.Collections.Generic.KeyValuePair <string, string> current; try { for ( ; enumerator.MoveNext(); ) { current = enumerator.Current; existent.Add(current.Key, current.Value); } } finally { enumerator.Dispose(); } }
private void SetUnpackedValueOfDictStaticKeyAndStaticItem(MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictStaticKeyAndStaticItemPrivateSetterCollectionProperty unpackingContext, System.Collections.Generic.IDictionary <string, string> unpackedValue) { System.Collections.Generic.IDictionary <string, string> existent = default(System.Collections.Generic.IDictionary <string, string>); existent = unpackingContext.DictStaticKeyAndStaticItem; if ((existent == null)) { this._methodBasePolymorphicMemberTypeRuntimeType_Dict_DictStaticKeyAndStaticItemPrivateSetterCollectionProperty_set_DictStaticKeyAndStaticItem0.Invoke(unpackingContext, new object[] { unpackedValue }); } else { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator = unpackedValue.GetEnumerator(); System.Collections.Generic.KeyValuePair <string, string> current; try { for ( ; enumerator.MoveNext(); ) { current = enumerator.Current; existent.Add(current.Key, current.Value); } } finally { enumerator.Dispose(); } } }
protected internal override MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictObjectKeyAndStaticItemReadOnlyCollectionField UnpackFromCore(MsgPack.Unpacker unpacker) { MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictObjectKeyAndStaticItemReadOnlyCollectionField result = default(MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictObjectKeyAndStaticItemReadOnlyCollectionField); result = new MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictObjectKeyAndStaticItemReadOnlyCollectionField(); if (unpacker.IsArrayHeader) { int unpacked = default(int); int itemsCount = default(int); itemsCount = MsgPack.Serialization.UnpackHelpers.GetItemsCount(unpacker); System.Collections.Generic.IDictionary <object, string> nullable = default(System.Collections.Generic.IDictionary <object, string>); if ((unpacked < itemsCount)) { if ((unpacker.Read() == false)) { throw MsgPack.Serialization.SerializationExceptions.NewMissingItem(0); } if (((unpacker.IsArrayHeader == false) && (unpacker.IsMapHeader == false))) { nullable = this._serializer0.UnpackFrom(unpacker); } else { MsgPack.Unpacker disposable = default(MsgPack.Unpacker); disposable = unpacker.ReadSubtree(); try { nullable = this._serializer0.UnpackFrom(disposable); } finally { if (((disposable == null) == false)) { disposable.Dispose(); } } } } if (((nullable == null) == false)) { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <object, string> > enumerator = nullable.GetEnumerator(); System.Collections.Generic.KeyValuePair <object, string> current; try { for ( ; enumerator.MoveNext(); ) { current = enumerator.Current; result.DictObjectKeyAndStaticItem.Add(current.Key, current.Value); } } finally { enumerator.Dispose(); } } unpacked = (unpacked + 1); } else { int itemsCount0 = default(int); itemsCount0 = MsgPack.Serialization.UnpackHelpers.GetItemsCount(unpacker); for (int i = 0; (i < itemsCount0); i = (i + 1)) { string key = default(string); string nullable0 = default(string); nullable0 = MsgPack.Serialization.UnpackHelpers.UnpackStringValue(unpacker, typeof(MsgPack.Serialization.PolymorphicMemberTypeRuntimeType_Dict_DictObjectKeyAndStaticItemReadOnlyCollectionField), "MemberName"); if (((nullable0 == null) == false)) { key = nullable0; } else { throw MsgPack.Serialization.SerializationExceptions.NewNullIsProhibited("MemberName"); } if ((key == "DictObjectKeyAndStaticItem")) { System.Collections.Generic.IDictionary <object, string> nullable1 = default(System.Collections.Generic.IDictionary <object, string>); if ((unpacker.Read() == false)) { throw MsgPack.Serialization.SerializationExceptions.NewMissingItem(i); } if (((unpacker.IsArrayHeader == false) && (unpacker.IsMapHeader == false))) { nullable1 = this._serializer0.UnpackFrom(unpacker); } else { MsgPack.Unpacker disposable0 = default(MsgPack.Unpacker); disposable0 = unpacker.ReadSubtree(); try { nullable1 = this._serializer0.UnpackFrom(disposable0); } finally { if (((disposable0 == null) == false)) { disposable0.Dispose(); } } } if (((nullable1 == null) == false)) { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <object, string> > enumerator0 = nullable1.GetEnumerator(); System.Collections.Generic.KeyValuePair <object, string> current0; try { for ( ; enumerator0.MoveNext(); ) { current0 = enumerator0.Current; result.DictObjectKeyAndStaticItem.Add(current0.Key, current0.Value); } } finally { enumerator0.Dispose(); } } } else { unpacker.Skip(); } } } return(result); }
protected internal override MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty UnpackFromCore(MsgPack.Unpacker unpacker) { MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty result = default(MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty); result = new MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty(); if (unpacker.IsArrayHeader) { int unpacked = default(int); int itemsCount = default(int); itemsCount = MsgPack.Serialization.UnpackHelpers.GetItemsCount(unpacker); System.Collections.Generic.IDictionary <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> nullable = default(System.Collections.Generic.IDictionary <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry>); if ((unpacked < itemsCount)) { if ((unpacker.Read() == false)) { throw MsgPack.Serialization.SerializationExceptions.NewMissingItem(0); } if (((unpacker.IsArrayHeader == false) && (unpacker.IsMapHeader == false))) { nullable = this._serializer0.UnpackFrom(unpacker); } else { MsgPack.Unpacker disposable = default(MsgPack.Unpacker); disposable = unpacker.ReadSubtree(); try { nullable = this._serializer0.UnpackFrom(disposable); } finally { if (((disposable == null) == false)) { disposable.Dispose(); } } } } if (((nullable == null) == false)) { if ((result.DictPolymorphicKeyAndItem == null)) { this._methodBasePolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty_set_DictPolymorphicKeyAndItem0.Invoke(result, new object[] { nullable }); } else { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> > enumerator = nullable.GetEnumerator(); System.Collections.Generic.KeyValuePair <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> current; try { for ( ; enumerator.MoveNext(); ) { current = enumerator.Current; result.DictPolymorphicKeyAndItem.Add(current.Key, current.Value); } } finally { enumerator.Dispose(); } } } unpacked = (unpacked + 1); } else { int itemsCount0 = default(int); itemsCount0 = MsgPack.Serialization.UnpackHelpers.GetItemsCount(unpacker); for (int i = 0; (i < itemsCount0); i = (i + 1)) { string key = default(string); string nullable0 = default(string); nullable0 = MsgPack.Serialization.UnpackHelpers.UnpackStringValue(unpacker, typeof(MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty), "MemberName"); if (((nullable0 == null) == false)) { key = nullable0; } else { throw MsgPack.Serialization.SerializationExceptions.NewNullIsProhibited("MemberName"); } if ((key == "DictPolymorphicKeyAndItem")) { System.Collections.Generic.IDictionary <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> nullable1 = default(System.Collections.Generic.IDictionary <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry>); if ((unpacker.Read() == false)) { throw MsgPack.Serialization.SerializationExceptions.NewMissingItem(i); } if (((unpacker.IsArrayHeader == false) && (unpacker.IsMapHeader == false))) { nullable1 = this._serializer0.UnpackFrom(unpacker); } else { MsgPack.Unpacker disposable0 = default(MsgPack.Unpacker); disposable0 = unpacker.ReadSubtree(); try { nullable1 = this._serializer0.UnpackFrom(disposable0); } finally { if (((disposable0 == null) == false)) { disposable0.Dispose(); } } } if (((nullable1 == null) == false)) { if ((result.DictPolymorphicKeyAndItem == null)) { this._methodBasePolymorphicMemberTypeKnownType_Dict_DictPolymorphicKeyAndItemPrivateSetterCollectionProperty_set_DictPolymorphicKeyAndItem0.Invoke(result, new object[] { nullable1 }); } else { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> > enumerator0 = nullable1.GetEnumerator(); System.Collections.Generic.KeyValuePair <MsgPack.Serialization.FileSystemEntry, MsgPack.Serialization.FileSystemEntry> current0; try { for ( ; enumerator0.MoveNext(); ) { current0 = enumerator0.Current; result.DictPolymorphicKeyAndItem.Add(current0.Key, current0.Value); } } finally { enumerator0.Dispose(); } } } } else { unpacker.Skip(); } } } return(result); }
private void SetUnpackedValueOfDictObjectKeyAndItem(MsgPack.Serialization.PolymorphicMemberTypeKnownType_Dict_DictObjectKeyAndItemReadOnlyCollectionField unpackingContext, System.Collections.Generic.IDictionary <object, object> unpackedValue) { System.Collections.Generic.IDictionary <object, object> existent = default(System.Collections.Generic.IDictionary <object, object>); existent = unpackingContext.DictObjectKeyAndItem; System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <object, object> > enumerator = unpackedValue.GetEnumerator(); System.Collections.Generic.KeyValuePair <object, object> current; try { for ( ; enumerator.MoveNext(); ) { current = enumerator.Current; existent.Add(current.Key, current.Value); } } finally { enumerator.Dispose(); } }