private static void ParseArray(JArray json, CustomConfigurationValue customConfiguration) { foreach (var element in json) { var configValue = new CustomConfigurationValue(); customConfiguration.Values.Add(configValue); Parse(element, configValue); } }
private static void ParseObject(JObject json, CustomConfigurationValue customConfiguration) { foreach (var child in json.Children()) { var property = (JProperty)child; var configValue = new CustomConfigurationValue { Key = property.Name }; customConfiguration.Values.Add(configValue); Parse(property.Value, configValue); } }
private static void Parse(JToken jsonToken, CustomConfigurationValue customConfiguration) { if (jsonToken is JObject) { ParseObject((JObject)jsonToken, customConfiguration); } else if (jsonToken is JArray) { ParseArray((JArray)jsonToken, customConfiguration); } else { ParseToken(jsonToken, customConfiguration); } }
private static void ParseToken(JToken json, CustomConfigurationValue customConfiguration) { customConfiguration.Value = json.Value <string>(); }
public JsonCustomConfiguration(JObject jsonObject) { _value = new CustomConfigurationValue(); Parse(jsonObject, _value); }