GetCustomTypeConverter() public static method

public static GetCustomTypeConverter ( Type propertyType ) : TypeConverter
propertyType System.Type
return TypeConverter
Exemplo n.º 1
0
        internal static object CreateObjectFromAttributeText(string valueText, Type targetType, XamlObject scope)
        {
            var converter =
                XamlNormalPropertyInfo.GetCustomTypeConverter(targetType) ??
                TypeDescriptor.GetConverter(targetType);

            return(converter.ConvertFromInvariantString(
                       scope.OwnerDocument.GetTypeDescriptorContext(scope), valueText));
        }
Exemplo n.º 2
0
        internal static object CreateObjectFromAttributeText(string valueText, Type targetType, XamlObject scope)
        {
            try {
                var converter =
                    XamlNormalPropertyInfo.GetCustomTypeConverter(targetType) ??
                    TypeDescriptor.GetConverter(targetType);

                return(converter.ConvertFromInvariantString(
                           scope.OwnerDocument.GetTypeDescriptorContext(scope), valueText));
            }
            catch (Exception e) {
                IXamlErrorSink sink = (IXamlErrorSink)scope.OwnerDocument.ServiceProvider.GetService(typeof(IXamlErrorSink));
                if (sink != null)
                {
                    sink.ReportError(e.Message, 0, 0);
                }
            }
            return(null);
        }