private object CreateTypedValue(ITypedPropertyKey key, string value) { if (key.GetValueType() == typeof(bool)) { try { return(bool.Parse(value)); } catch (Exception e) { throw new TypedPropertyValueException(key, value, e.Message); }; } if (key.GetValueType() == typeof(int)) { try { return(int.Parse(value)); } catch (Exception e) { throw new TypedPropertyValueException(key, value, e.Message); } } if (key.GetValueType() == typeof(long)) { try { return(long.Parse(value)); } catch (Exception e) { throw new TypedPropertyValueException(key, value, e.Message); } } return(value); }
public TypedPropertyValueException(ITypedPropertyKey key, string value, string error) : base($"Value `{value}` of `{key.GetKey()}` cannot convert to type `{key.GetValueType().Name}`,error:{error}.") { }