ConstructorBuilder 类

定义

定义和表示动态类的构造函数。

public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo, System::Runtime::InteropServices::_ConstructorBuilder
public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type ConstructorBuilder = class
    inherit ConstructorInfo
    interface _ConstructorBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ConstructorBuilder = class
    inherit ConstructorInfo
    interface _ConstructorBuilder
type ConstructorBuilder = class
    inherit ConstructorInfo
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Implements _ConstructorBuilder
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
继承
属性
实现

示例

下面的代码示例演示了上下文 ConstructorBuilder用法。


using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

class TestCtorBuilder {

    public static Type DynamicPointTypeGen() {
    
       Type pointType = null;
       Type[] ctorParams = new Type[] {typeof(int),
                        typeof(int),
                        typeof(int)};
    
       AppDomain myDomain = Thread.GetDomain();
       AssemblyName myAsmName = new AssemblyName();
       myAsmName.Name = "MyDynamicAssembly";
    
       AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
                      myAsmName,
                      AssemblyBuilderAccess.RunAndSave);

       ModuleBuilder pointModule = myAsmBuilder.DefineDynamicModule("PointModule",
                                    "Point.dll");

       TypeBuilder pointTypeBld = pointModule.DefineType("Point",
                                      TypeAttributes.Public);

       FieldBuilder xField = pointTypeBld.DefineField("x", typeof(int),
                                                          FieldAttributes.Public);
       FieldBuilder yField = pointTypeBld.DefineField("y", typeof(int),
                                                          FieldAttributes.Public);
       FieldBuilder zField = pointTypeBld.DefineField("z", typeof(int),
                                                          FieldAttributes.Public);

           Type objType = Type.GetType("System.Object");
           ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);

       ConstructorBuilder pointCtor = pointTypeBld.DefineConstructor(
                      MethodAttributes.Public,
                      CallingConventions.Standard,
                      ctorParams);
       ILGenerator ctorIL = pointCtor.GetILGenerator();

       // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
       // hold the actual passed parameters. ldarg.0 is used by instance methods
       // to hold a reference to the current calling object instance. Static methods
       // do not use arg.0, since they are not instantiated and hence no reference
       // is needed to distinguish them.

           ctorIL.Emit(OpCodes.Ldarg_0);

       // Here, we wish to create an instance of System.Object by invoking its
       // constructor, as specified above.

           ctorIL.Emit(OpCodes.Call, objCtor);

       // Now, we'll load the current instance ref in arg 0, along
       // with the value of parameter "x" stored in arg 1, into stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_1);
           ctorIL.Emit(OpCodes.Stfld, xField);

       // Now, we store arg 2 "y" in the current instance with stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_2);
           ctorIL.Emit(OpCodes.Stfld, yField);

       // Last of all, arg 3 "z" gets stored in the current instance.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_3);
           ctorIL.Emit(OpCodes.Stfld, zField);

           // Our work complete, we return.

       ctorIL.Emit(OpCodes.Ret);

       // Now, let's create three very simple methods so we can see our fields.

       string[] mthdNames = new string[] {"GetX", "GetY", "GetZ"};

           foreach (string mthdName in mthdNames) {
              MethodBuilder getFieldMthd = pointTypeBld.DefineMethod(
                           mthdName,
                           MethodAttributes.Public,
                                           typeof(int),
                                           null);
          ILGenerator mthdIL = getFieldMthd.GetILGenerator();
    
          mthdIL.Emit(OpCodes.Ldarg_0);
          switch (mthdName) {
             case "GetX": mthdIL.Emit(OpCodes.Ldfld, xField);
                  break;
             case "GetY": mthdIL.Emit(OpCodes.Ldfld, yField);
                  break;
             case "GetZ": mthdIL.Emit(OpCodes.Ldfld, zField);
                  break;
          }
          mthdIL.Emit(OpCodes.Ret);
           }
       // Finally, we create the type.

       pointType = pointTypeBld.CreateType();

       // Let's save it, just for posterity.
    
       myAsmBuilder.Save("Point.dll");
    
       return pointType;
    }

    public static void Main() {
    
       Type myDynamicType = null;
           object aPoint = null;
       Type[] aPtypes = new Type[] {typeof(int), typeof(int), typeof(int)};
           object[] aPargs = new object[] {4, 5, 6};
    
       // Call the  method to build our dynamic class.

       myDynamicType = DynamicPointTypeGen();

       Console.WriteLine("Some information about my new Type '{0}':",
                  myDynamicType.FullName);
       Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly);
       Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes);
       Console.WriteLine("Module: '{0}'", myDynamicType.Module);
       Console.WriteLine("Members: ");
       foreach (MemberInfo member in myDynamicType.GetMembers()) {
        Console.WriteLine("-- {0} {1};", member.MemberType, member.Name);
       }

           Console.WriteLine("---");

       // Let's take a look at the constructor we created.

       ConstructorInfo myDTctor = myDynamicType.GetConstructor(aPtypes);
           Console.WriteLine("Constructor: {0};", myDTctor.ToString());

           Console.WriteLine("---");
    
           // Now, we get to use our dynamically-created class by invoking the constructor.

       aPoint = myDTctor.Invoke(aPargs);
           Console.WriteLine("aPoint is type {0}.", aPoint.GetType());

       // Finally, let's reflect on the instance of our new type - aPoint - and
       // make sure everything proceeded according to plan.

       Console.WriteLine("aPoint.x = {0}",
                 myDynamicType.InvokeMember("GetX",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));
       Console.WriteLine("aPoint.y = {0}",
                 myDynamicType.InvokeMember("GetY",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));
       Console.WriteLine("aPoint.z = {0}",
                 myDynamicType.InvokeMember("GetZ",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));

       // +++ OUTPUT +++
       // Some information about my new Type 'Point':
       // Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
       // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
       // Module: 'PointModule'
       // Members:
       // -- Field x;
       // -- Field y;
       // -- Field z;
           // -- Method GetHashCode;
           // -- Method Equals;
           // -- Method ToString;
           // -- Method GetType;
           // -- Constructor .ctor;
       // ---
       // Constructor: Void .ctor(Int32, Int32, Int32);
       // ---
       // aPoint is type Point.
       // aPoint.x = 4
       // aPoint.y = 5
       // aPoint.z = 6
    }
}

Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _

Class TestCtorBuilder
   
   
   Public Shared Function DynamicPointTypeGen() As Type
      
      Dim pointType As Type = Nothing
      Dim ctorParams() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      
      Dim myDomain As AppDomain = Thread.GetDomain()
      Dim myAsmName As New AssemblyName()
      myAsmName.Name = "MyDynamicAssembly"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.RunAndSave)
      
      Dim pointModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("PointModule", "Point.dll")
      
      Dim pointTypeBld As TypeBuilder = pointModule.DefineType("Point", TypeAttributes.Public)
      
      Dim xField As FieldBuilder = pointTypeBld.DefineField("x", GetType(Integer), FieldAttributes.Public)
      Dim yField As FieldBuilder = pointTypeBld.DefineField("y", GetType(Integer), FieldAttributes.Public)
      Dim zField As FieldBuilder = pointTypeBld.DefineField("z", GetType(Integer), FieldAttributes.Public)
      
      Dim objType As Type = Type.GetType("System.Object")
      Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type() {})
      
      Dim pointCtor As ConstructorBuilder = pointTypeBld.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctorParams)
      Dim ctorIL As ILGenerator = pointCtor.GetILGenerator()
      
      ' NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
      ' hold the actual passed parameters. ldarg.0 is used by instance methods
      ' to hold a reference to the current calling object instance. Static methods
      ' do not use arg.0, since they are not instantiated and hence no reference
      ' is needed to distinguish them. 
      ctorIL.Emit(OpCodes.Ldarg_0)
      
      ' Here, we wish to create an instance of System.Object by invoking its
      ' constructor, as specified above.
      ctorIL.Emit(OpCodes.Call, objCtor)
      
      ' Now, we'll load the current instance ref in arg 0, along
      ' with the value of parameter "x" stored in arg 1, into stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_1)
      ctorIL.Emit(OpCodes.Stfld, xField)
      
      ' Now, we store arg 2 "y" in the current instance with stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_2)
      ctorIL.Emit(OpCodes.Stfld, yField)
      
      ' Last of all, arg 3 "z" gets stored in the current instance.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_3)
      ctorIL.Emit(OpCodes.Stfld, zField)
      
      ' Our work complete, we return.
      ctorIL.Emit(OpCodes.Ret)
      
      ' Now, let's create three very simple methods so we can see our fields.
      Dim mthdNames() As String = {"GetX", "GetY", "GetZ"}
      
      Dim mthdName As String
      For Each mthdName In  mthdNames
         Dim getFieldMthd As MethodBuilder = pointTypeBld.DefineMethod(mthdName, MethodAttributes.Public, GetType(Integer), Nothing)
         Dim mthdIL As ILGenerator = getFieldMthd.GetILGenerator()
         
         mthdIL.Emit(OpCodes.Ldarg_0)
         Select Case mthdName
            Case "GetX"
               mthdIL.Emit(OpCodes.Ldfld, xField)
            Case "GetY"
               mthdIL.Emit(OpCodes.Ldfld, yField)
            Case "GetZ"
               mthdIL.Emit(OpCodes.Ldfld, zField)
         End Select
         
         mthdIL.Emit(OpCodes.Ret)
      Next mthdName 
      ' Finally, we create the type.
      pointType = pointTypeBld.CreateType()
      
      ' Let's save it, just for posterity.
      myAsmBuilder.Save("Point.dll")
      
      Return pointType
   End Function 'DynamicPointTypeGen
    
   
   Public Shared Sub Main()
      
      Dim myDynamicType As Type = Nothing
      Dim aPoint As Object = Nothing
      Dim aPtypes() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      Dim aPargs() As Object = {4, 5, 6}
      
      ' Call the  method to build our dynamic class.
      myDynamicType = DynamicPointTypeGen()
      
      Console.WriteLine("Some information about my new Type '{0}':", myDynamicType.FullName)
      Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly)
      Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes)
      Console.WriteLine("Module: '{0}'", myDynamicType.Module)
      Console.WriteLine("Members: ")
      Dim member As MemberInfo
      For Each member In  myDynamicType.GetMembers()
         Console.WriteLine("-- {0} {1};", member.MemberType, member.Name)
      Next member
      
      Console.WriteLine("---")
      
      ' Let's take a look at the constructor we created.
      Dim myDTctor As ConstructorInfo = myDynamicType.GetConstructor(aPtypes)
      Console.WriteLine("Constructor: {0};", myDTctor.ToString())
      
      Console.WriteLine("---")
      
      ' Now, we get to use our dynamically-created class by invoking the constructor. 
      aPoint = myDTctor.Invoke(aPargs)
      Console.WriteLine("aPoint is type {0}.", aPoint.GetType())
      
      
      ' Finally, let's reflect on the instance of our new type - aPoint - and
      ' make sure everything proceeded according to plan.
      Console.WriteLine("aPoint.x = {0}", myDynamicType.InvokeMember("GetX", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.y = {0}", myDynamicType.InvokeMember("GetY", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.z = {0}", myDynamicType.InvokeMember("GetZ", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
   End Sub
End Class



' +++ OUTPUT +++
' Some information about my new Type 'Point':
' Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
' Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
' Module: 'PointModule'
' Members: 
' -- Field x;
' -- Field y;
' -- Field z;
' -- Method GetHashCode;
' -- Method Equals;
' -- Method ToString;
' -- Method GetType;
' -- Constructor .ctor;
' ---
' Constructor: Void .ctor(Int32, Int32, Int32);
' ---
' aPoint is type Point.
' aPoint.x = 4
' aPoint.y = 5
' aPoint.z = 6

注解

ConstructorBuilder用于完全描述 Microsoft中间语言(MSIL)中的构造函数,包括名称、属性、签名和构造函数正文。 它与类一起使用 TypeBuilder ,用于在运行时创建类。 调用 DefineConstructor 以获取 . 的 ConstructorBuilder实例。

如果未为动态类型定义构造函数,则会自动提供无参数构造函数,并调用基类的无参数构造函数。

如果用于 ConstructorBuilder 为动态类型定义构造函数,则不提供无参数构造函数。 除了定义的构造函数之外,还可以使用以下选项来提供无参数构造函数:

  • 如果想要仅调用基类的无参数构造函数的无参数构造函数,可以使用 TypeBuilder.DefineDefaultConstructor 该方法创建一个(并选择性地限制对它的访问)。 不为此无参数构造函数提供实现。 如果这样做,尝试使用构造函数时将引发异常。 调用方法时 TypeBuilder.CreateType 不会引发异常。

  • 如果想要一个无参数构造函数,其执行操作不仅仅是调用基类的无参数构造函数,或者调用基类的另一个构造函数,或者完全执行其他操作,则必须使用 TypeBuilder.DefineConstructor 该方法创建一个 ConstructorBuilder,并提供你自己的实现。

属性

名称 说明
Attributes

获取此构造函数的属性。

CallingConvention

获取一个 CallingConventions 值,该值取决于声明类型是否为泛型。

CallingConvention

获取一个值,该值指示此方法的调用约定。

(继承自 MethodBase)
ContainsGenericParameters

获取一个值,该值指示泛型方法是否包含未分配的泛型类型参数。

(继承自 MethodBase)
CustomAttributes

获取包含此成员的自定义属性的集合。

(继承自 MemberInfo)
DeclaringType

获取对 Type 声明此成员的类型对象的引用。

InitLocals

获取或设置此构造函数中的局部变量是否应为零初始化。

IsAbstract

获取一个值,该值指示该方法是否为抽象方法。

(继承自 MethodBase)
IsAssembly

获取一个值,该值指示此方法或构造函数的潜在可见性是否由 Assembly该方法或构造函数描述;也就是说,该方法或构造函数对同一程序集中的其他类型最多可见,并且对程序集外部的派生类型不可见。

(继承自 MethodBase)
IsConstructedGenericMethod

定义和表示动态类的构造函数。

(继承自 MethodBase)
IsConstructor

获取一个值,该值指示该方法是否为构造函数。

(继承自 MethodBase)
IsFamily

获取一个值,该值指示此方法或构造函数的可见性是否由 Family该方法或构造函数描述;也就是说,该方法或构造函数仅在其类和派生类中可见。

(继承自 MethodBase)
IsFamilyAndAssembly

获取一个值,该值指示此方法或构造函数的可见性是否由 FamANDAssem;也就是说,方法或构造函数可由派生类调用,但前提是它们位于同一程序集中。

(继承自 MethodBase)
IsFamilyOrAssembly

获取一个值,该值指示此方法或构造函数的潜在可见性是否由 FamORAssem;也就是说,无论它们位于何处,都可以由派生类和同一程序集中的类调用该方法或构造函数。

(继承自 MethodBase)
IsFinal

获取一个值,该值指示此方法是否为 final

(继承自 MethodBase)
IsGenericMethod

获取一个值,该值指示该方法是否为泛型方法。

(继承自 MethodBase)
IsGenericMethodDefinition

获取一个值,该值指示该方法是否为泛型方法定义。

(继承自 MethodBase)
IsHideBySig

获取一个值,该值指示在派生类中是否仅隐藏具有相同签名的同一类型的成员。

(继承自 MethodBase)
IsPrivate

获取一个值,该值指示此成员是否为私有成员。

(继承自 MethodBase)
IsPublic

获取一个值,该值指示这是否为公共方法。

(继承自 MethodBase)
IsSecurityCritical

获取一个值,该值指示当前方法或构造函数在当前信任级别是安全关键型还是安全安全关键型,因此可以执行关键操作。

(继承自 MethodBase)
IsSecuritySafeCritical

获取一个值,该值指示当前方法或构造函数在当前信任级别是安全安全关键;也就是说,它是否可以执行关键操作,并且可以通过透明代码访问。

(继承自 MethodBase)
IsSecurityTransparent

获取一个值,该值指示当前方法或构造函数在当前信任级别是否透明,因此无法执行关键操作。

(继承自 MethodBase)
IsSpecialName

获取一个值,该值指示此方法是否具有特殊名称。

(继承自 MethodBase)
IsStatic

获取一个值,该值指示方法是否为 static

(继承自 MethodBase)
IsVirtual

获取一个值,该值指示方法是否为 virtual

(继承自 MethodBase)
MemberType

获取一个 MemberTypes 值,该值指示此成员是构造函数。

(继承自 ConstructorInfo)
MetadataToken

获取标识元数据元素的值。

(继承自 MemberInfo)
MethodHandle

获取方法的内部句柄。 使用此句柄访问基础元数据句柄。

MethodImplementationFlags

MethodImplAttributes获取指定方法实现的属性的标志。

(继承自 MethodBase)
Module

获取在其中定义此构造函数的动态模块。

Name

检索此构造函数的名称。

ReflectedType

保存对 Type 从中获取此对象的对象的引用。

ReturnType
已过时.

获取 null

Signature

检索字符串形式的字段的签名。

方法

名称 说明
AddDeclarativeSecurity(SecurityAction, PermissionSet)

向此构造函数添加声明性安全性。

DefineParameter(Int32, ParameterAttributes, String)

定义此构造函数的参数。

Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 ConstructorInfo)
GetCustomAttributes(Boolean)

返回为此构造函数定义的所有自定义属性。

GetCustomAttributes(Type, Boolean)

返回由给定类型标识的自定义属性。

GetCustomAttributesData()

返回一个对象列表,该列表 CustomAttributeData 表示已应用于目标成员的属性的相关数据。

(继承自 MemberInfo)
GetGenericArguments()

返回表示泛型方法的类型参数或泛型方法定义的类型参数的对象数组 Type

(继承自 MethodBase)
GetHashCode()

返回此实例的哈希代码。

(继承自 ConstructorInfo)
GetILGenerator()

获取此构造函数的一个 ILGenerator

GetILGenerator(Int32)

ILGenerator获取具有指定 MSIL 流大小的对象,该对象可用于为此构造函数生成方法正文。

GetMethodBody()

在派生类中重写时,获取一个 MethodBody 对象,该对象提供对当前方法的 MSIL 流、局部变量和异常的访问权限。

(继承自 MethodBase)
GetMethodImplementationFlags()

返回此构造函数的方法实现标志。

GetModule()

返回对包含此构造函数的模块的引用。

GetParameters()

返回此构造函数的参数。

GetToken()

返回表示 MethodToken 此构造函数的标记。

GetType()

发现类构造函数的属性,并提供对构造函数元数据的访问权限。

(继承自 ConstructorInfo)
HasSameMetadataDefinitionAs(MemberInfo)

定义和表示动态类的构造函数。

(继承自 MemberInfo)
Invoke(BindingFlags, Binder, Object[], CultureInfo)

在给定对象上动态调用此实例表示的构造函数,并沿指定参数传递,并在给定绑定器的约束下传递。

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

在指定的 Binder约束下,使用指定参数动态调用此实例反映的构造函数。

Invoke(Object, Object[])

使用指定的参数调用由当前实例表示的方法或构造函数。

(继承自 MethodBase)
Invoke(Object[])

调用具有指定参数的实例反映的构造函数,为不常用的参数提供默认值。

(继承自 ConstructorInfo)
IsDefined(Type, Boolean)

检查是否定义了指定的自定义属性类型。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
SetCustomAttribute(ConstructorInfo, Byte[])

使用指定的自定义属性 blob 设置自定义属性。

SetCustomAttribute(CustomAttributeBuilder)

使用自定义属性生成器设置自定义属性。

SetImplementationFlags(MethodImplAttributes)

设置此构造函数的方法实现标志。

SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>)

使用Microsoft中间语言(MSIL)指令的指定字节数组创建构造函数的正文。

SetSymCustomAttribute(String, Byte[])

设置与此构造函数的自定义属性关联的符号信息。

ToString()

以 . 的形式String返回此ConstructorBuilder实例。

显式接口实现

名称 说明
_ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

_ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

_ConstructorBuilder.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

_ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

_ConstructorInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 ConstructorInfo)
_ConstructorInfo.GetType()

获取表示 Type 类型的 ConstructorInfo 对象。

(继承自 ConstructorInfo)
_ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 ConstructorInfo)
_ConstructorInfo.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 ConstructorInfo)
_ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo)

为 COM 对象提供与版本无关的访问 Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) 方法。

(继承自 ConstructorInfo)
_ConstructorInfo.Invoke_3(Object, Object[])

为 COM 对象提供与版本无关的访问 Invoke(Object, Object[]) 方法。

(继承自 ConstructorInfo)
_ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo)

为 COM 对象提供与版本无关的访问 Invoke(BindingFlags, Binder, Object[], CultureInfo) 方法。

(继承自 ConstructorInfo)
_ConstructorInfo.Invoke_5(Object[])

为 COM 对象提供与版本无关的访问 Invoke(Object[]) 方法。

(继承自 ConstructorInfo)
_ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 ConstructorInfo)
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 MemberInfo)
_MemberInfo.GetType()

获取表示TypeMemberInfo类的对象。

(继承自 MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 MethodBase)
_MethodBase.GetType()

有关此成员的说明,请参阅 GetType()

(继承自 MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 MethodBase)
_MethodBase.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 MethodBase)
_MethodBase.IsAbstract

有关此成员的说明,请参阅 IsAbstract

(继承自 MethodBase)
_MethodBase.IsAssembly

有关此成员的说明,请参阅 IsAssembly

(继承自 MethodBase)
_MethodBase.IsConstructor

有关此成员的说明,请参阅 IsConstructor

(继承自 MethodBase)
_MethodBase.IsFamily

有关此成员的说明,请参阅 IsFamily

(继承自 MethodBase)
_MethodBase.IsFamilyAndAssembly

有关此成员的说明,请参阅 IsFamilyAndAssembly

(继承自 MethodBase)
_MethodBase.IsFamilyOrAssembly

有关此成员的说明,请参阅 IsFamilyOrAssembly

(继承自 MethodBase)
_MethodBase.IsFinal

有关此成员的说明,请参阅 IsFinal

(继承自 MethodBase)
_MethodBase.IsHideBySig

有关此成员的说明,请参阅 IsHideBySig

(继承自 MethodBase)
_MethodBase.IsPrivate

有关此成员的说明,请参阅 IsPrivate

(继承自 MethodBase)
_MethodBase.IsPublic

有关此成员的说明,请参阅 IsPublic

(继承自 MethodBase)
_MethodBase.IsSpecialName

有关此成员的说明,请参阅 IsSpecialName

(继承自 MethodBase)
_MethodBase.IsStatic

有关此成员的说明,请参阅 IsStatic

(继承自 MethodBase)
_MethodBase.IsVirtual

有关此成员的说明,请参阅 IsVirtual

(继承自 MethodBase)

扩展方法

名称 说明
GetCustomAttribute(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义属性,并选择性地检查该成员的上级。

GetCustomAttribute(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义属性。

GetCustomAttribute<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义属性,并选择性地检查该成员的上级。

GetCustomAttribute<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义属性。

GetCustomAttributes(MemberInfo, Boolean)

检索应用于指定成员的自定义属性的集合,并选择性地检查该成员的上级。

GetCustomAttributes(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义属性集合,并选择性地检查该成员的上级。

GetCustomAttributes(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义属性集合。

GetCustomAttributes(MemberInfo)

检索应用于指定成员的自定义属性的集合。

GetCustomAttributes<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义属性集合,并选择性地检查该成员的上级。

GetCustomAttributes<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义属性集合。

IsDefined(MemberInfo, Type, Boolean)

指示指定类型的自定义属性是否应用于指定成员,以及(可选)应用于其上级。

IsDefined(MemberInfo, Type)

指示指定类型的自定义属性是否应用于指定成员。

适用于