Exemplo n.º 1
0
 /// <summary>Attempts to convert an <see cref="T:System.Windows.Int32Rect" /> to a specified type.</summary>
 /// <returns>The object created from converting this <see cref="T:System.Windows.Int32Rect" />.</returns>
 /// <param name="context">Provides contextual information required for conversion.</param>
 /// <param name="culture">Cultural information to respect during conversion.</param>
 /// <param name="value">The <see cref="T:System.Windows.Int32Rect" /> to convert.</param>
 /// <param name="destinationType">The type to convert this <see cref="T:System.Windows.Int32Rect" /> to.</param>
 /// <exception cref="T:System.NotSupportedException">Thrown if <paramref name="value" /> is null or is not an <see cref="T:System.Windows.Int32Rect" />, or if the <paramref name="destinationType" /> is not one of the valid types for conversion.</exception>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType != null && value is Int32Rect)
     {
         Int32Rect int32Rect = (Int32Rect)value;
         if (destinationType == typeof(string))
         {
             return(int32Rect.ConvertToString(null, culture));
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Converts the value into a string.
        /// </summary>
        public override string ConvertToString(object value, IValueSerializerContext context)
        {
            if (value is Int32Rect)
            {
                Int32Rect instance = (Int32Rect)value;


                #pragma warning suppress 6506 // instance is obviously not null
                return(instance.ConvertToString(null, System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS));
            }

            return(base.ConvertToString(value, context));
        }