public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if (value != null && value is VirtualizationCacheLength)
     {
         VirtualizationCacheLength cacheLength = (VirtualizationCacheLength)value;
         if (destinationType == typeof(string))
         {
             return(VirtualizationCacheLengthConverter.ToString(cacheLength, cultureInfo));
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             ConstructorInfo constructor = typeof(VirtualizationCacheLength).GetConstructor(new Type[]
             {
                 typeof(double),
                 typeof(VirtualizationCacheLengthUnit)
             });
             return(new InstanceDescriptor(constructor, new object[]
             {
                 cacheLength.CacheBeforeViewport,
                 cacheLength.CacheAfterViewport
             }));
         }
     }
     throw base.GetConvertToException(value, destinationType);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the string representation of this object.
 /// </summary>
 public override string ToString()
 {
     return(VirtualizationCacheLengthConverter.ToString(this, CultureInfo.InvariantCulture));
 }