C# Класс ICSharpCode.NRefactory.TypeSystem.TypeSystemExtensions

Contains extension methods for the type system.
Показать файл Открыть проект

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

Метод Описание
CreateResolvedAttributes ( this attributes, ITypeResolveContext context ) : IList
CreateResolvedParameters ( this parameters, ITypeResolveContext context ) : IList
CreateResolvedTypeParameters ( this typeParameters, ITypeResolveContext context ) : IList
FindType ( this compilation, FullTypeName fullTypeName ) : IType

Retrieves the specified type in this compilation. Returns an UnknownType if the type cannot be found in this compilation.

There can be multiple types with the same full name in a compilation, as a full type name is only unique per assembly. If there are multiple possible matches, this method will return just one of them. When possible, use IAssembly.GetTypeDefinition instead to retrieve a type from a specific assembly.

GetAllBaseTypeDefinitions ( this type ) : IEnumerable

Gets all base type definitions. The output is ordered so that base types occur before derived types.

This is equivalent to type.GetAllBaseTypes().Select(t => t.GetDefinition()).Where(d => d != null).Distinct().

GetAllBaseTypes ( this type ) : IEnumerable

Gets all base types.

This is the reflexive and transitive closure of IType.DirectBaseTypes. Note that this method does not return all supertypes - doing so is impossible due to contravariance (and undesirable for covariance as the list could become very large). The output is ordered so that base types occur before derived types.

GetAllTypeDefinitions ( this assembly ) : IEnumerable
GetAllTypeDefinitions ( this file ) : IEnumerable

Gets all unresolved type definitions from the file. For partial classes, each part is returned.

GetAttribute ( this entity, FullTypeName attributeType, bool inherit = true ) : IAttribute

Gets the attribute of the specified attribute type (or derived attribute types).

GetAttribute ( this entity, IType attributeType, bool inherit = true ) : IAttribute

Gets the attribute of the specified attribute type (or derived attribute types).

GetAttributes ( this entity, FullTypeName attributeType, bool inherit = true ) : IEnumerable

Gets the attributes of the specified attribute type (or derived attribute types).

GetAttributes ( this entity, IType attributeType, bool inherit = true ) : IEnumerable

Gets the attributes of the specified attribute type (or derived attribute types).

GetAttributes ( this entity, bool inherit = true ) : IEnumerable

Gets the attribute of the specified attribute type (or derived attribute types).

GetDelegateInvokeMethod ( this type ) : IMethod

Gets the invoke method for a delegate type.

Returns null if the type is not a delegate type; or if the invoke method could not be found.

GetInnermostTypeDefinition ( this file, int line, int column ) : IUnresolvedTypeDefinition

Gets the type (potentially a nested type) defined at the specified location. Returns null if no type is defined at that location.

GetMember ( this file, int line, int column ) : IUnresolvedMember

Gets the member defined at the specified location. Returns null if no member is defined at that location.

GetNonInterfaceBaseTypes ( this type ) : IEnumerable

Gets all non-interface base types.

When type is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()). The output is ordered so that base types occur before derived types.

GetSubTypeDefinitions ( this baseType ) : IEnumerable
GetSymbol ( this rr ) : ISymbol
GetTopLevelTypeDefinitons ( this compilation ) : IEnumerable

Gets all top level type definitions in the compilation. This may include types from referenced assemblies that are not accessible in the main assembly.

GetTypeDefinition ( this assembly, FullTypeName fullTypeName ) : ITypeDefinition

Gets the type definition for the specified unresolved type. Returns null if the unresolved type does not belong to this assembly.

GetTypeDefinition ( this assembly, string namespaceName, string name, int typeParameterCount ) : ITypeDefinition

Gets the type definition for a top-level type.

This method uses ordinal name comparison, not the compilation's name comparer.

Import ( this compilation, IEntity entity ) : IEntity

Imports an entity from another compilation.

Import ( this compilation, IEvent ev ) : IEvent

Imports a member from another compilation.

Import ( this compilation, IField field ) : IField

Imports a member from another compilation.

Import ( this compilation, IMember member ) : IMember

Imports a member from another compilation.

Import ( this compilation, IMethod method ) : IMethod

Imports a member from another compilation.

Import ( this compilation, INamespace ns ) : INamespace

Imports a namespace from another compilation.

This method may return null if the namespace does not exist in the target compilation.

Import ( this compilation, IProperty property ) : IProperty

Imports a member from another compilation.

Import ( this compilation, ISymbol symbol ) : ISymbol

Imports a symbol from another compilation.

Import ( this compilation, IType type ) : IType

Imports a type from another compilation.

Import ( this compilation, ITypeDefinition typeDefinition ) : ITypeDefinition

Imports a type from another compilation.

IsDerivedFrom ( this type, ITypeDefinition baseType ) : bool

Gets whether this type definition is derived from the base type definition.

IsDerivedFrom ( this type, KnownTypeCode baseType ) : bool

Gets whether this type definition is derived from a given known type.

IsKnownType ( this type, KnownTypeCode knownType ) : bool

Gets whether the type is the specified known type. For generic known types, this returns true any parameterization of the type (and also for the definition itself).

IsOpen ( this type ) : bool

Gets whether the type is an open type (contains type parameters).

IsUnbound ( this type ) : bool

Gets whether the type is unbound (is a generic type, but no type arguments were provided).

In "typeof(List<Dictionary<,>>)", only the Dictionary is unbound, the List is considered bound despite containing an unbound type. This method returns false for partially parameterized types (Dictionary<string, >).

Resolve ( this typeReferences, ITypeResolveContext context ) : IList
Resolve ( this constantValues, ITypeResolveContext context ) : IList
Resolve ( this reference, ICompilation compilation ) : IType

Resolves a type reference in the compilation's main type resolve context. Some type references require a more specific type resolve context and will not resolve using this method.

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

Метод Описание
FindNestedType ( ITypeDefinition typeDef, string name, int typeParameterCount ) : ITypeDefinition
GetAttributes ( IEntity entity, Predicate attributeTypePredicate, bool inherit ) : IEnumerable
GetTypeParameterOwner ( IType type ) : IEntity

Gets the entity that owns the type parameters occurring in the specified type. If both class and method type parameters are present, the method is returned. Returns null if the specified type is closed.

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

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

public static CreateResolvedAttributes ( this attributes, ITypeResolveContext context ) : IList
attributes this
context ITypeResolveContext
Результат IList

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

public static CreateResolvedParameters ( this parameters, ITypeResolveContext context ) : IList
parameters this
context ITypeResolveContext
Результат IList

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

public static CreateResolvedTypeParameters ( this typeParameters, ITypeResolveContext context ) : IList
typeParameters this
context ITypeResolveContext
Результат IList

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

Retrieves the specified type in this compilation. Returns an UnknownType if the type cannot be found in this compilation.
There can be multiple types with the same full name in a compilation, as a full type name is only unique per assembly. If there are multiple possible matches, this method will return just one of them. When possible, use IAssembly.GetTypeDefinition instead to retrieve a type from a specific assembly.
public static FindType ( this compilation, FullTypeName fullTypeName ) : IType
compilation this
fullTypeName FullTypeName
Результат IType

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

Gets all base type definitions. The output is ordered so that base types occur before derived types.
This is equivalent to type.GetAllBaseTypes().Select(t => t.GetDefinition()).Where(d => d != null).Distinct().
public static GetAllBaseTypeDefinitions ( this type ) : IEnumerable
type this
Результат IEnumerable

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

Gets all base types.
This is the reflexive and transitive closure of IType.DirectBaseTypes. Note that this method does not return all supertypes - doing so is impossible due to contravariance (and undesirable for covariance as the list could become very large). The output is ordered so that base types occur before derived types.
public static GetAllBaseTypes ( this type ) : IEnumerable
type this
Результат IEnumerable

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

public static GetAllTypeDefinitions ( this assembly ) : IEnumerable
assembly this
Результат IEnumerable

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

Gets all unresolved type definitions from the file. For partial classes, each part is returned.
public static GetAllTypeDefinitions ( this file ) : IEnumerable
file this
Результат IEnumerable

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

Gets the attribute of the specified attribute type (or derived attribute types).
public static GetAttribute ( this entity, FullTypeName attributeType, bool inherit = true ) : IAttribute
entity this The entity on which the attributes are declared.
attributeType FullTypeName The attribute type to look for.
inherit bool /// Specifies whether attributes inherited from base classes and base members (if the given in an override) /// should be returned. The default is true. ///
Результат IAttribute

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

Gets the attribute of the specified attribute type (or derived attribute types).
public static GetAttribute ( this entity, IType attributeType, bool inherit = true ) : IAttribute
entity this The entity on which the attributes are declared.
attributeType IType The attribute type to look for.
inherit bool /// Specifies whether attributes inherited from base classes and base members (if the given in an override) /// should be returned. The default is true. ///
Результат IAttribute

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

Gets the attributes of the specified attribute type (or derived attribute types).
public static GetAttributes ( this entity, FullTypeName attributeType, bool inherit = true ) : IEnumerable
entity this The entity on which the attributes are declared.
attributeType FullTypeName The attribute type to look for.
inherit bool /// Specifies whether attributes inherited from base classes and base members (if the given in an override) /// should be returned. The default is true. ///
Результат IEnumerable

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

Gets the attributes of the specified attribute type (or derived attribute types).
public static GetAttributes ( this entity, IType attributeType, bool inherit = true ) : IEnumerable
entity this The entity on which the attributes are declared.
attributeType IType The attribute type to look for.
inherit bool /// Specifies whether attributes inherited from base classes and base members (if the given in an override) /// should be returned. The default is true. ///
Результат IEnumerable

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

Gets the attribute of the specified attribute type (or derived attribute types).
public static GetAttributes ( this entity, bool inherit = true ) : IEnumerable
entity this The entity on which the attributes are declared.
inherit bool /// Specifies whether attributes inherited from base classes and base members (if the given in an override) /// should be returned. The default is true. ///
Результат IEnumerable

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

Gets the invoke method for a delegate type.
Returns null if the type is not a delegate type; or if the invoke method could not be found.
public static GetDelegateInvokeMethod ( this type ) : IMethod
type this
Результат IMethod

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

Gets the type (potentially a nested type) defined at the specified location. Returns null if no type is defined at that location.
public static GetInnermostTypeDefinition ( this file, int line, int column ) : IUnresolvedTypeDefinition
file this
line int
column int
Результат IUnresolvedTypeDefinition

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

Gets the member defined at the specified location. Returns null if no member is defined at that location.
public static GetMember ( this file, int line, int column ) : IUnresolvedMember
file this
line int
column int
Результат IUnresolvedMember

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

Gets all non-interface base types.
When type is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()). The output is ordered so that base types occur before derived types.
public static GetNonInterfaceBaseTypes ( this type ) : IEnumerable
type this
Результат IEnumerable

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

public static GetSubTypeDefinitions ( this baseType ) : IEnumerable
baseType this
Результат IEnumerable

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

public static GetSymbol ( this rr ) : ISymbol
rr this
Результат ISymbol

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

Gets all top level type definitions in the compilation. This may include types from referenced assemblies that are not accessible in the main assembly.
public static GetTopLevelTypeDefinitons ( this compilation ) : IEnumerable
compilation this
Результат IEnumerable

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

Gets the type definition for the specified unresolved type. Returns null if the unresolved type does not belong to this assembly.
public static GetTypeDefinition ( this assembly, FullTypeName fullTypeName ) : ITypeDefinition
assembly this
fullTypeName FullTypeName
Результат ITypeDefinition

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

Gets the type definition for a top-level type.
This method uses ordinal name comparison, not the compilation's name comparer.
public static GetTypeDefinition ( this assembly, string namespaceName, string name, int typeParameterCount ) : ITypeDefinition
assembly this
namespaceName string
name string
typeParameterCount int
Результат ITypeDefinition

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

Imports an entity from another compilation.
public static Import ( this compilation, IEntity entity ) : IEntity
compilation this
entity IEntity
Результат IEntity

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

Imports a member from another compilation.
public static Import ( this compilation, IEvent ev ) : IEvent
compilation this
ev IEvent
Результат IEvent

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

Imports a member from another compilation.
public static Import ( this compilation, IField field ) : IField
compilation this
field IField
Результат IField

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

Imports a member from another compilation.
public static Import ( this compilation, IMember member ) : IMember
compilation this
member IMember
Результат IMember

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

Imports a member from another compilation.
public static Import ( this compilation, IMethod method ) : IMethod
compilation this
method IMethod
Результат IMethod

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

Imports a namespace from another compilation.
This method may return null if the namespace does not exist in the target compilation.
public static Import ( this compilation, INamespace ns ) : INamespace
compilation this
ns INamespace
Результат INamespace

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

Imports a member from another compilation.
public static Import ( this compilation, IProperty property ) : IProperty
compilation this
property IProperty
Результат IProperty

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

Imports a symbol from another compilation.
public static Import ( this compilation, ISymbol symbol ) : ISymbol
compilation this
symbol ISymbol
Результат ISymbol

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

Imports a type from another compilation.
public static Import ( this compilation, IType type ) : IType
compilation this
type IType
Результат IType

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

Imports a type from another compilation.
public static Import ( this compilation, ITypeDefinition typeDefinition ) : ITypeDefinition
compilation this
typeDefinition ITypeDefinition
Результат ITypeDefinition

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

Gets whether this type definition is derived from the base type definition.
public static IsDerivedFrom ( this type, ITypeDefinition baseType ) : bool
type this
baseType ITypeDefinition
Результат bool

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

Gets whether this type definition is derived from a given known type.
public static IsDerivedFrom ( this type, KnownTypeCode baseType ) : bool
type this
baseType KnownTypeCode
Результат bool

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

Gets whether the type is the specified known type. For generic known types, this returns true any parameterization of the type (and also for the definition itself).
public static IsKnownType ( this type, KnownTypeCode knownType ) : bool
type this
knownType KnownTypeCode
Результат bool

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

Gets whether the type is an open type (contains type parameters).
public static IsOpen ( this type ) : bool
type this
Результат bool

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

Gets whether the type is unbound (is a generic type, but no type arguments were provided).
In "typeof(List<Dictionary<,>>)", only the Dictionary is unbound, the List is considered bound despite containing an unbound type. This method returns false for partially parameterized types (Dictionary<string, >).
public static IsUnbound ( this type ) : bool
type this
Результат bool

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

public static Resolve ( this typeReferences, ITypeResolveContext context ) : IList
typeReferences this
context ITypeResolveContext
Результат IList

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

public static Resolve ( this constantValues, ITypeResolveContext context ) : IList
constantValues this
context ITypeResolveContext
Результат IList

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

Resolves a type reference in the compilation's main type resolve context. Some type references require a more specific type resolve context and will not resolve using this method.
public static Resolve ( this reference, ICompilation compilation ) : IType
reference this
compilation ICompilation
Результат IType