C# Class System.ComponentModel.TypeDescriptor

Show file Open project: dotnet/corefx Class Usage Examples

Private Properties

Property Type Description
AddAttributes TypeDescriptionProvider
AddAttributes TypeDescriptionProvider
AddEditorTable void
AddProvider void
AddProvider void
AddProviderTransparent void
AddProviderTransparent void
CheckDefaultProvider void
CreateAssociation void
FilterMembers System.Collections.ArrayList
GetAssociation object
GetAttributes AttributeCollection
GetCache IDictionary
GetClassName string
GetComponentName string
GetConverter TypeConverter
GetDefaultEvent System.ComponentModel.EventDescriptor
GetDefaultProperty PropertyDescriptor
GetDescriptor ICustomTypeDescriptor
GetDescriptor ICustomTypeDescriptor
GetEditor object
GetEvents EventDescriptorCollection
GetEvents EventDescriptorCollection
GetExtendedDescriptor ICustomTypeDescriptor
GetExtenderCollisionSuffix string
GetNodeForBaseType System.Type
GetProperties PropertyDescriptorCollection
GetPropertiesImpl PropertyDescriptorCollection
GetProvider TypeDescriptionProvider
GetProvider TypeDescriptionProvider
GetProviderRecursive TypeDescriptionProvider
GetReflectionType System.Type
GetReflectionType System.Type
NodeFor TypeDescriptionNode
NodeFor TypeDescriptionNode
NodeFor TypeDescriptionNode
NodeFor TypeDescriptionNode
NodeRemove void
PipelineAttributeFilter ICollection
PipelineFilter ICollection
PipelineInitialize ICollection
PipelineMerge ICollection
RaiseRefresh void
RaiseRefresh void
Refresh void
RemoveAssociation void
RemoveAssociations void
RemoveProvider void
RemoveProvider void
RemoveProviderTransparent void
RemoveProviderTransparent void
ShouldHideMember bool
TypeDescriptor System.Collections

Public Methods

Method Description
CreateDesigner ( IComponent component, Type designerBaseType ) : IDesigner
CreateEvent ( Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor ) : System.ComponentModel.EventDescriptor

This creates a new event descriptor identical to an existing event descriptor. The new event descriptor has the specified metadata attributes merged with the existing metadata attributes.

CreateEvent ( Type componentType, string name, Type type ) : System.ComponentModel.EventDescriptor

This dynamically binds an EventDescriptor to a type.

CreateInstance ( IServiceProvider provider, Type objectType, Type argTypes, object args ) : object

This method will search internal tables within TypeDescriptor for a TypeDescriptionProvider object that is associated with the given data type. If it finds one, it will delegate the call to that object.

CreateProperty ( Type componentType, PropertyDescriptor oldPropertyDescriptor ) : PropertyDescriptor

This creates a new property descriptor identical to an existing property descriptor. The new property descriptor has the specified metadata attributes merged with the existing metadata attributes.

CreateProperty ( Type componentType, string name, Type type ) : PropertyDescriptor

This dynamically binds a PropertyDescriptor to a type.

GetAttributes ( Type componentType ) : AttributeCollection

Gets a collection of attributes for the specified type of component.

GetAttributes ( object component ) : AttributeCollection

Gets a collection of attributes for the specified component.

GetClassName ( Type componentType ) : string

Gets the name of the class for the specified type.

GetClassName ( object component ) : string

Gets the name of the class for the specified component.

GetComponentName ( object component ) : string

The name of the class for the specified component.

GetConverter ( Type type ) : TypeConverter

Gets a type converter for the specified type.

GetConverter ( object component ) : TypeConverter

Gets a type converter for the type of the specified component.

GetDefaultEvent ( Type componentType ) : System.ComponentModel.EventDescriptor

Gets the default event for the specified type of component.

GetDefaultEvent ( object component ) : System.ComponentModel.EventDescriptor

Gets the default event for the specified component.

GetDefaultProperty ( Type componentType ) : PropertyDescriptor

Gets the default property for the specified type of component.

GetDefaultProperty ( object component ) : PropertyDescriptor

Gets the default property for the specified component.

GetEditor ( Type type, Type editorBaseType ) : object

Gets an editor with the specified base type for the specified type.

GetEditor ( object component, Type editorBaseType ) : object

Gets an editor with the specified base type for the specified component.

GetEvents ( Type componentType ) : EventDescriptorCollection

Gets a collection of events for a specified type of component.

GetEvents ( Type componentType, Attribute attributes ) : EventDescriptorCollection

Gets a collection of events for a specified type of component using a specified array of attributes as a filter.

GetEvents ( object component ) : EventDescriptorCollection

Gets a collection of events for a specified component.

GetEvents ( object component, Attribute attributes ) : EventDescriptorCollection

Gets a collection of events for a specified component using a specified array of attributes as a filter.

GetFullComponentName ( object component ) : string

The name of the specified component, or null if the component has no name. In many cases this will return the same value as GetComponentName. If the component resides in a nested container or has other nested semantics, it may return a different fully qualfied name.

GetProperties ( Type componentType ) : PropertyDescriptorCollection

Gets a collection of properties for a specified type of component.

GetProperties ( Type componentType, Attribute attributes ) : PropertyDescriptorCollection

Gets a collection of properties for a specified type of component using a specified array of attributes as a filter.

GetProperties ( object component ) : PropertyDescriptorCollection

Gets a collection of properties for a specified component.

GetProperties ( object component, Attribute attributes ) : PropertyDescriptorCollection

Gets a collection of properties for a specified component using a specified array of attributes as a filter.

GetProperties ( object component, Attribute attributes, bool noCustomTypeDesc ) : PropertyDescriptorCollection

Gets a collection of properties for a specified component using a specified array of attributes as a filter.

Refresh ( Assembly assembly ) : void

Clears the properties and events for the specified assembly from the cache.

Refresh ( Module module ) : void

Clears the properties and events for the specified module from the cache.

Refresh ( Type type ) : void

Clears the properties and events for the specified type of component from the cache.

Refresh ( object component ) : void

Clears the properties and events for the specified component from the cache.

SortDescriptorArray ( IList infos ) : void

Sorts descriptors by name of the descriptor.

Private Methods

Method Description
AddAttributes ( Type type ) : TypeDescriptionProvider
AddAttributes ( object instance ) : TypeDescriptionProvider
AddEditorTable ( Type editorBaseType, Hashtable table ) : void
AddProvider ( TypeDescriptionProvider provider, Type type ) : void
AddProvider ( TypeDescriptionProvider provider, object instance ) : void
AddProviderTransparent ( TypeDescriptionProvider provider, Type type ) : void
AddProviderTransparent ( TypeDescriptionProvider provider, object instance ) : void
CheckDefaultProvider ( Type type ) : void

This method verifies that we have checked for the presence of a default type description provider attribute for the given type.

CreateAssociation ( object primary, object secondary ) : void
FilterMembers ( IList members, Attribute attributes ) : ArrayList

This API is used to remove any members from the given collection that do not match the attribute array. If members need to be removed, a new ArrayList wil be created that contains only the remaining members. The API returns NULL if it did not need to filter any members.

GetAssociation ( Type type, object primary ) : object
GetAttributes ( object component, bool noCustomTypeDesc ) : AttributeCollection
GetCache ( object instance ) : IDictionary

Helper function to obtain a cache for the given object.

GetClassName ( object component, bool noCustomTypeDesc ) : string
GetComponentName ( object component, bool noCustomTypeDesc ) : string
GetConverter ( object component, bool noCustomTypeDesc ) : TypeConverter
GetDefaultEvent ( object component, bool noCustomTypeDesc ) : System.ComponentModel.EventDescriptor
GetDefaultProperty ( object component, bool noCustomTypeDesc ) : PropertyDescriptor
GetDescriptor ( Type type, string typeName ) : ICustomTypeDescriptor

Returns a custom type descriptor for the given type. Performs arg checking so callers don't have to.

GetDescriptor ( object component, bool noCustomTypeDesc ) : ICustomTypeDescriptor

Returns a custom type descriptor for the given instance. Performs arg checking so callers don't have to. This will call through to instance if it is a custom type descriptor.

GetEditor ( object component, Type editorBaseType, bool noCustomTypeDesc ) : object
GetEvents ( object component, Attribute attributes, bool noCustomTypeDesc ) : EventDescriptorCollection
GetEvents ( object component, bool noCustomTypeDesc ) : EventDescriptorCollection
GetExtendedDescriptor ( object component ) : ICustomTypeDescriptor

Returns an extended custom type descriptor for the given instance.

GetExtenderCollisionSuffix ( MemberDescriptor member ) : string

This method is invoked during filtering when a name collision is encountered between two properties or events. This returns a suffix that can be appended to the name to make it unique. This will first attempt ot use the name of the extender. Failing that it will fall back to a static index that is continually incremented.

GetNodeForBaseType ( Type searchType ) : Type
GetProperties ( object component, bool noCustomTypeDesc ) : PropertyDescriptorCollection
GetPropertiesImpl ( object component, Attribute attributes, bool noCustomTypeDesc, bool noAttributes ) : PropertyDescriptorCollection

Gets a collection of properties for a specified component. Uses the attribute filter only if noAttributes is false. This is to preserve backward compat for the case when no attribute filter was passed in (as against passing in null).

GetProvider ( Type type ) : TypeDescriptionProvider
GetProvider ( object instance ) : TypeDescriptionProvider
GetProviderRecursive ( Type type ) : TypeDescriptionProvider

This method returns a type description provider, but instead of creating a delegating provider for the type, this will walk all base types until it locates a provider. The provider returned cannot be cached. This method is used by the DelegatingTypeDescriptionProvider to efficiently locate the provider to delegate to.

GetReflectionType ( Type type ) : Type
GetReflectionType ( object instance ) : Type
NodeFor ( Type type ) : TypeDescriptionNode

Retrieves the head type description node for a type. A head node pointing to a reflection based type description provider will be created on demand. This does not create a delegator, in which case the node returned may be a base type node.

NodeFor ( Type type, bool createDelegator ) : TypeDescriptionNode

Retrieves the head type description node for a type. A head node pointing to a reflection based type description provider will be created on demand. If createDelegator is true, this method will create a delegation node for a type if the type has no node of its own. Delegation nodes should be created if you are going to hand this node out to a user. Without a delegation node, user code could skip providers that are added after their call. Delegation nodes solve that problem. If createDelegator is false, this method will recurse up the base type chain looking for nodes.

NodeFor ( object instance ) : TypeDescriptionNode

Retrieves the head type description node for an instance. Instance-based node lists are rare. If a node list is not available for a given instance, this will return the head node for the instance's type.

NodeFor ( object instance, bool createDelegator ) : TypeDescriptionNode

Retrieves the head type description node for an instance. Instance-based node lists are rare. If a node list is not available for a given instance, this will return the head node for the instance's type. This variation offers a bool called createDelegator. If true and there is no node list for this instance, NodeFor will create a temporary "delegator node" that, when queried, will delegate to the type stored in the instance. This is done on demand, which means if someone else added a type description provider for the instance's type the delegator would pick up the new type. If a query is being made that does not involve publicly exposing the type description provider for the instance, the query should pass in fase (the default) for createDelegator because no object will be created.

NodeRemove ( object key, TypeDescriptionProvider provider ) : void

Simple linked list code to remove an element from the list. Returns the new head to the list. If the head points to an instance of DelegatingTypeDescriptionProvider, we clear the node because all it is doing is delegating elsewhere. Note that this behaves a little differently from normal linked list code. In a normal linked list, you remove then target node and fixup the links. In this linked list, we remove the node AFTER the target node, fixup the links, and fixup the underlying providers that each node references. The reason for this is that most providers keep a reference to the previous provider, which is exposed as one of these nodes. Therefore, to remove a provider the node following is most likely referenced by that provider

PipelineAttributeFilter ( int pipelineType, ICollection members, Attribute filter, object instance, IDictionary cache ) : ICollection

This is the last stage in our filtering pipeline. Here, we apply any user-defined filter.

PipelineFilter ( int pipelineType, ICollection members, object instance, IDictionary cache ) : ICollection

Metdata filtering is the third stage of our pipeline. In this stage we check to see if the given object is a sited component that provides the ITypeDescriptorFilterService object. If it does, we allow the TDS to filter the metadata. This will use the cache, if available, to store filtered metdata.

PipelineInitialize ( int pipelineType, ICollection members, IDictionary cache ) : ICollection

This is the first stage in the pipeline. This checks the incoming member collection and if it differs from what we have seen in the past, it invalidates all successive pipelines.

PipelineMerge ( int pipelineType, ICollection primary, ICollection secondary, object instance, IDictionary cache ) : ICollection

Metadata merging is the second stage of our metadata pipeline. This stage merges extended metdata with primary metadata, and stores it in the cache if it is available.

RaiseRefresh ( Type type ) : void
RaiseRefresh ( object component ) : void
Refresh ( object component, bool refreshReflectionProvider ) : void
RemoveAssociation ( object primary, object secondary ) : void
RemoveAssociations ( object primary ) : void
RemoveProvider ( TypeDescriptionProvider provider, Type type ) : void
RemoveProvider ( TypeDescriptionProvider provider, object instance ) : void
RemoveProviderTransparent ( TypeDescriptionProvider provider, Type type ) : void
RemoveProviderTransparent ( TypeDescriptionProvider provider, object instance ) : void
ShouldHideMember ( MemberDescriptor member, Attribute attribute ) : bool

This function takes a member descriptor and an attribute and determines whether the member satisfies the particular attribute. This either means that the member contains the attribute or the member does not contain the attribute and the default for the attribute matches the passed in attribute.

TypeDescriptor ( ) : System.Collections

Method Details

CreateDesigner() public static method

public static CreateDesigner ( IComponent component, Type designerBaseType ) : IDesigner
component IComponent
designerBaseType System.Type
return IDesigner

CreateEvent() public static method

This creates a new event descriptor identical to an existing event descriptor. The new event descriptor has the specified metadata attributes merged with the existing metadata attributes.
public static CreateEvent ( Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor ) : System.ComponentModel.EventDescriptor
componentType System.Type
oldEventDescriptor System.ComponentModel.EventDescriptor
return System.ComponentModel.EventDescriptor

CreateEvent() public static method

This dynamically binds an EventDescriptor to a type.
public static CreateEvent ( Type componentType, string name, Type type ) : System.ComponentModel.EventDescriptor
componentType System.Type
name string
type System.Type
return System.ComponentModel.EventDescriptor

CreateInstance() public static method

This method will search internal tables within TypeDescriptor for a TypeDescriptionProvider object that is associated with the given data type. If it finds one, it will delegate the call to that object.
public static CreateInstance ( IServiceProvider provider, Type objectType, Type argTypes, object args ) : object
provider IServiceProvider
objectType System.Type
argTypes System.Type
args object
return object

CreateProperty() public static method

This creates a new property descriptor identical to an existing property descriptor. The new property descriptor has the specified metadata attributes merged with the existing metadata attributes.
public static CreateProperty ( Type componentType, PropertyDescriptor oldPropertyDescriptor ) : PropertyDescriptor
componentType System.Type
oldPropertyDescriptor PropertyDescriptor
return PropertyDescriptor

CreateProperty() public static method

This dynamically binds a PropertyDescriptor to a type.
public static CreateProperty ( Type componentType, string name, Type type ) : PropertyDescriptor
componentType System.Type
name string
type System.Type
return PropertyDescriptor

GetAttributes() public static method

Gets a collection of attributes for the specified type of component.
public static GetAttributes ( Type componentType ) : AttributeCollection
componentType System.Type
return AttributeCollection

GetAttributes() public static method

Gets a collection of attributes for the specified component.
public static GetAttributes ( object component ) : AttributeCollection
component object
return AttributeCollection

GetClassName() public static method

Gets the name of the class for the specified type.
public static GetClassName ( Type componentType ) : string
componentType System.Type
return string

GetClassName() public static method

Gets the name of the class for the specified component.
public static GetClassName ( object component ) : string
component object
return string

GetComponentName() public static method

The name of the class for the specified component.
public static GetComponentName ( object component ) : string
component object
return string

GetConverter() public static method

Gets a type converter for the specified type.
public static GetConverter ( Type type ) : TypeConverter
type System.Type
return TypeConverter

GetConverter() public static method

Gets a type converter for the type of the specified component.
public static GetConverter ( object component ) : TypeConverter
component object
return TypeConverter

GetDefaultEvent() public static method

Gets the default event for the specified type of component.
public static GetDefaultEvent ( Type componentType ) : System.ComponentModel.EventDescriptor
componentType System.Type
return System.ComponentModel.EventDescriptor

GetDefaultEvent() public static method

Gets the default event for the specified component.
public static GetDefaultEvent ( object component ) : System.ComponentModel.EventDescriptor
component object
return System.ComponentModel.EventDescriptor

GetDefaultProperty() public static method

Gets the default property for the specified type of component.
public static GetDefaultProperty ( Type componentType ) : PropertyDescriptor
componentType System.Type
return PropertyDescriptor

GetDefaultProperty() public static method

Gets the default property for the specified component.
public static GetDefaultProperty ( object component ) : PropertyDescriptor
component object
return PropertyDescriptor

GetEditor() public static method

Gets an editor with the specified base type for the specified type.
public static GetEditor ( Type type, Type editorBaseType ) : object
type System.Type
editorBaseType System.Type
return object

GetEditor() public static method

Gets an editor with the specified base type for the specified component.
public static GetEditor ( object component, Type editorBaseType ) : object
component object
editorBaseType System.Type
return object

GetEvents() public static method

Gets a collection of events for a specified type of component.
public static GetEvents ( Type componentType ) : EventDescriptorCollection
componentType System.Type
return EventDescriptorCollection

GetEvents() public static method

Gets a collection of events for a specified type of component using a specified array of attributes as a filter.
public static GetEvents ( Type componentType, Attribute attributes ) : EventDescriptorCollection
componentType System.Type
attributes System.Attribute
return EventDescriptorCollection

GetEvents() public static method

Gets a collection of events for a specified component.
public static GetEvents ( object component ) : EventDescriptorCollection
component object
return EventDescriptorCollection

GetEvents() public static method

Gets a collection of events for a specified component using a specified array of attributes as a filter.
public static GetEvents ( object component, Attribute attributes ) : EventDescriptorCollection
component object
attributes System.Attribute
return EventDescriptorCollection

GetFullComponentName() public static method

The name of the specified component, or null if the component has no name. In many cases this will return the same value as GetComponentName. If the component resides in a nested container or has other nested semantics, it may return a different fully qualfied name.
public static GetFullComponentName ( object component ) : string
component object
return string

GetProperties() public static method

Gets a collection of properties for a specified type of component.
public static GetProperties ( Type componentType ) : PropertyDescriptorCollection
componentType System.Type
return PropertyDescriptorCollection

GetProperties() public static method

Gets a collection of properties for a specified type of component using a specified array of attributes as a filter.
public static GetProperties ( Type componentType, Attribute attributes ) : PropertyDescriptorCollection
componentType System.Type
attributes System.Attribute
return PropertyDescriptorCollection

GetProperties() public static method

Gets a collection of properties for a specified component.
public static GetProperties ( object component ) : PropertyDescriptorCollection
component object
return PropertyDescriptorCollection

GetProperties() public static method

Gets a collection of properties for a specified component using a specified array of attributes as a filter.
public static GetProperties ( object component, Attribute attributes ) : PropertyDescriptorCollection
component object
attributes System.Attribute
return PropertyDescriptorCollection

GetProperties() public static method

Gets a collection of properties for a specified component using a specified array of attributes as a filter.

public static GetProperties ( object component, Attribute attributes, bool noCustomTypeDesc ) : PropertyDescriptorCollection
component object
attributes System.Attribute
noCustomTypeDesc bool
return PropertyDescriptorCollection

Refresh() public static method

Clears the properties and events for the specified assembly from the cache.
public static Refresh ( Assembly assembly ) : void
assembly System.Reflection.Assembly
return void

Refresh() public static method

Clears the properties and events for the specified module from the cache.
public static Refresh ( Module module ) : void
module System.Reflection.Module
return void

Refresh() public static method

Clears the properties and events for the specified type of component from the cache.
public static Refresh ( Type type ) : void
type System.Type
return void

Refresh() public static method

Clears the properties and events for the specified component from the cache.
public static Refresh ( object component ) : void
component object
return void

SortDescriptorArray() public static method

Sorts descriptors by name of the descriptor.
public static SortDescriptorArray ( IList infos ) : void
infos IList
return void