private bool TryConvertValue(object value, Type propertyType, out object convertedValue) { var conversionResult = ConversionResultProvider.ConvertTo(value, propertyType); if (!conversionResult.CanBeConverted) { convertedValue = null; return(false); } convertedValue = conversionResult.ConvertedInstance; return(true); }
private bool TryConvertValue(object value, out TValue convertedValue, out string errorMessage) { var conversionResult = ConversionResultProvider.ConvertTo(value, typeof(TValue)); if (conversionResult.CanBeConverted) { errorMessage = null; convertedValue = (TValue)conversionResult.ConvertedInstance; return(true); } else { errorMessage = Resources.FormatInvalidValueForProperty(value); convertedValue = default(TValue); return(false); } }
private bool TryConvertKey(string key, out TKey convertedKey, out string errorMessage) { var conversionResult = ConversionResultProvider.ConvertTo(key, typeof(TKey)); if (conversionResult.CanBeConverted) { errorMessage = null; convertedKey = (TKey)conversionResult.ConvertedInstance; return(true); } else { errorMessage = Resources.FormatInvalidPathSegment(key); convertedKey = default(TKey); return(false); } }
private bool TryConvertValue( object originalValue, Type listTypeArgument, string segment, out object convertedValue, out string errorMessage) { var conversionResult = ConversionResultProvider.ConvertTo(originalValue, listTypeArgument); if (!conversionResult.CanBeConverted) { convertedValue = null; errorMessage = Resources.FormatInvalidValueForProperty(originalValue); return(false); } convertedValue = conversionResult.ConvertedInstance; errorMessage = null; return(true); }