152 lines
5.6 KiB
C#
152 lines
5.6 KiB
C#
using System;
|
|
using System.Globalization;
|
|
|
|
namespace System.ComponentModel
|
|
{
|
|
/// <summary>Provides a type converter to convert <see cref="T:System.Array" /> objects to and from various other representations.</summary>
|
|
// Token: 0x02000052 RID: 82
|
|
public class ArrayConverter : CollectionConverter
|
|
{
|
|
/// <summary>Converts the given value object to the specified destination type.</summary>
|
|
/// <returns>An <see cref="T:System.Object" /> that represents the converted value.</returns>
|
|
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param>
|
|
/// <param name="culture">The culture into which <paramref name="value" /> will be converted.</param>
|
|
/// <param name="value">The <see cref="T:System.Object" /> to convert. </param>
|
|
/// <param name="destinationType">The <see cref="T:System.Type" /> to convert the value to. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="destinationType" /> is null. </exception>
|
|
/// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
|
|
// 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);
|
|
}
|
|
|
|
/// <summary>Gets a collection of properties for the type of array specified by the value parameter.</summary>
|
|
/// <returns>A <see cref="T:System.ComponentModel.PropertyDescriptorCollection" /> with the properties that are exposed for an array, or null if there are no properties.</returns>
|
|
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param>
|
|
/// <param name="value">An <see cref="T:System.Object" /> that specifies the type of array to get the properties for. </param>
|
|
/// <param name="attributes">An array of type <see cref="T:System.Attribute" /> that will be used as a filter. </param>
|
|
// 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;
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether this object supports properties.</summary>
|
|
/// <returns>true because <see cref="M:System.ComponentModel.ArrayConverter.GetProperties(System.ComponentModel.ITypeDescriptorContext,System.Object,System.Attribute[])" /> should be called to find the properties of this object. This method never returns false.</returns>
|
|
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param>
|
|
// 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;
|
|
}
|
|
}
|
|
}
|