C# Class WebApplications.Utilities.Reflect.ExtendedType

Afficher le fichier Open project: webappsuk/CoreLibraries Class Usage Examples

Private Properties

Свойство Type Description
Get ExtendedType
Get ExtendedType
GetCastFromMethod CastMethod
GetCastToMethod CastMethod
LoadMembers void

Méthodes publiques

Méthode Description
CanConvertTo ( Type type ) : bool

Determines whether this instance can be converted to the specified type. Unlike the built in cast system, this returns true if a cast is possible AND if IConvertible can be used.

CloseType ( ) : ExtendedType

Closes the type if it is generic and has generic parameters, or creates equivalent type.

DescendsFrom ( [ baseType ) : bool

Checks to see if a type descends from another type.

ExtendedType ( [ type ) : System

Initializes a new instance of the ExtendedType class.

FindType ( [ typeName, bool throwOnError = false, bool ignoreCase = false ) : Type

Finds the type with the specified typeName.

This is more robust than using Type.GetType(string,bool,bool) as it supports partial assembly names.

GetConstructor ( ) : Constructor

Gets the constructor.

GetConstructor ( [ constructorInfo, bool includeBase = true ) : Constructor

Gets the Constructor matching the ConstructorInfo (if any).

GetConstructor ( bool includeBase ) : Constructor

Gets the constructor.

GetConstructor ( bool &castsRequired, bool includeBase ) : Constructor

Gets the constructor.

GetEvent ( [ name, bool includeBase = true ) : Event

Gets the event.

GetField ( [ name, bool includeBase = true ) : Field

Gets the field.

GetIndexer ( ) : Indexer

Gets the indexer from the type (or base types).

GetIndexer ( [ propertyInfo, bool includeBase = true ) : Indexer

Gets the Indexer matching the PropertyInfo (if any).

GetIndexer ( bool &castsRequired ) : Indexer

Gets the indexer from the type (or base types).

GetIndexer ( bool includeBase, bool &castsRequired ) : Indexer

Gets the indexer.

GetMethod ( [ name ) : Method

Gets the method.

GetMethod ( [ methodInfo, bool includeBase = true ) : Method

Gets the Method matching the MethodInfo (if any).

GetMethod ( [ name, int genericArguments ) : Method

Gets the method.

GetMethod ( [ name, int genericArguments, bool includeBase ) : Method

Gets the method.

GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts ) : Method

Gets the method.

GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts, bool includeBase ) : Method

Gets the method.

GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts, bool &castsRequired, bool includeBase ) : Method

Gets the method.

GetMethods ( [ name, bool includeBase = true ) : IEnumerable

Gets the methods.

GetProperty ( [ name, bool includeBase = true ) : System.Property

Gets the property.

Implements ( [ interfaceType ) : bool

Checks to see if this type implements a particular interface.

ImplementsCastFrom ( [ fromType, bool implicitOnly = true ) : bool

Whether this type implements a cast from the specified type.

ImplementsCastTo ( [ toType, bool implicitOnly = true ) : bool

Whether this type implements a cast to the specified type.

TryConvert ( [ expression, [ outputExpression ) : bool

Converts the specified expression to the output type.

This version is more powerful than the Expression.Convert CLR method in that it supports ToString() conversion, IConvertible and TypeConverters. It also prevents exceptions being thrown.

Private Methods

Méthode Description
Get ( [ type ) : ExtendedType
Get ( [ typeName, bool ignoreCase = false ) : ExtendedType
GetCastFromMethod ( [ fromType ) : CastMethod
GetCastToMethod ( [ toType ) : CastMethod
LoadMembers ( ) : void

Loads all the members in one go.

Method Details

CanConvertTo() public méthode

Determines whether this instance can be converted to the specified type. Unlike the built in cast system, this returns true if a cast is possible AND if IConvertible can be used.
public CanConvertTo ( Type type ) : bool
type System.Type The type.
Résultat bool

CloseType() public méthode

Closes the type if it is generic and has generic parameters, or creates equivalent type.
public CloseType ( ) : ExtendedType
Résultat ExtendedType

DescendsFrom() public méthode

Checks to see if a type descends from another type.
public DescendsFrom ( [ baseType ) : bool
baseType [ Type of the base.
Résultat bool

ExtendedType() public méthode

Initializes a new instance of the ExtendedType class.
public ExtendedType ( [ type ) : System
type [ The type.
Résultat System

FindType() public static méthode

Finds the type with the specified typeName.
This is more robust than using Type.GetType(string,bool,bool) as it supports partial assembly names.
public static FindType ( [ typeName, bool throwOnError = false, bool ignoreCase = false ) : Type
typeName [ Name of the type.
throwOnError bool Throws an error if and not found.
ignoreCase bool Ignores the case if .
Résultat System.Type

GetConstructor() public méthode

Gets the constructor.
public GetConstructor ( ) : Constructor
Résultat Constructor

GetConstructor() public méthode

Gets the Constructor matching the ConstructorInfo (if any).
public GetConstructor ( [ constructorInfo, bool includeBase = true ) : Constructor
constructorInfo [ The constructor info.
includeBase bool if set to includes constructors from the base type.
Résultat Constructor

GetConstructor() public méthode

Gets the constructor.
public GetConstructor ( bool includeBase ) : Constructor
includeBase bool if set to includes constructors from the base type.
Résultat Constructor

GetConstructor() public méthode

Gets the constructor.
public GetConstructor ( bool &castsRequired, bool includeBase ) : Constructor
castsRequired bool Any array indicating which parameters require a cast (the last element is for the return type).
includeBase bool if set to includes constructors from the base type.
Résultat Constructor

GetEvent() public méthode

Gets the event.
public GetEvent ( [ name, bool includeBase = true ) : Event
name [ The name.
includeBase bool if set to includes events from the base type.
Résultat Event

GetField() public méthode

Gets the field.
public GetField ( [ name, bool includeBase = true ) : Field
name [ The name.
includeBase bool if set to includes fields from the base type.
Résultat Field

GetIndexer() public méthode

Gets the indexer from the type (or base types).
public GetIndexer ( ) : Indexer
Résultat Indexer

GetIndexer() public méthode

Gets the Indexer matching the PropertyInfo (if any).
public GetIndexer ( [ propertyInfo, bool includeBase = true ) : Indexer
propertyInfo [ The property info.
includeBase bool if set to includes indexers from the base type.
Résultat Indexer

GetIndexer() public méthode

Gets the indexer from the type (or base types).
public GetIndexer ( bool &castsRequired ) : Indexer
castsRequired bool Any array indicating which parameters require a cast (the last element is for the return type).
Résultat Indexer

GetIndexer() public méthode

Gets the indexer.
public GetIndexer ( bool includeBase, bool &castsRequired ) : Indexer
includeBase bool if set to includes indexers from the base type.
castsRequired bool Any array indicating which parameters require a cast (the last element is for the return type).
Résultat Indexer

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name ) : Method
name [ The name.
Résultat Method

GetMethod() public méthode

Gets the Method matching the MethodInfo (if any).
public GetMethod ( [ methodInfo, bool includeBase = true ) : Method
methodInfo [ The method info.
includeBase bool if set to includes methods from the base type.
Résultat Method

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name, int genericArguments ) : Method
name [ The name.
genericArguments int The number of generic arguments.
Résultat Method

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name, int genericArguments, bool includeBase ) : Method
name [ The name.
genericArguments int The number of generic arguments.
includeBase bool if set to includes methods from the base type.
Résultat Method

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts ) : Method
name [ The name.
genericArguments int The number of generic arguments.
allowClosure bool if set to will automatically close the signatures generic types if possible.
allowCasts bool if set to then types will match if they can be cast to the required type.
Résultat Method

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts, bool includeBase ) : Method
name [ The name.
genericArguments int The number of generic arguments.
allowClosure bool if set to will automatically close the signatures generic types if possible.
allowCasts bool if set to then types will match if they can be cast to the required type.
includeBase bool if set to includes methods from the base type.
Résultat Method

GetMethod() public méthode

Gets the method.
public GetMethod ( [ name, int genericArguments, bool allowClosure, bool allowCasts, bool &castsRequired, bool includeBase ) : Method
name [ The name.
genericArguments int The number of generic arguments.
allowClosure bool if set to will automatically close the signatures generic types if possible.
allowCasts bool if set to then types will match if they can be cast to the required type.
castsRequired bool Any array indicating which parameters require a cast (the last element is for the return type).
includeBase bool if set to includes methods from the base type.
Résultat Method

GetMethods() public méthode

Gets the methods.
public GetMethods ( [ name, bool includeBase = true ) : IEnumerable
name [ The name.
includeBase bool if set to includes methods from the base type.
Résultat IEnumerable

GetProperty() public méthode

Gets the property.
public GetProperty ( [ name, bool includeBase = true ) : System.Property
name [ The name.
includeBase bool if set to includes properties from the base type.
Résultat System.Property

Implements() public méthode

Checks to see if this type implements a particular interface.
public Implements ( [ interfaceType ) : bool
interfaceType [ Type of the interface.
Résultat bool

ImplementsCastFrom() public méthode

Whether this type implements a cast from the specified type.
public ImplementsCastFrom ( [ fromType, bool implicitOnly = true ) : bool
fromType [ The type to cast from.
implicitOnly bool If set to only allows implicit casts.
Résultat bool

ImplementsCastTo() public méthode

Whether this type implements a cast to the specified type.
public ImplementsCastTo ( [ toType, bool implicitOnly = true ) : bool
toType [ The type to cast to.
implicitOnly bool If set to only allows implicit casts.
Résultat bool

TryConvert() public méthode

Converts the specified expression to the output type.
This version is more powerful than the Expression.Convert CLR method in that it supports ToString() conversion, IConvertible and TypeConverters. It also prevents exceptions being thrown.
public TryConvert ( [ expression, [ outputExpression ) : bool
expression [ The expression.
outputExpression [ The output expression.
Résultat bool