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); }
/// <summary>Converts the specified object to a <see cref="T:System.Windows.Controls.VirtualizationCacheLength" />.</summary> /// <param name="typeDescriptorContext">An object that provides a format context.</param> /// <param name="cultureInfo">An object that provides the culture information that is used during conversion.</param> /// <param name="source">The object to convert to a <see cref="T:System.Windows.Controls.VirtualizationCacheLength" />.</param> /// <returns>The converted object.</returns> /// <exception cref="T:System.NotSupportedException"> /// <paramref name="source" /> is <see langword="null" />.--or-- /// <paramref name="source" /> cannot be converted to a <see cref="T:System.Windows.Controls.VirtualizationCacheLength" />.</exception> // Token: 0x0600540C RID: 21516 RVA: 0x00174B18 File Offset: 0x00172D18 public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object source) { if (source == null) { throw base.GetConvertFromException(source); } if (source is string) { return(VirtualizationCacheLengthConverter.FromString((string)source, cultureInfo)); } double cacheBeforeAndAfterViewport = Convert.ToDouble(source, cultureInfo); return(new VirtualizationCacheLength(cacheBeforeAndAfterViewport)); }
/// <summary> /// Returns the string representation of this object. /// </summary> public override string ToString() { return(VirtualizationCacheLengthConverter.ToString(this, CultureInfo.InvariantCulture)); }