Example #1
0
        public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (null == destinationType)
            {
                throw new ArgumentNullException("destinationType");
            }
            if (!(value is Thickness))
            {
                throw new ArgumentException(SR.Get("UnexpectedParameterType", new object[]
                {
                    value.GetType(),
                    typeof(Thickness)
                }), "value");
            }
            Thickness th = (Thickness)value;

            if (destinationType == typeof(string))
            {
                return(ThicknessConverter.ToString(th, cultureInfo));
            }
            if (destinationType == typeof(InstanceDescriptor))
            {
                ConstructorInfo constructor = typeof(Thickness).GetConstructor(new Type[]
                {
                    typeof(double),
                    typeof(double),
                    typeof(double),
                    typeof(double)
                });
                return(new InstanceDescriptor(constructor, new object[]
                {
                    th.Left,
                    th.Top,
                    th.Right,
                    th.Bottom
                }));
            }
            throw new ArgumentException(SR.Get("CannotConvertType", new object[]
            {
                typeof(Thickness),
                destinationType.FullName
            }));
        }
 // Token: 0x06000C40 RID: 3136 RVA: 0x0002D977 File Offset: 0x0002BB77
 internal string ToString(CultureInfo cultureInfo)
 {
     return(ThicknessConverter.ToString(this, cultureInfo));
 }
 /// <summary>Returns the string representation of the <see cref="T:System.Windows.Thickness" /> structure.</summary>
 /// <returns>A <see cref="T:System.String" /> that represents the <see cref="T:System.Windows.Thickness" /> value.</returns>
 // Token: 0x06000C3F RID: 3135 RVA: 0x0002D965 File Offset: 0x0002BB65
 public override string ToString()
 {
     return(ThicknessConverter.ToString(this, CultureInfo.InvariantCulture));
 }