using System; using System.Globalization; namespace System.ComponentModel { /// Provides a type converter to convert objects to and from various other representations. // Token: 0x02000052 RID: 82 public class ArrayConverter : CollectionConverter { /// Converts the given value object to the specified destination type. /// An that represents the converted value. /// An that provides a format context. /// The culture into which will be converted. /// The to convert. /// The to convert the value to. /// /// is null. /// The conversion cannot be performed. // Token: 0x06000337 RID: 823 RVA: 0x0000A140 File Offset: 0x00008340 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value is Array) { return value.GetType().Name + " Array"; } return base.ConvertTo(context, culture, value, destinationType); } /// Gets a collection of properties for the type of array specified by the value parameter. /// A with the properties that are exposed for an array, or null if there are no properties. /// An that provides a format context. /// An that specifies the type of array to get the properties for. /// An array of type that will be used as a filter. // Token: 0x06000338 RID: 824 RVA: 0x0000A19C File Offset: 0x0000839C public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (value == null) { throw new NullReferenceException(); } PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); if (value is Array) { Array array = (Array)value; for (int i = 0; i < array.Length; i++) { propertyDescriptorCollection.Add(new ArrayConverter.ArrayPropertyDescriptor(i, array.GetType())); } } return propertyDescriptorCollection; } /// Gets a value indicating whether this object supports properties. /// true because should be called to find the properties of this object. This method never returns false. /// An that provides a format context. // Token: 0x06000339 RID: 825 RVA: 0x0000A1FC File Offset: 0x000083FC public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } // Token: 0x02000053 RID: 83 internal class ArrayPropertyDescriptor : PropertyDescriptor { // Token: 0x0600033A RID: 826 RVA: 0x0000A200 File Offset: 0x00008400 public ArrayPropertyDescriptor(int index, Type array_type) : base(string.Format("[{0}]", index), null) { this.index = index; this.array_type = array_type; } // Token: 0x170000E0 RID: 224 // (get) Token: 0x0600033B RID: 827 RVA: 0x0000A228 File Offset: 0x00008428 public override Type ComponentType { get { return this.array_type; } } // Token: 0x170000E1 RID: 225 // (get) Token: 0x0600033C RID: 828 RVA: 0x0000A230 File Offset: 0x00008430 public override Type PropertyType { get { return this.array_type.GetElementType(); } } // Token: 0x170000E2 RID: 226 // (get) Token: 0x0600033D RID: 829 RVA: 0x0000A240 File Offset: 0x00008440 public override bool IsReadOnly { get { return false; } } // Token: 0x0600033E RID: 830 RVA: 0x0000A244 File Offset: 0x00008444 public override object GetValue(object component) { if (component == null) { return null; } return ((Array)component).GetValue(this.index); } // Token: 0x0600033F RID: 831 RVA: 0x0000A260 File Offset: 0x00008460 public override void SetValue(object component, object value) { if (component == null) { return; } ((Array)component).SetValue(value, this.index); } // Token: 0x06000340 RID: 832 RVA: 0x0000A27C File Offset: 0x0000847C public override void ResetValue(object component) { } // Token: 0x06000341 RID: 833 RVA: 0x0000A280 File Offset: 0x00008480 public override bool CanResetValue(object component) { return false; } // Token: 0x06000342 RID: 834 RVA: 0x0000A284 File Offset: 0x00008484 public override bool ShouldSerializeValue(object component) { return false; } // Token: 0x04000110 RID: 272 private int index; // Token: 0x04000111 RID: 273 private Type array_type; } } }