using System; using System.Collections; using System.ComponentModel.Design; using System.Globalization; namespace System.ComponentModel { /// Provides a type converter to convert object references to and from other representations. // Token: 0x020000B9 RID: 185 public class ReferenceConverter : TypeConverter { /// Initializes a new instance of the class. /// A that represents the type to associate with this reference converter. // Token: 0x06000630 RID: 1584 RVA: 0x0000FD3C File Offset: 0x0000DF3C public ReferenceConverter(Type type) { this.reference_type = type; } /// Gets a value indicating whether this converter can convert an object in the given source type to a reference object using the specified context. /// true if this object can perform the conversion; otherwise, false. /// An that provides a format context. /// A that represents the type you wish to convert from. // Token: 0x06000631 RID: 1585 RVA: 0x0000FD4C File Offset: 0x0000DF4C public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return (context != null && sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType); } /// Converts the given object to the reference type. /// An that represents the converted . /// An that provides a format context. /// A that specifies the culture used to represent the font. /// The to convert. /// The conversion cannot be performed. // Token: 0x06000632 RID: 1586 RVA: 0x0000FD7C File Offset: 0x0000DF7C public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (!(value is string)) { return base.ConvertFrom(context, culture, value); } if (context != null) { object obj = null; global::System.ComponentModel.Design.IReferenceService referenceService = context.GetService(typeof(global::System.ComponentModel.Design.IReferenceService)) as global::System.ComponentModel.Design.IReferenceService; if (referenceService != null) { obj = referenceService.GetReference((string)value); } if (obj == null && context.Container != null && context.Container.Components != null) { obj = context.Container.Components[(string)value]; } return obj; } return null; } /// Converts the given value object to the reference type using the specified context and arguments. /// The converted object. /// An that provides a format context. /// A that specifies the culture used to represent the font. /// The to convert. /// The type to convert the object to. /// /// is null. /// The conversion cannot be performed. // Token: 0x06000633 RID: 1587 RVA: 0x0000FE0C File Offset: 0x0000E00C public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType != typeof(string)) { return base.ConvertTo(context, culture, value, destinationType); } if (value == null) { return "(none)"; } string text = string.Empty; if (context != null) { global::System.ComponentModel.Design.IReferenceService referenceService = context.GetService(typeof(global::System.ComponentModel.Design.IReferenceService)) as global::System.ComponentModel.Design.IReferenceService; if (referenceService != null) { text = referenceService.GetName(value); } if ((text == null || text.Length == 0) && value is IComponent) { IComponent component = (IComponent)value; if (component.Site != null && component.Site.Name != null) { text = component.Site.Name; } } } return text; } /// Gets a collection of standard values for the reference data type. /// 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. // Token: 0x06000634 RID: 1588 RVA: 0x0000FEC0 File Offset: 0x0000E0C0 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { ArrayList arrayList = new ArrayList(); if (context != null) { global::System.ComponentModel.Design.IReferenceService referenceService = context.GetService(typeof(global::System.ComponentModel.Design.IReferenceService)) as global::System.ComponentModel.Design.IReferenceService; if (referenceService != null) { foreach (object obj in referenceService.GetReferences(this.reference_type)) { if (this.IsValueAllowed(context, obj)) { arrayList.Add(obj); } } } else if (context.Container != null && context.Container.Components != null) { foreach (object obj2 in context.Container.Components) { if (obj2 != null && this.IsValueAllowed(context, obj2) && this.reference_type.IsInstanceOfType(obj2)) { arrayList.Add(obj2); } } } arrayList.Add(null); } return new TypeConverter.StandardValuesCollection(arrayList); } /// Gets a value indicating whether the list of standard values returned from is an exclusive list. /// true because the returned from is an exhaustive list of possible values. This method never returns false. /// An that provides a format context. // Token: 0x06000635 RID: 1589 RVA: 0x0000FFF8 File Offset: 0x0000E1F8 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } /// Gets a value indicating whether this object supports a standard set of values that can be picked from a list. /// true because can be called to find a common set of values the object supports. This method never returns false. /// An that provides a format context. // Token: 0x06000636 RID: 1590 RVA: 0x0000FFFC File Offset: 0x0000E1FC public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } /// Returns a value indicating whether a particular value can be added to the standard values collection. /// true if the value is allowed and can be added to the standard values collection; false if the value cannot be added to the standard values collection. /// An that provides an additional context. /// The value to check. // Token: 0x06000637 RID: 1591 RVA: 0x00010000 File Offset: 0x0000E200 protected virtual bool IsValueAllowed(ITypeDescriptorContext context, object value) { return true; } // Token: 0x040001CB RID: 459 private Type reference_type; } }