C# Класс WebApplications.Utilities.Reflect.ExtendedType

Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
Get ExtendedType
Get ExtendedType
GetCastFromMethod CastMethod
GetCastToMethod CastMethod
LoadMembers void

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
Get ( [ type ) : ExtendedType
Get ( [ typeName, bool ignoreCase = false ) : ExtendedType
GetCastFromMethod ( [ fromType ) : CastMethod
GetCastToMethod ( [ toType ) : CastMethod
LoadMembers ( ) : void

Loads all the members in one go.

Описание методов

CanConvertTo() публичный Метод

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.
Результат bool

CloseType() публичный Метод

Closes the type if it is generic and has generic parameters, or creates equivalent type.
public CloseType ( ) : ExtendedType
Результат ExtendedType

DescendsFrom() публичный Метод

Checks to see if a type descends from another type.
public DescendsFrom ( [ baseType ) : bool
baseType [ Type of the base.
Результат bool

ExtendedType() публичный Метод

Initializes a new instance of the ExtendedType class.
public ExtendedType ( [ type ) : System
type [ The type.
Результат System

FindType() публичный статический Метод

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 .
Результат System.Type

GetConstructor() публичный Метод

Gets the constructor.
public GetConstructor ( ) : Constructor
Результат Constructor

GetConstructor() публичный Метод

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.
Результат Constructor

GetConstructor() публичный Метод

Gets the constructor.
public GetConstructor ( bool includeBase ) : Constructor
includeBase bool if set to includes constructors from the base type.
Результат Constructor

GetConstructor() публичный Метод

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.
Результат Constructor

GetEvent() публичный Метод

Gets the event.
public GetEvent ( [ name, bool includeBase = true ) : Event
name [ The name.
includeBase bool if set to includes events from the base type.
Результат Event

GetField() публичный Метод

Gets the field.
public GetField ( [ name, bool includeBase = true ) : Field
name [ The name.
includeBase bool if set to includes fields from the base type.
Результат Field

GetIndexer() публичный Метод

Gets the indexer from the type (or base types).
public GetIndexer ( ) : Indexer
Результат Indexer

GetIndexer() публичный Метод

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.
Результат Indexer

GetIndexer() публичный Метод

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).
Результат Indexer

GetIndexer() публичный Метод

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).
Результат Indexer

GetMethod() публичный Метод

Gets the method.
public GetMethod ( [ name ) : Method
name [ The name.
Результат Method

GetMethod() публичный Метод

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.
Результат Method

GetMethod() публичный Метод

Gets the method.
public GetMethod ( [ name, int genericArguments ) : Method
name [ The name.
genericArguments int The number of generic arguments.
Результат Method

GetMethod() публичный Метод

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.
Результат Method

GetMethod() публичный Метод

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.
Результат Method

GetMethod() публичный Метод

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.
Результат Method

GetMethod() публичный Метод

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.
Результат Method

GetMethods() публичный Метод

Gets the methods.
public GetMethods ( [ name, bool includeBase = true ) : IEnumerable
name [ The name.
includeBase bool if set to includes methods from the base type.
Результат IEnumerable

GetProperty() публичный Метод

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.
Результат System.Property

Implements() публичный Метод

Checks to see if this type implements a particular interface.
public Implements ( [ interfaceType ) : bool
interfaceType [ Type of the interface.
Результат bool

ImplementsCastFrom() публичный Метод

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.
Результат bool

ImplementsCastTo() публичный Метод

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.
Результат bool

TryConvert() публичный Метод

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.
Результат bool