コード例 #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 CornerRadius))
            {
                throw new ArgumentException(SR.Get("UnexpectedParameterType", new object[]
                {
                    value.GetType(),
                    typeof(CornerRadius)
                }), "value");
            }
            CornerRadius cr = (CornerRadius)value;

            if (destinationType == typeof(string))
            {
                return(CornerRadiusConverter.ToString(cr, cultureInfo));
            }
            if (destinationType == typeof(InstanceDescriptor))
            {
                ConstructorInfo constructor = typeof(CornerRadius).GetConstructor(new Type[]
                {
                    typeof(double),
                    typeof(double),
                    typeof(double),
                    typeof(double)
                });
                return(new InstanceDescriptor(constructor, new object[]
                {
                    cr.TopLeft,
                    cr.TopRight,
                    cr.BottomRight,
                    cr.BottomLeft
                }));
            }
            throw new ArgumentException(SR.Get("CannotConvertType", new object[]
            {
                typeof(CornerRadius),
                destinationType.FullName
            }));
        }
コード例 #2
0
 /// <summary>Returns the string representation of the <see cref="T:System.Windows.CornerRadius" />. </summary>
 /// <returns>A string representation of the <see cref="T:System.Windows.CornerRadius" />.</returns>
 // Token: 0x0600036F RID: 879 RVA: 0x00009C99 File Offset: 0x00007E99
 public override string ToString()
 {
     return(CornerRadiusConverter.ToString(this, CultureInfo.InvariantCulture));
 }