コード例 #1
0
        public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException(nameof(destinationType));
            }

            if (value is FlexLength == false)
            {
                throw GetConvertToExceptionInt(value, destinationType);
            }

            var flexLength = (FlexLength)value;

            if (destinationType == typeof(string))
            {
                return(FlexLengthConverter.ToString(flexLength, cultureInfo));
            }

            if (destinationType == typeof(InstanceDescriptor))
            {
                return(new InstanceDescriptor(typeof(FlexLength).GetConstructor(new[] { typeof(double), typeof(FlexLengthUnitType) }), new object[] { flexLength.Value, flexLength.UnitType }));
            }

            throw GetConvertToExceptionInt(value, destinationType);
        }
コード例 #2
0
ファイル: FlexLength.cs プロジェクト: Egaros/lib
 public override string ToString()
 {
     return(FlexLengthConverter.ToString(this, CultureInfo.InvariantCulture));
 }