SilverlightMappingToolBasic.XamlStringConverter.ConvertFrom C# (CSharp) Method

ConvertFrom() public method

public ConvertFrom ( ITypeDescriptorContext context, CultureInfo culture, object value ) : object
context ITypeDescriptorContext
culture System.Globalization.CultureInfo
value object
return object
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var strValue = value as string;
            if (strValue != null)
            {
                if (this._type == typeof(bool))
                {
                    return bool.Parse(strValue);
                }
                if (this._type.IsEnum)
                {
                    return Enum.Parse(this._type, strValue, false);
                }
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("<ContentControl xmlns='http://schemas.microsoft.com/client/2007' xmlns:c='" + ("clr-namespace:" + this._type.Namespace + ";assembly=" + this._type.Assembly.FullName.Split(new char[] { ',' })[0]) + "'>\n");
                stringBuilder.Append("<c:" + this._type.Name + ">\n");
                stringBuilder.Append(strValue);
                stringBuilder.Append("</c:" + this._type.Name + ">\n");
                stringBuilder.Append("</ContentControl>");
                ContentControl instance = XamlReader.Load(stringBuilder.ToString()) as ContentControl;
                if (instance != null)
                {
                    return instance.Content;
                }
            }
            return base.ConvertFrom(context, culture, value);
        }
    }