GenericTypeParameterBuilder Class
Defines and creates generic type parameters for dynamically defined generic types and methods. This class cannot be inherited.
System.Reflection::MemberInfo
System::Type
System.Reflection.Emit::GenericTypeParameterBuilder
Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
The GenericTypeParameterBuilder type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Assembly | Gets an Assembly object representing the dynamic assembly that contains the generic type definition the current type parameter belongs to. (Overrides Type::Assembly.) |
![]() | AssemblyQualifiedName | Gets nullptr in all cases. (Overrides Type::AssemblyQualifiedName.) |
![]() | Attributes | Gets the attributes associated with the Type. (Inherited from Type.) |
![]() | BaseType | Gets the base type constraint of the current generic type parameter. (Overrides Type::BaseType.) |
![]() | ContainsGenericParameters | Gets true in all cases. (Overrides Type::ContainsGenericParameters.) |
![]() | DeclaringMethod | Gets a MethodInfo that represents the declaring method, if the current GenericTypeParameterBuilder represents a type parameter of a generic method. (Overrides Type::DeclaringMethod.) |
![]() | DeclaringType | Gets the generic type definition or generic method definition to which the generic type parameter belongs. (Overrides Type::DeclaringType.) |
![]() | FullName | Gets nullptr in all cases. (Overrides Type::FullName.) |
![]() | GenericParameterAttributes | Gets a combination of GenericParameterAttributes flags that describe the covariance and special constraints of the current generic type parameter. (Inherited from Type.) |
![]() | GenericParameterPosition | Gets the position of the type parameter in the type parameter list of the generic type or method that declared the parameter. (Overrides Type::GenericParameterPosition.) |
![]() | GUID | Not supported for incomplete generic type parameters. (Overrides Type::GUID.) |
![]() | HasElementType | Gets a value indicating whether the current Type encompasses or refers to another type; that is, whether the current Type is an array, a pointer, or is passed by reference. (Inherited from Type.) |
![]() | IsAbstract | Gets a value indicating whether the Type is abstract and must be overridden. (Inherited from Type.) |
![]() | IsAnsiClass | Gets a value indicating whether the string format attribute AnsiClass is selected for the Type. (Inherited from Type.) |
![]() | IsArray | Gets a value indicating whether the Type is an array. (Inherited from Type.) |
![]() | IsAutoClass | Gets a value indicating whether the string format attribute AutoClass is selected for the Type. (Inherited from Type.) |
![]() | IsAutoLayout | Gets a value indicating whether the class layout attribute AutoLayout is selected for the Type. (Inherited from Type.) |
![]() | IsByRef | Gets a value indicating whether the Type is passed by reference. (Inherited from Type.) |
![]() | IsClass | Gets a value indicating whether the Type is a class; that is, not a value type or interface. (Inherited from Type.) |
![]() | IsCOMObject | Gets a value indicating whether the Type is a COM object. (Inherited from Type.) |
![]() | IsEnum | Gets a value indicating whether the current Type represents an enumeration. (Inherited from Type.) |
![]() | IsGenericParameter | Gets true in all cases. (Overrides Type::IsGenericParameter.) |
![]() | IsGenericType | Returns false in all cases. (Overrides Type::IsGenericType.) |
![]() | IsGenericTypeDefinition | Gets false in all cases. (Overrides Type::IsGenericTypeDefinition.) |
![]() | IsImport | Gets a value indicating whether the Type has a ComImportAttribute attribute applied, indicating that it was imported from a COM type library. (Inherited from Type.) |
![]() | IsInterface | Gets a value indicating whether the Type is an interface; that is, not a class or a value type. (Inherited from Type.) |
![]() | IsNested | Gets a value indicating whether the current Type object represents a type whose definition is nested inside the definition of another type. (Inherited from Type.) |
![]() | IsNestedAssembly | Gets a value indicating whether the Type is nested and visible only within its own assembly. (Inherited from Type.) |
![]() | IsNestedFamANDAssem | Gets a value indicating whether the Type is nested and visible only to classes that belong to both its own family and its own assembly. (Inherited from Type.) |
![]() | IsNestedFamily | Gets a value indicating whether the Type is nested and visible only within its own family. (Inherited from Type.) |
![]() | IsNestedFamORAssem | Gets a value indicating whether the Type is nested and visible only to classes that belong to either its own family or to its own assembly. (Inherited from Type.) |
![]() | IsNestedPrivate | Gets a value indicating whether the Type is nested and declared private. (Inherited from Type.) |
![]() | IsNestedPublic | Gets a value indicating whether a class is nested and declared public. (Inherited from Type.) |
![]() | IsNotPublic | Gets a value indicating whether the Type is not declared public. (Inherited from Type.) |
![]() | IsPointer | Gets a value indicating whether the Type is a pointer. (Inherited from Type.) |
![]() | IsPrimitive | Gets a value indicating whether the Type is one of the primitive types. (Inherited from Type.) |
![]() | IsPublic | Gets a value indicating whether the Type is declared public. (Inherited from Type.) |
![]() | IsSealed | Gets a value indicating whether the Type is declared sealed. (Inherited from Type.) |
![]() | IsSpecialName | Gets a value indicating whether the Type has a name that requires special handling. (Inherited from Type.) |
![]() | IsUnicodeClass | Gets a value indicating whether the string format attribute UnicodeClass is selected for the Type. (Inherited from Type.) |
![]() | IsValueType | Gets a value indicating whether the Type is a value type. (Inherited from Type.) |
![]() | IsVisible | Gets a value indicating whether the Type can be accessed by code outside the assembly. (Inherited from Type.) |
![]() | MemberType | Gets a MemberTypes value indicating that this member is a type or a nested type. (Inherited from Type.) |
![]() | MetadataToken | Gets a value that identifies a metadata element. (Inherited from MemberInfo.) |
![]() | Module | Gets the dynamic module that contains the generic type parameter. (Overrides Type::Module.) |
![]() | Name | Gets the name of the generic type parameter. (Overrides MemberInfo::Name.) |
![]() | Namespace | Gets nullptr in all cases. (Overrides Type::Namespace.) |
![]() | ReflectedType | Gets the Type object that was used to obtain the GenericTypeParameterBuilder. (Overrides Type::ReflectedType.) |
![]() | TypeHandle | Not supported for incomplete generic type parameters. (Overrides Type::TypeHandle.) |
![]() | UnderlyingSystemType | Gets the current generic type parameter. (Overrides Type::UnderlyingSystemType.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Tests whether the given object is an instance of EventToken and is equal to the current instance. (Overrides Type::Equals(Object).) |
![]() | Equals(Type) | Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Type. (Inherited from Type.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | FindMembers | Returns a filtered array of MemberInfo objects of the specified member type. (Inherited from Type.) |
![]() | GetArrayRank | Gets the number of dimensions in an Array. (Inherited from Type.) |
![]() | GetAttributeFlagsImpl | When overridden in a derived class, implements the Attributes property and gets a bitmask indicating the attributes associated with the Type. (Inherited from Type.) |
![]() | GetConstructor(array<Type>) | Searches for a public instance constructor whose parameters match the types in the specified array. (Inherited from Type.) |
![]() | GetConstructor(BindingFlags, Binder, array<Type>, array<ParameterModifier>) | Searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.) |
![]() | GetConstructorImpl | When overridden in a derived class, searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.) |
![]() | GetConstructors() | Returns all the public constructors defined for the current Type. (Inherited from Type.) |
![]() | GetConstructors(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetConstructors(BindingFlags).) |
![]() | GetCustomAttributes(Boolean) | Not supported for incomplete generic type parameters. (Overrides MemberInfo::GetCustomAttributes(Boolean).) |
![]() | GetCustomAttributes(Type, Boolean) | Not supported for incomplete generic type parameters. (Overrides MemberInfo::GetCustomAttributes(Type, Boolean).) |
![]() | GetDefaultMembers | Searches for the members defined for the current Type whose DefaultMemberAttribute is set. (Inherited from Type.) |
![]() | GetElementType | Throws a NotSupportedException in all cases. (Overrides Type::GetElementType().) |
![]() | GetEvent(String) | Returns the EventInfo object representing the specified public event. (Inherited from Type.) |
![]() | GetEvent(String, BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetEvent(String, BindingFlags).) |
![]() | GetEvents() | Not supported for incomplete generic type parameters. (Overrides Type::GetEvents().) |
![]() | GetEvents(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetEvents(BindingFlags).) |
![]() | GetField(String) | Searches for the public field with the specified name. (Inherited from Type.) |
![]() | GetField(String, BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetField(String, BindingFlags).) |
![]() | GetFields() | Returns all the public fields of the current Type. (Inherited from Type.) |
![]() | GetFields(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetFields(BindingFlags).) |
![]() | GetGenericArguments | Not valid for generic type parameters. (Overrides Type::GetGenericArguments().) |
![]() | GetGenericParameterConstraints | Returns an array of Type objects that represent the constraints on the current generic type parameter. (Inherited from Type.) |
![]() | GetGenericTypeDefinition | Not valid for generic type parameters. (Overrides Type::GetGenericTypeDefinition().) |
![]() | GetHashCode | Returns a 32-bit integer hash code for the current instance. (Overrides Type::GetHashCode().) |
![]() | GetInterface | Not supported for incomplete generic type parameters. (Overrides Type::GetInterface(String, Boolean).) |
![]() | GetInterfaceMap | Not supported for incomplete generic type parameters. (Overrides Type::GetInterfaceMap(Type).) |
![]() | GetInterfaces | Not supported for incomplete generic type parameters. (Overrides Type::GetInterfaces().) |
![]() | GetMember(String) | Searches for the public members with the specified name. (Inherited from Type.) |
![]() | GetMember(String, BindingFlags) | Searches for the specified members, using the specified binding constraints. (Inherited from Type.) |
![]() | GetMember(String, MemberTypes, BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetMember(String, MemberTypes, BindingFlags).) |
![]() | GetMembers() | Returns all the public members of the current Type. (Inherited from Type.) |
![]() | GetMembers(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetMembers(BindingFlags).) |
![]() | GetMethod(String) | Searches for the public method with the specified name. (Inherited from Type.) |
![]() | GetMethod(String, BindingFlags) | Searches for the specified method, using the specified binding constraints. (Inherited from Type.) |
![]() | GetMethod(String, array<Type>) | Searches for the specified public method whose parameters match the specified argument types. (Inherited from Type.) |
![]() | GetMethod(String, array<Type>, array<ParameterModifier>) | Searches for the specified public method whose parameters match the specified argument types and modifiers. (Inherited from Type.) |
![]() | GetMethod(String, BindingFlags, Binder, array<Type>, array<ParameterModifier>) | Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.) |
![]() | GetMethod(String, BindingFlags, Binder, CallingConventions, array<Type>, array<ParameterModifier>) | Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.) |
![]() | GetMethodImpl | When overridden in a derived class, searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention. (Inherited from Type.) |
![]() | GetMethods() | Returns all the public methods of the current Type. (Inherited from Type.) |
![]() | GetMethods(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetMethods(BindingFlags).) |
![]() | GetNestedType | Not supported for incomplete generic type parameters. (Overrides Type::GetNestedType(String, BindingFlags).) |
![]() | GetNestedTypes | Not supported for incomplete generic type parameters. (Overrides Type::GetNestedTypes(BindingFlags).) |
![]() | GetProperties() | Returns all the public properties of the current Type. (Inherited from Type.) |
![]() | GetProperties(BindingFlags) | Not supported for incomplete generic type parameters. (Overrides Type::GetProperties(BindingFlags).) |
![]() | GetProperty(String) | Searches for the public property with the specified name. (Inherited from Type.) |
![]() | GetProperty(String, BindingFlags) | Searches for the specified property, using the specified binding constraints. (Inherited from Type.) |
![]() | GetProperty(String, Type) | Searches for the public property with the specified name and return type. (Inherited from Type.) |
![]() | GetProperty(String, Type, array<Type>) | Searches for the specified public property whose parameters match the specified argument types. (Inherited from Type.) |
![]() | GetProperty(String, Type, array<Type>, array<ParameterModifier>) | Searches for the specified public property whose parameters match the specified argument types and modifiers. (Inherited from Type.) |
![]() | GetProperty(String, BindingFlags, Binder, Type, array<Type>, array<ParameterModifier>) | Searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.) |
![]() | GetPropertyImpl | When overridden in a derived class, searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints. (Inherited from Type.) |
![]() | GetType() | Gets the current Type. (Inherited from Type.) |
![]() | HasElementTypeImpl | When overridden in a derived class, implements the HasElementType property and determines whether the current Type encompasses or refers to another type; that is, whether the current Type is an array, a pointer, or is passed by reference. (Inherited from Type.) |
![]() | InvokeMember(String, BindingFlags, Binder, Object, array<Object>) | Invokes the specified member, using the specified binding constraints and matching the specified argument list. (Inherited from Type.) |
![]() | InvokeMember(String, BindingFlags, Binder, Object, array<Object>, array<ParameterModifier>, CultureInfo, array<String>) | Not supported for incomplete generic type parameters. (Overrides Type::InvokeMember(String, BindingFlags, Binder, Object, array<Object>, array<ParameterModifier>, CultureInfo, array<String>).) |
![]() | IsArrayImpl | When overridden in a derived class, implements the IsArray property and determines whether the Type is an array. (Inherited from Type.) |
![]() | IsAssignableFrom | Not supported for incomplete generic type parameters. (Overrides Type::IsAssignableFrom(Type).) |
![]() | IsByRefImpl | When overridden in a derived class, implements the IsByRef property and determines whether the Type is passed by reference. (Inherited from Type.) |
![]() | IsCOMObjectImpl | When overridden in a derived class, implements the IsCOMObject property and determines whether the Type is a COM object. (Inherited from Type.) |
![]() | IsDefined | Not supported for incomplete generic type parameters. (Overrides MemberInfo::IsDefined(Type, Boolean).) |
![]() | IsInstanceOfType | Determines whether the specified object is an instance of the current Type. (Inherited from Type.) |
![]() | IsPointerImpl | When overridden in a derived class, implements the IsPointer property and determines whether the Type is a pointer. (Inherited from Type.) |
![]() | IsPrimitiveImpl | When overridden in a derived class, implements the IsPrimitive property and determines whether the Type is one of the primitive types. (Inherited from Type.) |
![]() | IsSubclassOf | Not supported for incomplete generic type parameters. (Overrides Type::IsSubclassOf(Type).) |
![]() | IsValueTypeImpl | Implements the IsValueType property and determines whether the Type is a value type; that is, not a class or an interface. (Inherited from Type.) |
![]() | MakeArrayType() | Returns the type of a one-dimensional array whose element type is the generic type parameter. (Overrides Type::MakeArrayType().) |
![]() | MakeArrayType(Int32) | Returns the type of an array whose element type is the generic type parameter, with the specified number of dimensions. (Overrides Type::MakeArrayType(Int32).) |
![]() | MakeByRefType | Returns a Type object that represents the current generic type parameter when passed as a reference parameter. (Overrides Type::MakeByRefType().) |
![]() | MakeGenericType | Not valid for incomplete generic type parameters. (Overrides Type::MakeGenericType(array<Type>).) |
![]() | MakePointerType | Returns a Type object that represents a pointer to the current generic type parameter. (Overrides Type::MakePointerType().) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | SetBaseTypeConstraint | Sets the base type that a type must inherit in order to be substituted for the type parameter. |
![]() | SetCustomAttribute | Set a custom attribute using a custom attribute builder. |
![]() | SetGenericParameterAttributes | Sets the variance characteristics and special constraints of the generic parameter, such as the parameterless constructor constraint. |
![]() | SetInterfaceConstraints | Sets the interfaces a type must implement in order to be substituted for the type parameter. |
![]() | ToString | Returns a string representation of the current generic type parameter. (Overrides Type::ToString().) |
You can get an array of GenericTypeParameterBuilder objects by using the TypeBuilder::DefineGenericParameters method to add type parameters to a dynamic type, thus making it a generic type, or by using the MethodBuilder::DefineGenericParameters method to add type parameters to a dynamic method. Use the GenericTypeParameterBuilder objects to add constraints to the type parameters. Constraints are of three kinds:
The base type constraint specifies that any type assigned to the generic type parameter must derive from a particular base type. Set this constraint by using the SetBaseTypeConstraint method.
An interface constraint specifies that any type assigned to the generic type parameter must implement a particular interface. Set the interface constraints by using the SetInterfaceConstraints method.
Special constraints specify that any type assigned to the generic type parameter must have a default constructor, must be a reference type, or must be a value type. Set the special constraints for a type parameter by using the SetGenericParameterAttributes method.
Interface constraints and special constraints cannot be retrieved using methods of the GenericTypeParameterBuilder class. Once you have created the generic type that contains the type parameters, you can use its Type object to reflect the constraints. Use the Type::GetGenericArguments method to get the type parameters, and for each type parameter use the Type::GetGenericParameterConstraints method to get the base type constraint and interface constraints, and the Type::GenericParameterAttributes property to get the special constraints.
The following code example creates a generic type with two type parameters. For a more detailed explanation of the steps involved in defining a dynamic generic type, see How to: Define a Generic Type with Reflection Emit.
Note: |
|---|
To run this example, see Building Examples That Use a Demo Method and a TextBlock Control. |
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
