Пример #1
0
        private static void ParseArray(JArray json, CustomConfigurationValue customConfiguration)
        {
            foreach (var element in json)
            {
                var configValue = new CustomConfigurationValue();
                customConfiguration.Values.Add(configValue);

                Parse(element, configValue);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 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);
     }
 }
Пример #4
0
 private static void ParseToken(JToken json, CustomConfigurationValue customConfiguration)
 {
     customConfiguration.Value = json.Value <string>();
 }
Пример #5
0
 public JsonCustomConfiguration(JObject jsonObject)
 {
     _value = new CustomConfigurationValue();
     Parse(jsonObject, _value);
 }