/// <exception cref="ArgumentException"></exception> /// <exception cref="JsonReaderException"></exception> public static object GetValue(this ISerealizedValueTypeProvider configSetting) { if (configSetting.ValueString == null) { return(null); } Type type = configSetting.GetValueType(); object result = JsonConvert.DeserializeObject(configSetting.ValueString, type); return(result); }
public static bool TryGetValue(this ISerealizedValueTypeProvider configSetting, out object result) { if (configSetting.ValueString == null) { result = null; return(true); } bool hasError = false; JsonSerializerSettings serializerSettings = new JsonSerializerSettings { Error = (sender, args) => hasError = true }; Type type = configSetting.GetValueType(); result = JsonConvert.DeserializeObject(configSetting.ValueString, type, serializerSettings); return(hasError); }