Class TypeIdentifier
Representation of a .NET type name, allowing access to the individual parts of the type name, both for reading and for modification.
Implements
Inherited Members
Namespace: Alphaleonis.Reflection.Metadata
Assembly: Alphaleonis.Reflection.Metadata.dll
Syntax
[Serializable]
public class TypeIdentifier : IEquatable<TypeIdentifier>
Remarks
Use Parse(String) to create a new instance of a TypeIdentifier
Properties
| Improve this Doc View SourceAssemblyName
Gets or sets the assembly name in which this type resides. This may be null if no assembly name was provided.
Declaration
public AssemblyName AssemblyName { get; set; }
Property Value
Type | Description |
---|---|
AssemblyName |
AssemblyQualifiedName
Gets or sets the full assembly qualified name of the type.
Declaration
public string AssemblyQualifiedName { get; set; }
Property Value
Type | Description |
---|---|
String |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when one or more required arguments are null. |
ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
FullName
Gets or sets the full name of the type. This is equivalent to FullName.
Declaration
public string FullName { get; set; }
Property Value
Type | Description |
---|---|
String |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when one or more required arguments are null. |
ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
GenericArguments
Gets a list containing the generic arguments of this type, or an empty list if no generic arguments are available.
Declaration
public IList<TypeIdentifier> GenericArguments { get; }
Property Value
Type | Description |
---|---|
IList<TypeIdentifier> |
IsArray
Returns true if this type is an array.
Declaration
public bool IsArray { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsPointer
Returns true if this type is a pointer.
Declaration
public bool IsPointer { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsReference
Returns true if this type is a reference.
Declaration
public bool IsReference { get; }
Property Value
Type | Description |
---|---|
Boolean |
Name
Gets or sets the simple name of the type without any array/pointer/byref specs.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
String | The name. |
Remarks
This is different from Name that does include the array/pointer/byRef specifiers.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when one or more required arguments are null. |
ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
Namespace
Gets or sets the namespace of the type. May be null if the type is not contained within a namespace.
Declaration
public string Namespace { get; set; }
Property Value
Type | Description |
---|---|
String |
NamespaceTypeName
Gets or sets the namespace and type name, without any array/pointer/reference specifiers or
generic arguments. For example the
NamespaceTypeName of the type
System.Collections.Generic.Dictionary
.2+KeyCollection[System.String,System.Int32][,]</code> is <code>System.Collections.Generic.Dictionary
2+KeyCollection
Declaration
public string NamespaceTypeName { get; set; }
Property Value
Type | Description |
---|---|
String | The name of the namespace type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when one or more required arguments are null. |
ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
TypeSpecifiers
Gets or sets the specifiers indicating whether this type is an array, pointer or reference type.
Declaration
public IList<TypeSpecifier> TypeSpecifiers { get; }
Property Value
Type | Description |
---|---|
IList<TypeSpecifier> |
Methods
| Improve this Doc View SourceEquals(TypeIdentifier)
Tests if this TypeIdentifier is considered equal to another.
Declaration
public bool Equals(TypeIdentifier other)
Parameters
Type | Name | Description |
---|---|---|
TypeIdentifier | other | The type identifier to compare to this object. |
Returns
Type | Description |
---|---|
Boolean | True if the objects are considered equal, false if they are not. |
Equals(Object)
Tests if this object is considered equal to another.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare to this object. |
Returns
Type | Description |
---|---|
Boolean | True if the objects are considered equal, false if they are not. |
Overrides
| Improve this Doc View SourceGetDeclaringType()
Gets declaring type of this type if this type is a nested type, or returns null otherwise.
Declaration
public TypeIdentifier GetDeclaringType()
Returns
Type | Description |
---|---|
TypeIdentifier |
GetElementType()
Gets element type of this type if this type is an array, pointer or reference. Returns null otherwise.
Declaration
public TypeIdentifier GetElementType()
Returns
Type | Description |
---|---|
TypeIdentifier |
GetHashCode()
Calculates a hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this object. |
Overrides
| Improve this Doc View SourceParse(String)
Parses a type name. This may be an assembly qualified name, a full type name or a simple type name.
Declaration
public static TypeIdentifier Parse(string typeName)
Parameters
Type | Name | Description |
---|---|---|
String | typeName | The type name to parse |
Returns
Type | Description |
---|---|
TypeIdentifier | A new TypeIdentifier representing the specified type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when one or more required arguments are null. |
ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
ToString()
Convert this object into a string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string that represents this object. |