public IEnumerable<int> CreateIntegerStreamWithoutRedMaps(JsonObject obj) { switch(obj.Type) { case JsonObjectType.Array: foreach(var item in SumArray((JsonArray)obj)) { yield return item; } break; case JsonObjectType.Map: foreach(var element in SumMap((JsonMap)obj)) { yield return element; } break; case JsonObjectType.ValueInt: yield return ((JsonInteger)obj).Value; break; case JsonObjectType.ValueString: yield return 0; break; default: throw new ArgumentOutOfRangeException(nameof(obj), obj, "Unhandled type"); } }
public JsonProperty(string property, JsonObject value) { if(string.IsNullOrEmpty(property)) { throw new ArgumentNullException(nameof(property)); } if(value == null) { throw new ArgumentNullException(nameof(value)); } Property = property; Value = value; }