using System; using System.Collections; using System.Globalization; namespace System.ComponentModel { /// Provides automatic conversion between a nullable type and its underlying primitive type. // Token: 0x020000B1 RID: 177 public class NullableConverter : TypeConverter { /// Initializes a new instance of the class. /// The specified nullable type. /// /// is not a nullable type. // Token: 0x060005B6 RID: 1462 RVA: 0x0000EC38 File Offset: 0x0000CE38 public NullableConverter(Type nullableType) { if (nullableType == null) { throw new ArgumentNullException("nullableType"); } this.nullableType = nullableType; this.underlyingType = Nullable.GetUnderlyingType(nullableType); this.underlyingTypeConverter = TypeDescriptor.GetConverter(this.underlyingType); } /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context. /// true if this converter can perform the conversion; otherwise, false. /// An that provides a format context. /// A that represents the type you want to convert from. // Token: 0x060005B7 RID: 1463 RVA: 0x0000EC78 File Offset: 0x0000CE78 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == this.underlyingType) { return true; } if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.CanConvertFrom(context, sourceType); } return base.CanConvertFrom(context, sourceType); } /// Returns whether this converter can convert the object to the specified type, using the specified context. /// true if this converter can perform the conversion; otherwise, false. /// An that provides a format context. /// A that represents the type you want to convert to. // Token: 0x060005B8 RID: 1464 RVA: 0x0000ECAC File Offset: 0x0000CEAC public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == this.underlyingType) { return true; } if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.CanConvertTo(context, destinationType); } return base.CanConvertFrom(context, destinationType); } /// Converts the given object to the type of this converter, using the specified context and culture information. /// An that represents the converted value. /// An that provides a format context. /// The to use as the current culture. /// The to convert. /// The conversion cannot be performed. // Token: 0x060005B9 RID: 1465 RVA: 0x0000ECE0 File Offset: 0x0000CEE0 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null || value.GetType() == this.underlyingType) { return value; } if (value is string && string.IsNullOrEmpty((string)value)) { return null; } if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.ConvertFrom(context, culture, value); } return base.ConvertFrom(context, culture, value); } /// Converts the given value object to the specified type, using the specified context and culture information. /// An that represents the converted value. /// An that provides a format context. /// The to use as the current culture. /// The to convert. /// The to convert the value parameter to. /// /// is null. /// The conversion cannot be performed. // Token: 0x060005BA RID: 1466 RVA: 0x0000ED48 File Offset: 0x0000CF48 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == this.underlyingType && value.GetType() == this.nullableType) { return value; } if (this.underlyingTypeConverter != null && value != null) { return this.underlyingTypeConverter.ConvertTo(context, culture, value, destinationType); } return base.ConvertTo(context, culture, value, destinationType); } /// An representing the given , or null if the object cannot be created. This method always returns null. /// An that provides a format context. /// An of new property values. // Token: 0x060005BB RID: 1467 RVA: 0x0000EDB4 File Offset: 0x0000CFB4 public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.CreateInstance(context, propertyValues); } return base.CreateInstance(context, propertyValues); } /// true if changing a property on this object requires a call to to create a new value; otherwise, false. /// An that provides a format context. // Token: 0x060005BC RID: 1468 RVA: 0x0000EDD8 File Offset: 0x0000CFD8 public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.GetCreateInstanceSupported(context); } return base.GetCreateInstanceSupported(context); } /// A with the properties that are exposed for this data type, or null if there are no properties. /// An that provides a format context. /// An that specifies the type of array for which to get properties. /// An array of type that is used as a filter. // Token: 0x060005BD RID: 1469 RVA: 0x0000EDFC File Offset: 0x0000CFFC public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.GetProperties(context, value, attributes); } return base.GetProperties(context, value, attributes); } /// true if should be called to find the properties of this object; otherwise, false. /// An that provides a format context. // Token: 0x060005BE RID: 1470 RVA: 0x0000EE24 File Offset: 0x0000D024 public override bool GetPropertiesSupported(ITypeDescriptorContext context) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.GetCreateInstanceSupported(context); } return base.GetCreateInstanceSupported(context); } /// A that holds a standard set of valid values, or null if the data type does not support a standard set of values. /// An that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null. // Token: 0x060005BF RID: 1471 RVA: 0x0000EE48 File Offset: 0x0000D048 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (this.underlyingTypeConverter != null && this.underlyingTypeConverter.GetStandardValuesSupported(context)) { TypeConverter.StandardValuesCollection standardValues = this.underlyingTypeConverter.GetStandardValues(context); if (standardValues != null) { return new TypeConverter.StandardValuesCollection(new ArrayList(standardValues) { null }); } } return base.GetStandardValues(context); } /// true if the returned from is an exhaustive list of possible values; false if other values are possible. /// An that provides a format context. // Token: 0x060005C0 RID: 1472 RVA: 0x0000EEA4 File Offset: 0x0000D0A4 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.GetStandardValuesExclusive(context); } return base.GetStandardValuesExclusive(context); } /// true if should be called to find a common set of values the object supports; otherwise, false. /// An that provides a format context. // Token: 0x060005C1 RID: 1473 RVA: 0x0000EEC8 File Offset: 0x0000D0C8 public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.GetStandardValuesSupported(context); } return base.GetStandardValuesSupported(context); } /// An that provides a format context. /// The to test for validity. // Token: 0x060005C2 RID: 1474 RVA: 0x0000EEEC File Offset: 0x0000D0EC public override bool IsValid(ITypeDescriptorContext context, object value) { if (this.underlyingTypeConverter != null) { return this.underlyingTypeConverter.IsValid(context, value); } return base.IsValid(context, value); } /// Gets the nullable type. /// A that represents the nullable type. // Token: 0x1700017F RID: 383 // (get) Token: 0x060005C3 RID: 1475 RVA: 0x0000EF10 File Offset: 0x0000D110 public Type NullableType { get { return this.nullableType; } } /// Gets the underlying type. /// A that represents the underlying type. // Token: 0x17000180 RID: 384 // (get) Token: 0x060005C4 RID: 1476 RVA: 0x0000EF18 File Offset: 0x0000D118 public Type UnderlyingType { get { return this.underlyingType; } } /// Gets the underlying type converter. /// A that represents the underlying type converter. // Token: 0x17000181 RID: 385 // (get) Token: 0x060005C5 RID: 1477 RVA: 0x0000EF20 File Offset: 0x0000D120 public TypeConverter UnderlyingTypeConverter { get { return this.underlyingTypeConverter; } } // Token: 0x040001B4 RID: 436 private Type nullableType; // Token: 0x040001B5 RID: 437 private Type underlyingType; // Token: 0x040001B6 RID: 438 private TypeConverter underlyingTypeConverter; } }