Exemplo n.º 1
0
 public override object ConvertTo(
     ITypeDescriptorContext context,
     System.Globalization.CultureInfo culture,
     object Value,
     Type destinationType)
 {
     if (destinationType.Equals(typeof(InstanceDescriptor)))
     {
         ValueFormater format = (ValueFormater)Value;
         System.Reflection.ConstructorInfo ctor = null;
         if (format.Style == ValueFormatStyle.None && format.Format == null && format.NoneText == null)
         {
             ctor = typeof(ValueFormater).GetConstructor(new Type[] { });
             return(new InstanceDescriptor(ctor, new object[] { }, true));
         }
         else
         {
             ctor = typeof(ValueFormater).GetConstructor(
                 new Type[] { typeof(ValueFormatStyle), typeof(string), typeof(string) });
             return(new InstanceDescriptor(ctor, new object[] { format.Style, format.Format, format.NoneText }, true));
         }
         //InstanceDescriptor desc = new InstanceDescriptor(
     }
     return(base.ConvertTo(context, culture, Value, destinationType));
 }
Exemplo n.º 2
0
        public static ValueFormater ParseOldFormat(string format)
        {
            ValueFormater formater = new ValueFormater();

            if (format == null)
            {
                return(new ValueFormater());
            }
            int index = format.IndexOf(":");

            if (index > 0)
            {
                string strStyle = format.Substring(0, index).Trim();
                try
                {
                    formater.Style = ( ValueFormatStyle )Enum.Parse(typeof(ValueFormatStyle), strStyle);
                }
                finally{}
                if (formater.Style != ValueFormatStyle.None)
                {
                    formater.Format = format.Substring(index + 1).Trim();
                    if (formater.Format == "chinese")
                    {
                        formater.Format = "BigChinese";
                    }
                }
            }
            else
            {
                formater.Style = (ValueFormatStyle)Enum.Parse(typeof(ValueFormatStyle), format);
            }
            return(formater);
        }
Exemplo n.º 3
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object Value)
 {
     if (Value is string)
     {
         ValueFormater format = new ValueFormater();
         format.Parse((string)Value);
         return(format);
     }
     return(base.ConvertFrom(context, culture, Value));
 }
Exemplo n.º 4
0
        /// <summary>
        /// 复制对象
        /// </summary>
        /// <returns>复制品</returns>
        object System.ICloneable.Clone()
        {
            ValueFormater formater = (ValueFormater)this.MemberwiseClone();

            return(formater);
        }