// We will be working with one if this class' children - object or array - so we need to // use the add method that's appropriate for that child private void AddSelector(string key, JsonBaseType value) { JsonArray thisArray = this as JsonArray; if (thisArray != null) { thisArray.Add(value); } else { ((JsonObject)this).Add(key, value); } }
// Implement the correct add method for an array internal void Add(JsonBaseType value) { ((List <JsonBaseType>)InternalValue).Add(value); }
// Implement the correct add method for an object (dictionary) internal void Add(string key, JsonBaseType value) { ((Dictionary <string, JsonBaseType>)InternalValue).Add(key, value); }