TypeBuilder Classe

Definizione

Definisce e crea nuove istanze di classi durante l'esecuzione.

public ref class TypeBuilder sealed : Type, System::Runtime::InteropServices::_TypeBuilder
public ref class TypeBuilder sealed : System::Reflection::TypeInfo, System::Runtime::InteropServices::_TypeBuilder
public ref class TypeBuilder sealed : Type
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class TypeBuilder : Type, System.Runtime.InteropServices._TypeBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class TypeBuilder : Type, System.Runtime.InteropServices._TypeBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class TypeBuilder : System.Reflection.TypeInfo, System.Runtime.InteropServices._TypeBuilder
public sealed class TypeBuilder : Type
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type TypeBuilder = class
    inherit Type
    interface _TypeBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type TypeBuilder = class
    inherit Type
    interface _TypeBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type TypeBuilder = class
    inherit TypeInfo
    interface _TypeBuilder
type TypeBuilder = class
    inherit Type
Public NotInheritable Class TypeBuilder
Inherits Type
Implements _TypeBuilder
Public NotInheritable Class TypeBuilder
Inherits TypeInfo
Implements _TypeBuilder
Public NotInheritable Class TypeBuilder
Inherits Type
Ereditarietà
TypeBuilder
Ereditarietà
Attributi
Implementazioni

Esempio

Nell'esempio di codice seguente viene illustrato come definire e usare un assembly dinamico. L'assembly di esempio contiene un tipo, MyDynamicType, con un campo privato, una proprietà che ottiene e imposta il campo privato, i costruttori che inizializzano il campo privato e un metodo che moltiplica un numero fornito dall'utente per il valore del campo privato e restituisce il risultato.

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

class DemoAssemblyBuilder
{
    public static void Main()
    {
        // This code creates an assembly that contains one type,
        // named "MyDynamicType", that has a private field, a property
        // that gets and sets the private field, constructors that
        // initialize the private field, and a method that multiplies
        // a user-supplied number by the private field value and returns
        // the result. In C# the type might look like this:
        /*
        public class MyDynamicType
        {
            private int m_number;

            public MyDynamicType() : this(42) {}
            public MyDynamicType(int initNumber)
            {
                m_number = initNumber;
            }

            public int Number
            {
                get { return m_number; }
                set { m_number = value; }
            }

            public int MyMethod(int multiplier)
            {
                return m_number * multiplier;
            }
        }
        */

        var aName = new AssemblyName("DynamicAssemblyExample");
        AssemblyBuilder ab =
            AssemblyBuilder.DefineDynamicAssembly(
                aName,
                AssemblyBuilderAccess.Run);

        // The module name is usually the same as the assembly name.
        ModuleBuilder mb = ab.DefineDynamicModule(aName.Name ?? "DynamicAssemblyExample");

        TypeBuilder tb = mb.DefineType(
            "MyDynamicType",
             TypeAttributes.Public);

        // Add a private field of type int (Int32).
        FieldBuilder fbNumber = tb.DefineField(
            "m_number",
            typeof(int),
            FieldAttributes.Private);

        // Define a constructor that takes an integer argument and
        // stores it in the private field.
        Type[] parameterTypes = { typeof(int) };
        ConstructorBuilder ctor1 = tb.DefineConstructor(
            MethodAttributes.Public,
            CallingConventions.Standard,
            parameterTypes);

        ILGenerator ctor1IL = ctor1.GetILGenerator();
        // For a constructor, argument zero is a reference to the new
        // instance. Push it on the stack before calling the base
        // class constructor. Specify the default constructor of the
        // base class (System.Object) by passing an empty array of
        // types (Type.EmptyTypes) to GetConstructor.
        ctor1IL.Emit(OpCodes.Ldarg_0);
        ConstructorInfo? ci = typeof(object).GetConstructor(Type.EmptyTypes);
        ctor1IL.Emit(OpCodes.Call, ci!);
        // Push the instance on the stack before pushing the argument
        // that is to be assigned to the private field m_number.
        ctor1IL.Emit(OpCodes.Ldarg_0);
        ctor1IL.Emit(OpCodes.Ldarg_1);
        ctor1IL.Emit(OpCodes.Stfld, fbNumber);
        ctor1IL.Emit(OpCodes.Ret);

        // Define a default constructor that supplies a default value
        // for the private field. For parameter types, pass the empty
        // array of types or pass null.
        ConstructorBuilder ctor0 = tb.DefineConstructor(
            MethodAttributes.Public,
            CallingConventions.Standard,
            Type.EmptyTypes);

        ILGenerator ctor0IL = ctor0.GetILGenerator();
        // For a constructor, argument zero is a reference to the new
        // instance. Push it on the stack before pushing the default
        // value on the stack, then call constructor ctor1.
        ctor0IL.Emit(OpCodes.Ldarg_0);
        ctor0IL.Emit(OpCodes.Ldc_I4_S, 42);
        ctor0IL.Emit(OpCodes.Call, ctor1);
        ctor0IL.Emit(OpCodes.Ret);

        // Define a property named Number that gets and sets the private
        // field.
        //
        // The last argument of DefineProperty is null, because the
        // property has no parameters. (If you don't specify null, you must
        // specify an array of Type objects. For a parameterless property,
        // use the built-in array with no elements: Type.EmptyTypes)
        PropertyBuilder pbNumber = tb.DefineProperty(
            "Number",
            PropertyAttributes.HasDefault,
            typeof(int),
            null);

        // The property "set" and property "get" methods require a special
        // set of attributes.
        MethodAttributes getSetAttr = MethodAttributes.Public |
            MethodAttributes.SpecialName | MethodAttributes.HideBySig;

        // Define the "get" accessor method for Number. The method returns
        // an integer and has no arguments. (Note that null could be
        // used instead of Types.EmptyTypes)
        MethodBuilder mbNumberGetAccessor = tb.DefineMethod(
            "get_Number",
            getSetAttr,
            typeof(int),
            Type.EmptyTypes);

        ILGenerator numberGetIL = mbNumberGetAccessor.GetILGenerator();
        // For an instance property, argument zero is the instance. Load the
        // instance, then load the private field and return, leaving the
        // field value on the stack.
        numberGetIL.Emit(OpCodes.Ldarg_0);
        numberGetIL.Emit(OpCodes.Ldfld, fbNumber);
        numberGetIL.Emit(OpCodes.Ret);

        // Define the "set" accessor method for Number, which has no return
        // type and takes one argument of type int (Int32).
        MethodBuilder mbNumberSetAccessor = tb.DefineMethod(
            "set_Number",
            getSetAttr,
            null,
            new Type[] { typeof(int) });

        ILGenerator numberSetIL = mbNumberSetAccessor.GetILGenerator();
        // Load the instance and then the numeric argument, then store the
        // argument in the field.
        numberSetIL.Emit(OpCodes.Ldarg_0);
        numberSetIL.Emit(OpCodes.Ldarg_1);
        numberSetIL.Emit(OpCodes.Stfld, fbNumber);
        numberSetIL.Emit(OpCodes.Ret);

        // Last, map the "get" and "set" accessor methods to the
        // PropertyBuilder. The property is now complete.
        pbNumber.SetGetMethod(mbNumberGetAccessor);
        pbNumber.SetSetMethod(mbNumberSetAccessor);

        // Define a method that accepts an integer argument and returns
        // the product of that integer and the private field m_number. This
        // time, the array of parameter types is created on the fly.
        MethodBuilder meth = tb.DefineMethod(
            "MyMethod",
            MethodAttributes.Public,
            typeof(int),
            new Type[] { typeof(int) });

        ILGenerator methIL = meth.GetILGenerator();
        // To retrieve the private instance field, load the instance it
        // belongs to (argument zero). After loading the field, load the
        // argument one and then multiply. Return from the method with
        // the return value (the product of the two numbers) on the
        // execution stack.
        methIL.Emit(OpCodes.Ldarg_0);
        methIL.Emit(OpCodes.Ldfld, fbNumber);
        methIL.Emit(OpCodes.Ldarg_1);
        methIL.Emit(OpCodes.Mul);
        methIL.Emit(OpCodes.Ret);

        // Finish the type.
        Type? t = tb.CreateType();

        // Because AssemblyBuilderAccess includes Run, the code can be
        // executed immediately. Start by getting reflection objects for
        // the method and the property.
        MethodInfo? mi = t?.GetMethod("MyMethod");
        PropertyInfo? pi = t?.GetProperty("Number");

        // Create an instance of MyDynamicType using the default
        // constructor.
        object? o1 = null;
        if (t is not null)
            o1 = Activator.CreateInstance(t);

        // Display the value of the property, then change it to 127 and
        // display it again. Use null to indicate that the property
        // has no index.
        Console.WriteLine("o1.Number: {0}", pi?.GetValue(o1, null));
        pi?.SetValue(o1, 127, null);
        Console.WriteLine("o1.Number: {0}", pi?.GetValue(o1, null));

        // Call MyMethod, passing 22, and display the return value, 22
        // times 127. Arguments must be passed as an array, even when
        // there is only one.
        object[] arguments = { 22 };
        Console.WriteLine("o1.MyMethod(22): {0}",
            mi?.Invoke(o1, arguments));

        // Create an instance of MyDynamicType using the constructor
        // that specifies m_Number. The constructor is identified by
        // matching the types in the argument array. In this case,
        // the argument array is created on the fly. Display the
        // property value.
        object? o2 = null;
        if (t is not null)
            o2 = Activator.CreateInstance(t, new object[] { 5280 });
        Console.WriteLine("o2.Number: {0}", pi?.GetValue(o2, null));
    }
}

/* This code produces the following output:

o1.Number: 42
o1.Number: 127
o1.MyMethod(22): 2794
o2.Number: 5280
 */
Imports System.Reflection
Imports System.Reflection.Emit

Class DemoAssemblyBuilder

    Public Shared Sub Main()

        ' This code creates an assembly that contains one type,
        ' named "MyDynamicType", that has a private field, a property
        ' that gets and sets the private field, constructors that
        ' initialize the private field, and a method that multiplies
        ' a user-supplied number by the private field value and returns
        ' the result. The code might look like this in Visual Basic:
        '
        'Public Class MyDynamicType
        '    Private m_number As Integer
        '
        '    Public Sub New()
        '        Me.New(42)
        '    End Sub
        '
        '    Public Sub New(ByVal initNumber As Integer)
        '        m_number = initNumber
        '    End Sub
        '
        '    Public Property Number As Integer
        '        Get
        '            Return m_number
        '        End Get
        '        Set
        '            m_Number = Value
        '        End Set
        '    End Property
        '
        '    Public Function MyMethod(ByVal multiplier As Integer) As Integer
        '        Return m_Number * multiplier
        '    End Function
        'End Class
      
        Dim aName As New AssemblyName("DynamicAssemblyExample")
        Dim ab As AssemblyBuilder = _
            AssemblyBuilder.DefineDynamicAssembly( _
                aName, _
                AssemblyBuilderAccess.Run)

        ' The module name is usually the same as the assembly name.
        Dim mb As ModuleBuilder = ab.DefineDynamicModule( _
            aName.Name)
      
        Dim tb As TypeBuilder = _
            mb.DefineType("MyDynamicType", TypeAttributes.Public)

        ' Add a private field of type Integer (Int32).
        Dim fbNumber As FieldBuilder = tb.DefineField( _
            "m_number", _
            GetType(Integer), _
            FieldAttributes.Private)

        ' Define a constructor that takes an integer argument and 
        ' stores it in the private field. 
        Dim parameterTypes() As Type = { GetType(Integer) }
        Dim ctor1 As ConstructorBuilder = _
            tb.DefineConstructor( _
                MethodAttributes.Public, _
                CallingConventions.Standard, _
                parameterTypes)

        Dim ctor1IL As ILGenerator = ctor1.GetILGenerator()
        ' For a constructor, argument zero is a reference to the new
        ' instance. Push it on the stack before calling the base
        ' class constructor. Specify the default constructor of the 
        ' base class (System.Object) by passing an empty array of 
        ' types (Type.EmptyTypes) to GetConstructor.
        ctor1IL.Emit(OpCodes.Ldarg_0)
        ctor1IL.Emit(OpCodes.Call, _
            GetType(Object).GetConstructor(Type.EmptyTypes))
        ' Push the instance on the stack before pushing the argument
        ' that is to be assigned to the private field m_number.
        ctor1IL.Emit(OpCodes.Ldarg_0)
        ctor1IL.Emit(OpCodes.Ldarg_1)
        ctor1IL.Emit(OpCodes.Stfld, fbNumber)
        ctor1IL.Emit(OpCodes.Ret)

        ' Define a default constructor that supplies a default value
        ' for the private field. For parameter types, pass the empty
        ' array of types or pass Nothing.
        Dim ctor0 As ConstructorBuilder = tb.DefineConstructor( _
            MethodAttributes.Public, _
            CallingConventions.Standard, _
            Type.EmptyTypes)

        Dim ctor0IL As ILGenerator = ctor0.GetILGenerator()
        ' For a constructor, argument zero is a reference to the new
        ' instance. Push it on the stack before pushing the default
        ' value on the stack, then call constructor ctor1.
        ctor0IL.Emit(OpCodes.Ldarg_0)
        ctor0IL.Emit(OpCodes.Ldc_I4_S, 42)
        ctor0IL.Emit(OpCodes.Call, ctor1)
        ctor0IL.Emit(OpCodes.Ret)

        ' Define a property named Number that gets and sets the private 
        ' field.
        '
        ' The last argument of DefineProperty is Nothing, because the
        ' property has no parameters. (If you don't specify Nothing, you must
        ' specify an array of Type objects. For a parameterless property,
        ' use the built-in array with no elements: Type.EmptyTypes)
        Dim pbNumber As PropertyBuilder = tb.DefineProperty( _
            "Number", _
            PropertyAttributes.HasDefault, _
            GetType(Integer), _
            Nothing)
      
        ' The property Set and property Get methods require a special
        ' set of attributes.
        Dim getSetAttr As MethodAttributes = _
            MethodAttributes.Public Or MethodAttributes.SpecialName _
                Or MethodAttributes.HideBySig

        ' Define the "get" accessor method for Number. The method returns
        ' an integer and has no arguments. (Note that Nothing could be 
        ' used instead of Types.EmptyTypes)
        Dim mbNumberGetAccessor As MethodBuilder = tb.DefineMethod( _
            "get_Number", _
            getSetAttr, _
            GetType(Integer), _
            Type.EmptyTypes)
      
        Dim numberGetIL As ILGenerator = mbNumberGetAccessor.GetILGenerator()
        ' For an instance property, argument zero is the instance. Load the 
        ' instance, then load the private field and return, leaving the
        ' field value on the stack.
        numberGetIL.Emit(OpCodes.Ldarg_0)
        numberGetIL.Emit(OpCodes.Ldfld, fbNumber)
        numberGetIL.Emit(OpCodes.Ret)
        
        ' Define the "set" accessor method for Number, which has no return
        ' type and takes one argument of type Integer (Int32).
        Dim mbNumberSetAccessor As MethodBuilder = _
            tb.DefineMethod( _
                "set_Number", _
                getSetAttr, _
                Nothing, _
                New Type() { GetType(Integer) })
      
        Dim numberSetIL As ILGenerator = mbNumberSetAccessor.GetILGenerator()
        ' Load the instance and then the numeric argument, then store the
        ' argument in the field.
        numberSetIL.Emit(OpCodes.Ldarg_0)
        numberSetIL.Emit(OpCodes.Ldarg_1)
        numberSetIL.Emit(OpCodes.Stfld, fbNumber)
        numberSetIL.Emit(OpCodes.Ret)
      
        ' Last, map the "get" and "set" accessor methods to the 
        ' PropertyBuilder. The property is now complete. 
        pbNumber.SetGetMethod(mbNumberGetAccessor)
        pbNumber.SetSetMethod(mbNumberSetAccessor)

        ' Define a method that accepts an integer argument and returns
        ' the product of that integer and the private field m_number. This
        ' time, the array of parameter types is created on the fly.
        Dim meth As MethodBuilder = tb.DefineMethod( _
            "MyMethod", _
            MethodAttributes.Public, _
            GetType(Integer), _
            New Type() { GetType(Integer) })

        Dim methIL As ILGenerator = meth.GetILGenerator()
        ' To retrieve the private instance field, load the instance it
        ' belongs to (argument zero). After loading the field, load the 
        ' argument one and then multiply. Return from the method with 
        ' the return value (the product of the two numbers) on the 
        ' execution stack.
        methIL.Emit(OpCodes.Ldarg_0)
        methIL.Emit(OpCodes.Ldfld, fbNumber)
        methIL.Emit(OpCodes.Ldarg_1)
        methIL.Emit(OpCodes.Mul)
        methIL.Emit(OpCodes.Ret)

        ' Finish the type.
        Dim t As Type = tb.CreateType()

        ' Because AssemblyBuilderAccess includes Run, the code can be
        ' executed immediately. Start by getting reflection objects for
        ' the method and the property.
        Dim mi As MethodInfo = t.GetMethod("MyMethod")
        Dim pi As PropertyInfo = t.GetProperty("Number")
  
        ' Create an instance of MyDynamicType using the default 
        ' constructor. 
        Dim o1 As Object = Activator.CreateInstance(t)

        ' Display the value of the property, then change it to 127 and 
        ' display it again. Use Nothing to indicate that the property
        ' has no index.
        Console.WriteLine("o1.Number: {0}", pi.GetValue(o1, Nothing))
        pi.SetValue(o1, 127, Nothing)
        Console.WriteLine("o1.Number: {0}", pi.GetValue(o1, Nothing))

        ' Call MyMethod, passing 22, and display the return value, 22
        ' times 127. Arguments must be passed as an array, even when
        ' there is only one.
        Dim arguments() As Object = { 22 }
        Console.WriteLine("o1.MyMethod(22): {0}", _
            mi.Invoke(o1, arguments))

        ' Create an instance of MyDynamicType using the constructor
        ' that specifies m_Number. The constructor is identified by
        ' matching the types in the argument array. In this case, 
        ' the argument array is created on the fly. Display the 
        ' property value.
        Dim o2 As Object = Activator.CreateInstance(t, _
            New Object() { 5280 })
        Console.WriteLine("o2.Number: {0}", pi.GetValue(o2, Nothing))
      
    End Sub  
End Class

' This code produces the following output:
'
'o1.Number: 42
'o1.Number: 127
'o1.MyMethod(22): 2794
'o2.Number: 5280

Nell'esempio di codice seguente viene illustrato come compilare un tipo in modo dinamico usando TypeBuilder.

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

class TestILGenerator
{
    public static Type DynamicDotProductGen()
    {
       Type ivType = null;
       Type[] ctorParams = new Type[] { typeof(int),
                                typeof(int),
                        typeof(int)};
    
       AppDomain myDomain = Thread.GetDomain();
       AssemblyName myAsmName = new AssemblyName();
       myAsmName.Name = "IntVectorAsm";
    
       AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
                      myAsmName,
                      AssemblyBuilderAccess.RunAndSave);

       ModuleBuilder IntVectorModule = myAsmBuilder.DefineDynamicModule("IntVectorModule",
                                        "Vector.dll");

       TypeBuilder ivTypeBld = IntVectorModule.DefineType("IntVector",
                                      TypeAttributes.Public);

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

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

       ConstructorBuilder ivCtor = ivTypeBld.DefineConstructor(
                      MethodAttributes.Public,
                      CallingConventions.Standard,
                      ctorParams);
       ILGenerator ctorIL = ivCtor.GetILGenerator();
           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Call, objCtor);
           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_1);
           ctorIL.Emit(OpCodes.Stfld, xField);
           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_2);
           ctorIL.Emit(OpCodes.Stfld, yField);
           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_3);
           ctorIL.Emit(OpCodes.Stfld, zField);
       ctorIL.Emit(OpCodes.Ret);

       // This method will find the dot product of the stored vector
       // with another.

       Type[] dpParams = new Type[] { ivTypeBld };

           // Here, you create a MethodBuilder containing the
       // name, the attributes (public, static, private, and so on),
       // the return type (int, in this case), and a array of Type
       // indicating the type of each parameter. Since the sole parameter
       // is a IntVector, the very class you're creating, you will
       // pass in the TypeBuilder (which is derived from Type) instead of
       // a Type object for IntVector, avoiding an exception.

       // -- This method would be declared in C# as:
       //    public int DotProduct(IntVector aVector)

           MethodBuilder dotProductMthd = ivTypeBld.DefineMethod(
                                  "DotProduct",
                          MethodAttributes.Public,
                                          typeof(int),
                                          dpParams);

       // A ILGenerator can now be spawned, attached to the MethodBuilder.

       ILGenerator mthdIL = dotProductMthd.GetILGenerator();
    
       // Here's the body of our function, in MSIL form. We're going to find the
       // "dot product" of the current vector instance with the passed vector
       // instance. For reference purposes, the equation is:
       // (x1 * x2) + (y1 * y2) + (z1 * z2) = the dot product

       // First, you'll load the reference to the current instance "this"
       // stored in argument 0 (ldarg.0) onto the stack. Ldfld, the subsequent
       // instruction, will pop the reference off the stack and look up the
       // field "x", specified by the FieldInfo token "xField".

       mthdIL.Emit(OpCodes.Ldarg_0);
       mthdIL.Emit(OpCodes.Ldfld, xField);

       // That completed, the value stored at field "x" is now atop the stack.
       // Now, you'll do the same for the object reference we passed as a
       // parameter, stored in argument 1 (ldarg.1). After Ldfld executed,
       // you'll have the value stored in field "x" for the passed instance
       // atop the stack.

       mthdIL.Emit(OpCodes.Ldarg_1);
       mthdIL.Emit(OpCodes.Ldfld, xField);

           // There will now be two values atop the stack - the "x" value for the
       // current vector instance, and the "x" value for the passed instance.
       // You'll now multiply them, and push the result onto the evaluation stack.

       mthdIL.Emit(OpCodes.Mul_Ovf_Un);

       // Now, repeat this for the "y" fields of both vectors.

       mthdIL.Emit(OpCodes.Ldarg_0);
       mthdIL.Emit(OpCodes.Ldfld, yField);
       mthdIL.Emit(OpCodes.Ldarg_1);
       mthdIL.Emit(OpCodes.Ldfld, yField);
       mthdIL.Emit(OpCodes.Mul_Ovf_Un);

       // At this time, the results of both multiplications should be atop
       // the stack. You'll now add them and push the result onto the stack.

       mthdIL.Emit(OpCodes.Add_Ovf_Un);

       // Multiply both "z" field and push the result onto the stack.
       mthdIL.Emit(OpCodes.Ldarg_0);
       mthdIL.Emit(OpCodes.Ldfld, zField);
       mthdIL.Emit(OpCodes.Ldarg_1);
       mthdIL.Emit(OpCodes.Ldfld, zField);
       mthdIL.Emit(OpCodes.Mul_Ovf_Un);

       // Finally, add the result of multiplying the "z" fields with the
       // result of the earlier addition, and push the result - the dot product -
       // onto the stack.
       mthdIL.Emit(OpCodes.Add_Ovf_Un);

       // The "ret" opcode will pop the last value from the stack and return it
       // to the calling method. You're all done!

       mthdIL.Emit(OpCodes.Ret);

       ivType = ivTypeBld.CreateType();

       return ivType;
    }

    public static void Main() {
    
       Type IVType = null;
           object aVector1 = null;
           object aVector2 = null;
       Type[] aVtypes = new Type[] {typeof(int), typeof(int), typeof(int)};
           object[] aVargs1 = new object[] {10, 10, 10};
           object[] aVargs2 = new object[] {20, 20, 20};
    
       // Call the  method to build our dynamic class.

       IVType = DynamicDotProductGen();

           Console.WriteLine("---");

       ConstructorInfo myDTctor = IVType.GetConstructor(aVtypes);
       aVector1 = myDTctor.Invoke(aVargs1);
       aVector2 = myDTctor.Invoke(aVargs2);

       object[] passMe = new object[1];
           passMe[0] = (object)aVector2;

       Console.WriteLine("(10, 10, 10) . (20, 20, 20) = {0}",
                 IVType.InvokeMember("DotProduct",
                          BindingFlags.InvokeMethod,
                          null,
                          aVector1,
                          passMe));

       // +++ OUTPUT +++
       // ---
       // (10, 10, 10) . (20, 20, 20) = 600
    }
}
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _


Class TestILGenerator
   
   
   Public Shared Function DynamicDotProductGen() As Type
      
      Dim ivType 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 = "IntVectorAsm"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly( _
                        myAsmName, _
                        AssemblyBuilderAccess.RunAndSave)
      
      Dim IntVectorModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule( _
                         "IntVectorModule", _
                         "Vector.dll")
      
      Dim ivTypeBld As TypeBuilder = IntVectorModule.DefineType("IntVector", TypeAttributes.Public)
      
      Dim xField As FieldBuilder = ivTypeBld.DefineField("x", _
                                 GetType(Integer), _
                                 FieldAttributes.Private)
      Dim yField As FieldBuilder = ivTypeBld.DefineField("y", _ 
                                 GetType(Integer), _
                                 FieldAttributes.Private)
      Dim zField As FieldBuilder = ivTypeBld.DefineField("z", _
                                 GetType(Integer), _
                                 FieldAttributes.Private)
      
      
      Dim objType As Type = Type.GetType("System.Object")
      Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type() {})
      
      Dim ivCtor As ConstructorBuilder = ivTypeBld.DefineConstructor( _
                     MethodAttributes.Public, _
                     CallingConventions.Standard, _
                     ctorParams)
      Dim ctorIL As ILGenerator = ivCtor.GetILGenerator()
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Call, objCtor)
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_1)
      ctorIL.Emit(OpCodes.Stfld, xField)
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_2)
      ctorIL.Emit(OpCodes.Stfld, yField)
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_3)
      ctorIL.Emit(OpCodes.Stfld, zField)
      ctorIL.Emit(OpCodes.Ret)
     

      ' Now, you'll construct the method find the dot product of two vectors. First,
      ' let's define the parameters that will be accepted by the method. In this case,
      ' it's an IntVector itself!

      Dim dpParams() As Type = {ivTypeBld}
      
      ' Here, you create a MethodBuilder containing the
      ' name, the attributes (public, static, private, and so on),
      ' the return type (int, in this case), and a array of Type
      ' indicating the type of each parameter. Since the sole parameter
      ' is a IntVector, the very class you're creating, you will
      ' pass in the TypeBuilder (which is derived from Type) instead of 
      ' a Type object for IntVector, avoiding an exception. 
      ' -- This method would be declared in VB.NET as:
      '    Public Function DotProduct(IntVector aVector) As Integer

      Dim dotProductMthd As MethodBuilder = ivTypeBld.DefineMethod("DotProduct", _
                        MethodAttributes.Public, GetType(Integer), _
                                            dpParams)
      
      ' A ILGenerator can now be spawned, attached to the MethodBuilder.
      Dim mthdIL As ILGenerator = dotProductMthd.GetILGenerator()
      
      ' Here's the body of our function, in MSIL form. We're going to find the
      ' "dot product" of the current vector instance with the passed vector 
      ' instance. For reference purposes, the equation is:
      ' (x1 * x2) + (y1 * y2) + (z1 * z2) = the dot product
      ' First, you'll load the reference to the current instance "this"
      ' stored in argument 0 (ldarg.0) onto the stack. Ldfld, the subsequent
      ' instruction, will pop the reference off the stack and look up the
      ' field "x", specified by the FieldInfo token "xField".
      mthdIL.Emit(OpCodes.Ldarg_0)
      mthdIL.Emit(OpCodes.Ldfld, xField)
      
      ' That completed, the value stored at field "x" is now atop the stack.
      ' Now, you'll do the same for the object reference we passed as a
      ' parameter, stored in argument 1 (ldarg.1). After Ldfld executed,
      ' you'll have the value stored in field "x" for the passed instance
      ' atop the stack.
      mthdIL.Emit(OpCodes.Ldarg_1)
      mthdIL.Emit(OpCodes.Ldfld, xField)
      
      ' There will now be two values atop the stack - the "x" value for the
      ' current vector instance, and the "x" value for the passed instance.
      ' You'll now multiply them, and push the result onto the evaluation stack.
      mthdIL.Emit(OpCodes.Mul_Ovf_Un)
      
      ' Now, repeat this for the "y" fields of both vectors.
      mthdIL.Emit(OpCodes.Ldarg_0)
      mthdIL.Emit(OpCodes.Ldfld, yField)
      mthdIL.Emit(OpCodes.Ldarg_1)
      mthdIL.Emit(OpCodes.Ldfld, yField)
      mthdIL.Emit(OpCodes.Mul_Ovf_Un)
      
      ' At this time, the results of both multiplications should be atop
      ' the stack. You'll now add them and push the result onto the stack.
      mthdIL.Emit(OpCodes.Add_Ovf_Un)
      
      ' Multiply both "z" field and push the result onto the stack.
      mthdIL.Emit(OpCodes.Ldarg_0)
      mthdIL.Emit(OpCodes.Ldfld, zField)
      mthdIL.Emit(OpCodes.Ldarg_1)
      mthdIL.Emit(OpCodes.Ldfld, zField)
      mthdIL.Emit(OpCodes.Mul_Ovf_Un)
      
      ' Finally, add the result of multiplying the "z" fields with the
      ' result of the earlier addition, and push the result - the dot product -
      ' onto the stack.
      mthdIL.Emit(OpCodes.Add_Ovf_Un)
      
      ' The "ret" opcode will pop the last value from the stack and return it
      ' to the calling method. You're all done!
      mthdIL.Emit(OpCodes.Ret)
      
      
      ivType = ivTypeBld.CreateType()
      
      Return ivType
   End Function 'DynamicDotProductGen
    
   
   Public Shared Sub Main()
      
      Dim IVType As Type = Nothing
      Dim aVector1 As Object = Nothing
      Dim aVector2 As Object = Nothing
      Dim aVtypes() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      Dim aVargs1() As Object = {10, 10, 10}
      Dim aVargs2() As Object = {20, 20, 20}
      
      ' Call the  method to build our dynamic class.
      IVType = DynamicDotProductGen()
      
      
      Dim myDTctor As ConstructorInfo = IVType.GetConstructor(aVtypes)
      aVector1 = myDTctor.Invoke(aVargs1)
      aVector2 = myDTctor.Invoke(aVargs2)
      
      Console.WriteLine("---")
      Dim passMe(0) As Object
      passMe(0) = CType(aVector2, Object)
      
      Console.WriteLine("(10, 10, 10) . (20, 20, 20) = {0}", _
                        IVType.InvokeMember("DotProduct", BindingFlags.InvokeMethod, _
                        Nothing, aVector1, passMe))
   End Sub
End Class



' +++ OUTPUT +++
' ---
' (10, 10, 10) . (20, 20, 20) = 600

Commenti

Per altre informazioni su questa API, vedere Osservazioni supplementari sull'API per TypeBuilder.

Campi

Nome Descrizione
UnspecifiedTypeSize

Rappresenta la dimensione totale per il tipo non specificata.

Proprietà

Nome Descrizione
Assembly

Recupera l'assembly dinamico che contiene questa definizione di tipo.

AssemblyQualifiedName

Restituisce il nome completo di questo tipo qualificato dal nome visualizzato dell'assembly.

Attributes

Ottiene gli attributi associati all'oggetto Type.

(Ereditato da Type)
BaseType

Recupera il tipo di base di questo tipo.

ContainsGenericParameters

Ottiene un valore che indica se l'oggetto corrente Type dispone di parametri di tipo che non sono stati sostituiti da tipi specifici.

(Ereditato da Type)
CustomAttributes

Ottiene una raccolta contenente gli attributi personalizzati di questo membro.

(Ereditato da MemberInfo)
DeclaredConstructors

Ottiene una raccolta dei costruttori dichiarati dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredEvents

Ottiene una raccolta degli eventi definiti dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredFields

Ottiene una raccolta dei campi definiti dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredMembers

Ottiene una raccolta dei membri definiti dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredMethods

Ottiene una raccolta dei metodi definiti dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredNestedTypes

Ottiene una raccolta dei tipi annidati definiti dal tipo corrente.

(Ereditato da TypeInfo)
DeclaredProperties

Ottiene una raccolta delle proprietà definite dal tipo corrente.

(Ereditato da TypeInfo)
DeclaringMethod

Ottiene il metodo che ha dichiarato il parametro di tipo generico corrente.

DeclaringType

Restituisce il tipo che ha dichiarato questo tipo.

FullName

Recupera il percorso completo di questo tipo.

GenericParameterAttributes

Ottiene un valore che indica la covarianza e i vincoli speciali del parametro di tipo generico corrente.

GenericParameterPosition

Ottiene la posizione di un parametro di tipo nell'elenco dei parametri di tipo del tipo generico che ha dichiarato il parametro.

GenericTypeArguments

Ottiene una matrice degli argomenti di tipo generico per questo tipo.

(Ereditato da Type)
GenericTypeParameters

Ottiene una matrice dei parametri di tipo generico dell'istanza corrente.

(Ereditato da TypeInfo)
GUID

Recupera il GUID di questo tipo.

HasElementType

Ottiene un valore che indica se l'oggetto corrente Type comprende o fa riferimento a un altro tipo, ovvero se l'oggetto corrente Type è una matrice, un puntatore o viene passato per riferimento.

(Ereditato da Type)
ImplementedInterfaces

Ottiene una raccolta delle interfacce implementate dal tipo corrente.

(Ereditato da TypeInfo)
IsAbstract

Ottiene un valore che indica se l'oggetto Type è astratto e deve essere sottoposto a override.

(Ereditato da Type)
IsAnsiClass

Ottiene un valore che indica se l'attributo AnsiClass di formato stringa è selezionato per .Type

(Ereditato da Type)
IsArray

Ottiene un valore che indica se il tipo è una matrice.

(Ereditato da Type)
IsAutoClass

Ottiene un valore che indica se l'attributo AutoClass di formato stringa è selezionato per .Type

(Ereditato da Type)
IsAutoLayout

Ottiene un valore che indica se i campi del tipo corrente vengono disposti automaticamente da Common Language Runtime.

(Ereditato da Type)
IsByRef

Ottiene un valore che indica se l'oggetto Type viene passato per riferimento.

(Ereditato da Type)
IsByRefLike

Ottiene un valore che indica se il tipo è una struttura simile a byref.

IsClass

Ottiene un valore che indica se è Type una classe o un delegato, ovvero non un tipo di valore o un'interfaccia.

(Ereditato da Type)
IsCOMObject

Ottiene un valore che indica se è Type un oggetto COM.

(Ereditato da Type)
IsConstructedGenericType

Ottiene un valore che indica se questo oggetto rappresenta un tipo generico costruito.

IsContextful

Ottiene un valore che indica se l'oggetto Type può essere ospitato in un contesto.

(Ereditato da Type)
IsEnum

Ottiene un valore che indica se l'oggetto corrente Type rappresenta un'enumerazione.

(Ereditato da Type)
IsExplicitLayout

Ottiene un valore che indica se i campi del tipo corrente sono disposti in corrispondenza di offset specificati in modo esplicito.

(Ereditato da Type)
IsGenericMethodParameter

Ottiene un valore che indica se l'oggetto corrente Type rappresenta un parametro di tipo nella definizione di un metodo generico.

(Ereditato da Type)
IsGenericParameter

Ottiene un valore che indica se il tipo corrente è un parametro di tipo generico.

IsGenericType

Ottiene un valore che indica se il tipo corrente è un tipo generico.

IsGenericTypeDefinition

Ottiene un valore che indica se l'oggetto corrente TypeBuilder rappresenta una definizione di tipo generico da cui è possibile costruire altri tipi generici.

IsGenericTypeParameter

Ottiene un valore che indica se l'oggetto corrente Type rappresenta un parametro di tipo nella definizione di un tipo generico.

(Ereditato da Type)
IsImport

Ottiene un valore che indica se l'oggetto Type ha un ComImportAttribute attributo applicato, a indicare che è stato importato da una libreria dei tipi COM.

(Ereditato da Type)
IsInterface

Ottiene un valore che indica se è un'interfaccia Type , ovvero non una classe o un tipo valore.

(Ereditato da Type)
IsLayoutSequential

Ottiene un valore che indica se i campi del tipo corrente sono disposti in sequenza, nell'ordine in cui sono stati definiti o emessi nei metadati.

(Ereditato da Type)
IsMarshalByRef

Ottiene un valore che indica se l'oggetto viene sottoposto a Type marshalling per riferimento.

(Ereditato da Type)
IsNested

Ottiene un valore che indica se l'oggetto corrente Type rappresenta un tipo la cui definizione è annidata all'interno della definizione di un altro tipo.

(Ereditato da Type)
IsNestedAssembly

Ottiene un valore che indica se l'oggetto Type è annidato e visibile solo all'interno del proprio assembly.

(Ereditato da Type)
IsNestedFamANDAssem

Ottiene un valore che indica se l'oggetto Type è annidato e visibile solo alle classi che appartengono sia alla propria famiglia che al relativo assembly.

(Ereditato da Type)
IsNestedFamily

Ottiene un valore che indica se l'oggetto Type è annidato e visibile solo all'interno della propria famiglia.

(Ereditato da Type)
IsNestedFamORAssem

Ottiene un valore che indica se l'oggetto Type è annidato e visibile solo alle classi che appartengono alla propria famiglia o al proprio assembly.

(Ereditato da Type)
IsNestedPrivate

Ottiene un valore che indica se l'oggetto Type è annidato e dichiarato privato.

(Ereditato da Type)
IsNestedPublic

Ottiene un valore che indica se una classe è annidata e dichiarata pubblica.

(Ereditato da Type)
IsNotPublic

Ottiene un valore che indica se l'oggetto Type non è dichiarato pubblico.

(Ereditato da Type)
IsPointer

Ottiene un valore che indica se è Type un puntatore.

(Ereditato da Type)
IsPrimitive

Ottiene un valore che indica se è Type uno dei tipi primitivi.

(Ereditato da Type)
IsPublic

Ottiene un valore che indica se l'oggetto Type è dichiarato pubblico.

(Ereditato da Type)
IsSealed

Ottiene un valore che indica se l'oggetto Type è dichiarato sealed.

(Ereditato da Type)
IsSecurityCritical

Ottiene un valore che indica se il tipo corrente è critico per la sicurezza o critico per la sicurezza e pertanto può eseguire operazioni critiche.

IsSecuritySafeCritical

Ottiene un valore che indica se il tipo corrente è critico per la sicurezza; ovvero se può eseguire operazioni critiche e può essere accessibile tramite codice trasparente.

IsSecurityTransparent

Ottiene un valore che indica se il tipo corrente è trasparente e pertanto non può eseguire operazioni critiche.

IsSerializable

Ottiene un valore che indica se è Type serializzabile binario.

(Ereditato da Type)
IsSignatureType

Ottiene un valore che indica se il tipo è un tipo di firma.

(Ereditato da Type)
IsSpecialName

Ottiene un valore che indica se il tipo ha un nome che richiede una gestione speciale.

(Ereditato da Type)
IsSZArray

Definisce e crea nuove istanze di classi durante l'esecuzione.

IsTypeDefinition

Definisce e crea nuove istanze di classi durante l'esecuzione.

IsUnicodeClass

Ottiene un valore che indica se l'attributo UnicodeClass di formato stringa è selezionato per .Type

(Ereditato da Type)
IsValueType

Ottiene un valore che indica se è Type un tipo di valore.

(Ereditato da Type)
IsVariableBoundArray

Definisce e crea nuove istanze di classi durante l'esecuzione.

IsVisible

Ottiene un valore che indica se l'oggetto Type può essere accessibile dal codice all'esterno dell'assembly.

(Ereditato da Type)
MemberType

Ottiene un MemberTypes valore che indica che questo membro è un tipo o un tipo annidato.

(Ereditato da Type)
MetadataToken

Ottiene un valore che identifica un elemento di metadati.

(Ereditato da MemberInfo)
Module

Recupera il modulo dinamico che contiene questa definizione di tipo.

Name

Recupera il nome di questo tipo.

Namespace

Recupera lo spazio dei nomi in cui TypeBuilder è definito.

PackingSize

Recupera le dimensioni di compressione di questo tipo.

ReflectedType

Restituisce il tipo utilizzato per ottenere questo tipo.

Size

Recupera le dimensioni totali di un tipo.

StructLayoutAttribute

Ottiene un oggetto StructLayoutAttribute che descrive il layout del tipo corrente.

(Ereditato da Type)
TypeHandle

Non supportato nei moduli dinamici.

TypeInitializer

Ottiene l'inizializzatore per il tipo.

(Ereditato da Type)
TypeToken

Restituisce il token di tipo di questo tipo.

UnderlyingSystemType

Restituisce il tipo di sistema sottostante per l'oggetto TypeBuilder.

Metodi

Nome Descrizione
AddDeclarativeSecurity(SecurityAction, PermissionSet)

Aggiunge sicurezza dichiarativa a questo tipo.

AddInterfaceImplementation(Type)

Aggiunge un'interfaccia implementata da questo tipo.

AsType()

Restituisce il tipo corrente come Type oggetto .

(Ereditato da TypeInfo)
CreateType()

Crea un Type oggetto per la classe . Dopo aver definito campi e metodi nella classe , CreateType viene chiamato per caricarne l'oggetto Type .

CreateTypeInfo()

Ottiene un TypeInfo oggetto che rappresenta questo tipo.

DefineConstructor(MethodAttributes, CallingConventions, Type[], Type[][], Type[][])

Aggiunge un nuovo costruttore al tipo, con gli attributi, la firma e i modificatori personalizzati specificati.

DefineConstructor(MethodAttributes, CallingConventions, Type[])

Aggiunge un nuovo costruttore al tipo, con gli attributi e la firma specificati.

DefineDefaultConstructor(MethodAttributes)

Definisce il costruttore senza parametri. Il costruttore definito qui chiamerà semplicemente il costruttore senza parametri dell'elemento padre.

DefineEvent(String, EventAttributes, Type)

Aggiunge un nuovo evento al tipo, con il nome, gli attributi e il tipo di evento specificati.

DefineField(String, Type, FieldAttributes)

Aggiunge un nuovo campo al tipo, con il nome, gli attributi e il tipo di campo specificati.

DefineField(String, Type, Type[], Type[], FieldAttributes)

Aggiunge un nuovo campo al tipo, con il nome, gli attributi, il tipo di campo e i modificatori personalizzati specificati.

DefineGenericParameters(String[])

Definisce i parametri di tipo generico per il tipo corrente, specificandone il numero e i relativi nomi e restituisce una matrice di GenericTypeParameterBuilder oggetti che possono essere utilizzati per impostare i relativi vincoli.

DefineInitializedData(String, Byte[], FieldAttributes)

Definisce il campo dati inizializzato nella sezione sdata del file eseguibile portabile (PE).

DefineMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][])

Aggiunge un nuovo metodo al tipo, con il nome, gli attributi del metodo, la convenzione di chiamata, la firma del metodo e i modificatori personalizzati specificati.

DefineMethod(String, MethodAttributes, CallingConventions, Type, Type[])

Aggiunge un nuovo metodo al tipo, con il nome, gli attributi del metodo, la convenzione di chiamata e la firma del metodo specificati.

DefineMethod(String, MethodAttributes, CallingConventions)

Aggiunge un nuovo metodo al tipo, con il nome, gli attributi del metodo e la convenzione di chiamata specificati.

DefineMethod(String, MethodAttributes, Type, Type[])

Aggiunge un nuovo metodo al tipo, con il nome, gli attributi del metodo e la firma del metodo specificati.

DefineMethod(String, MethodAttributes)

Aggiunge un nuovo metodo al tipo, con il nome e gli attributi del metodo specificati.

DefineMethodOverride(MethodInfo, MethodInfo)

Specifica un determinato corpo del metodo che implementa una determinata dichiarazione di metodo, potenzialmente con un nome diverso.

DefineNestedType(String, TypeAttributes, Type, Int32)

Definisce un tipo annidato, in base al nome, agli attributi, alla dimensione totale del tipo e al tipo esteso.

DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32)

Definisce un tipo annidato, in base al nome, agli attributi, alle dimensioni e al tipo esteso.

DefineNestedType(String, TypeAttributes, Type, PackingSize)

Definisce un tipo annidato, in base al nome, agli attributi, al tipo esteso e alle dimensioni di compressione.

DefineNestedType(String, TypeAttributes, Type, Type[])

Definisce un tipo annidato, in base al nome, agli attributi, al tipo esteso e alle interfacce implementate.

DefineNestedType(String, TypeAttributes, Type)

Definisce un tipo annidato, in base al nome, agli attributi e al tipo esteso.

DefineNestedType(String, TypeAttributes)

Definisce un tipo annidato, in base al nome e agli attributi.

DefineNestedType(String)

Definisce un tipo annidato, dato il nome.

DefinePInvokeMethod(String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet)

Definisce un PInvoke metodo in base al nome, al nome della DLL in cui è definito il metodo, agli attributi del metodo, alla convenzione di chiamata del metodo, al tipo restituito del metodo, ai tipi dei parametri del metodo e ai PInvoke flag.

DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet)

Definisce un PInvoke metodo in base al nome, al nome della DLL in cui è definito il metodo, al nome del punto di ingresso, agli attributi del metodo, alla convenzione di chiamata del metodo, al tipo restituito del metodo, ai tipi dei parametri del metodo e ai PInvoke flag.

DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][], CallingConvention, CharSet)

Definisce un PInvoke metodo in base al nome, al nome della DLL in cui è definito il metodo, al nome del punto di ingresso, agli attributi del metodo, alla convenzione di chiamata del metodo, al tipo restituito del metodo, ai tipi dei parametri del metodo, PInvoke ai flag e ai modificatori personalizzati per i parametri e al tipo restituito.

DefineProperty(String, PropertyAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][])

Aggiunge una nuova proprietà al tipo, con il nome specificato, la convenzione di chiamata, la firma della proprietà e i modificatori personalizzati.

DefineProperty(String, PropertyAttributes, CallingConventions, Type, Type[])

Aggiunge una nuova proprietà al tipo, con il nome, gli attributi, la convenzione di chiamata e la firma della proprietà specificati.

DefineProperty(String, PropertyAttributes, Type, Type[], Type[], Type[], Type[][], Type[][])

Aggiunge una nuova proprietà al tipo, con il nome, la firma della proprietà e i modificatori personalizzati specificati.

DefineProperty(String, PropertyAttributes, Type, Type[])

Aggiunge una nuova proprietà al tipo, con il nome e la firma della proprietà specificati.

DefineTypeInitializer()

Definisce l'inizializzatore per questo tipo.

DefineUninitializedData(String, Int32, FieldAttributes)

Definisce un campo dati non inizializzato nella .sdata sezione del file eseguibile portabile (PE).

Equals(Object)

Determina se il tipo di sistema sottostante dell'oggetto corrente Type è uguale al tipo di sistema sottostante dell'oggetto specificato Object.

(Ereditato da Type)
Equals(Type)

Determina se il tipo di sistema sottostante dell'oggetto corrente Type corrisponde al tipo di sistema sottostante dell'oggetto specificato Type.

(Ereditato da Type)
FindInterfaces(TypeFilter, Object)

Restituisce una matrice di Type oggetti che rappresenta un elenco filtrato di interfacce implementate o ereditate dall'oggetto corrente Type.

(Ereditato da Type)
FindMembers(MemberTypes, BindingFlags, MemberFilter, Object)

Restituisce una matrice filtrata di MemberInfo oggetti del tipo di membro specificato.

(Ereditato da Type)
GetArrayRank()

Ottiene il numero di dimensioni in una matrice.

(Ereditato da Type)
GetAttributeFlagsImpl()

Quando sottoposto a override in una classe derivata, implementa la Attributes proprietà e ottiene una combinazione bit per bit di valori di enumerazione che indicano gli attributi associati all'oggetto Type.

(Ereditato da Type)
GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Cerca un costruttore i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])

Cerca un costruttore i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, usando i vincoli di associazione specificati.

(Ereditato da Type)
GetConstructor(Type, ConstructorInfo)

Restituisce il costruttore del tipo generico costruito specificato che corrisponde al costruttore specificato della definizione del tipo generico.

GetConstructor(Type[])

Cerca un costruttore di istanza pubblica i cui parametri corrispondono ai tipi nella matrice specificata.

(Ereditato da Type)
GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

In caso di override in una classe derivata, cerca un costruttore i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetConstructors()

Restituisce tutti i costruttori pubblici definiti per l'oggetto corrente Type.

(Ereditato da Type)
GetConstructors(BindingFlags)

Restituisce una matrice di ConstructorInfo oggetti che rappresentano i costruttori pubblici e non pubblici definiti per questa classe, come specificato.

GetCustomAttributes(Boolean)

Restituisce tutti gli attributi personalizzati definiti per questo tipo.

GetCustomAttributes(Type, Boolean)

Restituisce tutti gli attributi personalizzati del tipo corrente assegnabili a un tipo specificato.

GetCustomAttributesData()

Restituisce un elenco di CustomAttributeData oggetti che rappresentano i dati sugli attributi applicati al membro di destinazione.

(Ereditato da MemberInfo)
GetDeclaredEvent(String)

Restituisce un oggetto che rappresenta l'evento specificato dichiarato dal tipo corrente.

(Ereditato da TypeInfo)
GetDeclaredField(String)

Restituisce un oggetto che rappresenta il campo specificato dichiarato dal tipo corrente.

(Ereditato da TypeInfo)
GetDeclaredMethod(String)

Restituisce un oggetto che rappresenta il metodo specificato dichiarato dal tipo corrente.

(Ereditato da TypeInfo)
GetDeclaredMethods(String)

Restituisce un insieme che contiene tutti i metodi dichiarati nel tipo corrente che corrispondono al nome specificato.

(Ereditato da TypeInfo)
GetDeclaredNestedType(String)

Restituisce un oggetto che rappresenta il tipo annidato specificato dichiarato dal tipo corrente.

(Ereditato da TypeInfo)
GetDeclaredProperty(String)

Restituisce un oggetto che rappresenta la proprietà specificata dichiarata dal tipo corrente.

(Ereditato da TypeInfo)
GetDefaultMembers()

Cerca i membri definiti per l'oggetto corrente Type il cui DefaultMemberAttribute oggetto è impostato.

(Ereditato da Type)
GetElementType()

La chiamata a questo metodo genera NotSupportedExceptionsempre .

GetEnumName(Object)

Restituisce il nome della costante con il valore specificato per il tipo di enumerazione corrente.

(Ereditato da Type)
GetEnumNames()

Restituisce i nomi dei membri del tipo di enumerazione corrente.

(Ereditato da Type)
GetEnumUnderlyingType()

Restituisce il tipo sottostante del tipo di enumerazione corrente.

(Ereditato da Type)
GetEnumValues()

Restituisce una matrice dei valori delle costanti nel tipo di enumerazione corrente.

(Ereditato da Type)
GetEvent(String, BindingFlags)

Restituisce l'evento con il nome specificato.

GetEvent(String)

Restituisce l'oggetto EventInfo che rappresenta l'evento pubblico specificato.

(Ereditato da Type)
GetEvents()

Restituisce gli eventi pubblici dichiarati o ereditati da questo tipo.

GetEvents(BindingFlags)

Restituisce gli eventi pubblici e non pubblici dichiarati da questo tipo.

GetField(String, BindingFlags)

Restituisce il campo specificato dal nome specificato.

GetField(String)

Cerca il campo pubblico con il nome specificato.

(Ereditato da Type)
GetField(Type, FieldInfo)

Restituisce il campo del tipo generico costruito specificato che corrisponde al campo specificato della definizione del tipo generico.

GetFields()

Restituisce tutti i campi pubblici dell'oggetto corrente Type.

(Ereditato da Type)
GetFields(BindingFlags)

Restituisce i campi pubblici e non pubblici dichiarati da questo tipo.

GetGenericArguments()

Restituisce una matrice di Type oggetti che rappresentano gli argomenti di tipo di un tipo generico o i parametri di tipo di una definizione di tipo generico.

GetGenericParameterConstraints()

Restituisce una matrice di Type oggetti che rappresentano i vincoli per il parametro di tipo generico corrente.

(Ereditato da Type)
GetGenericTypeDefinition()

Restituisce un Type oggetto che rappresenta una definizione di tipo generico da cui è possibile ottenere il tipo corrente.

GetHashCode()

Restituisce il codice hash per questa istanza.

(Ereditato da Type)
GetInterface(String, Boolean)

Restituisce l'interfaccia implementata (direttamente o indirettamente) da questa classe con il nome completo corrispondente al nome dell'interfaccia specificato.

GetInterface(String)

Cerca l'interfaccia con il nome specificato.

(Ereditato da Type)
GetInterfaceMap(Type)

Restituisce un mapping dell'interfaccia per l'interfaccia richiesta.

GetInterfaces()

Restituisce una matrice di tutte le interfacce implementate su questo tipo e sui relativi tipi di base.

GetMember(String, BindingFlags)

Cerca i membri specificati utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetMember(String, MemberTypes, BindingFlags)

Restituisce tutti i membri pubblici e non pubblici dichiarati o ereditati da questo tipo, come specificato.

GetMember(String)

Cerca i membri pubblici con il nome specificato.

(Ereditato da Type)
GetMembers()

Restituisce tutti i membri pubblici dell'oggetto corrente Type.

(Ereditato da Type)
GetMembers(BindingFlags)

Restituisce i membri per i membri pubblici e non pubblici dichiarati o ereditati da questo tipo.

GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Cerca il metodo specificato i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])

Cerca il metodo specificato i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetMethod(String, BindingFlags)

Cerca il metodo specificato utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetMethod(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Cerca il metodo specificato i cui parametri corrispondono al conteggio dei parametri generici, ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetMethod(String, Int32, BindingFlags, Binder, Type[], ParameterModifier[])

Cerca il metodo specificato i cui parametri corrispondono al conteggio dei parametri generici, ai tipi di argomento e ai modificatori specificati, usando i vincoli di associazione specificati.

(Ereditato da Type)
GetMethod(String, Int32, Type[], ParameterModifier[])

Cerca il metodo pubblico specificato i cui parametri corrispondono al conteggio dei parametri generici, ai tipi di argomento e ai modificatori specificati.

(Ereditato da Type)
GetMethod(String, Int32, Type[])

Cerca il metodo pubblico specificato i cui parametri corrispondono al numero di parametri generici e ai tipi di argomento specificati.

(Ereditato da Type)
GetMethod(String, Type[], ParameterModifier[])

Cerca il metodo pubblico specificato i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati.

(Ereditato da Type)
GetMethod(String, Type[])

Cerca il metodo pubblico specificato i cui parametri corrispondono ai tipi di argomento specificati.

(Ereditato da Type)
GetMethod(String)

Cerca il metodo pubblico con il nome specificato.

(Ereditato da Type)
GetMethod(Type, MethodInfo)

Restituisce il metodo del tipo generico costruito specificato che corrisponde al metodo specificato della definizione del tipo generico.

GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Quando sottoposto a override in una classe derivata, cerca il metodo specificato i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

In caso di override in una classe derivata, cerca il metodo specificato i cui parametri corrispondono al conteggio dei parametri generici, ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati e la convenzione di chiamata specificata.

(Ereditato da Type)
GetMethods()

Restituisce tutti i metodi pubblici dell'oggetto corrente Type.

(Ereditato da Type)
GetMethods(BindingFlags)

Restituisce tutti i metodi pubblici e non pubblici dichiarati o ereditati da questo tipo, come specificato.

GetNestedType(String, BindingFlags)

Restituisce i tipi annidati pubblici e non pubblici dichiarati da questo tipo.

GetNestedType(String)

Cerca il tipo annidato pubblico con il nome specificato.

(Ereditato da Type)
GetNestedTypes()

Restituisce i tipi pubblici annidati nell'oggetto corrente Type.

(Ereditato da Type)
GetNestedTypes(BindingFlags)

Restituisce i tipi annidati pubblici e non pubblici dichiarati o ereditati da questo tipo.

GetProperties()

Restituisce tutte le proprietà pubbliche dell'oggetto corrente Type.

(Ereditato da Type)
GetProperties(BindingFlags)

Restituisce tutte le proprietà pubbliche e non pubbliche dichiarate o ereditate da questo tipo, come specificato.

GetProperty(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])

Cerca la proprietà specificata i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetProperty(String, BindingFlags)

Cerca la proprietà specificata utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetProperty(String, Type, Type[], ParameterModifier[])

Cerca la proprietà pubblica specificata i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati.

(Ereditato da Type)
GetProperty(String, Type, Type[])

Cerca la proprietà pubblica specificata i cui parametri corrispondono ai tipi di argomento specificati.

(Ereditato da Type)
GetProperty(String, Type)

Cerca la proprietà pubblica con il nome e il tipo restituito specificati.

(Ereditato da Type)
GetProperty(String, Type[])

Cerca la proprietà pubblica specificata i cui parametri corrispondono ai tipi di argomento specificati.

(Ereditato da Type)
GetProperty(String)

Cerca la proprietà pubblica con il nome specificato.

(Ereditato da Type)
GetPropertyImpl(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])

In caso di override in una classe derivata, cerca la proprietà specificata i cui parametri corrispondono ai tipi di argomento e ai modificatori specificati, utilizzando i vincoli di associazione specificati.

(Ereditato da Type)
GetType()

Ottiene l'oggetto corrente Type.

(Ereditato da Type)
GetTypeCodeImpl()

Restituisce il codice di tipo sottostante di questa Type istanza.

(Ereditato da Type)
HasElementTypeImpl()

Quando sottoposto a override in una classe derivata, implementa la HasElementType proprietà e determina se l'oggetto corrente comprende o fa riferimento a un altro tipo, ovvero se l'oggetto corrente TypeType è una matrice, un puntatore o viene passato per riferimento.

(Ereditato da Type)
HasSameMetadataDefinitionAs(MemberInfo)

Definisce e crea nuove istanze di classi durante l'esecuzione.

(Ereditato da MemberInfo)
InvokeMember(String, BindingFlags, Binder, Object, Object[], CultureInfo)

Richiama il membro specificato, utilizzando i vincoli di associazione specificati e associando l'elenco di argomenti e le impostazioni cultura specificati.

(Ereditato da Type)
InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])

Richiama il membro specificato. Il metodo che deve essere richiamato deve essere accessibile e fornire la corrispondenza più specifica con l'elenco di argomenti specificato, in base ai vincoli del binder e degli attributi di chiamata specificati.

InvokeMember(String, BindingFlags, Binder, Object, Object[])

Richiama il membro specificato, utilizzando i vincoli di associazione specificati e associando l'elenco di argomenti specificato.

(Ereditato da Type)
IsArrayImpl()

Quando sottoposto a override in una classe derivata, implementa la IsArray proprietà e determina se è Type una matrice.

(Ereditato da Type)
IsAssignableFrom(Type)

Ottiene un valore che indica se un oggetto specificato Type può essere assegnato a questo oggetto.

IsAssignableFrom(TypeInfo)

Ottiene un valore che indica se un oggetto specificato TypeInfo può essere assegnato a questo oggetto.

IsByRefImpl()

Quando sottoposto a override in una classe derivata, implementa la IsByRef proprietà e determina se l'oggetto Type viene passato per riferimento.

(Ereditato da Type)
IsCOMObjectImpl()

Quando sottoposto a override in una classe derivata, implementa la IsCOMObject proprietà e determina se è Type un oggetto COM.

(Ereditato da Type)
IsContextfulImpl()

Implementa la IsContextful proprietà e determina se Type può essere ospitato in un contesto.

(Ereditato da Type)
IsCreated()

Restituisce un valore che indica se il tipo dinamico corrente è stato creato.

IsDefined(Type, Boolean)

Determina se un attributo personalizzato viene applicato al tipo corrente.

IsEnumDefined(Object)

Restituisce un valore che indica se il valore specificato esiste nel tipo di enumerazione corrente.

(Ereditato da Type)
IsEquivalentTo(Type)

Determina se due tipi COM hanno la stessa identità e sono idonei per l'equivalenza del tipo.

(Ereditato da Type)
IsInstanceOfType(Object)

Determina se l'oggetto specificato è un'istanza dell'oggetto corrente Type.

(Ereditato da Type)
IsMarshalByRefImpl()

Implementa la IsMarshalByRef proprietà e determina se l'oggetto Type viene sottoposto a marshalling per riferimento.

(Ereditato da Type)
IsPointerImpl()

Quando sottoposto a override in una classe derivata, implementa la IsPointer proprietà e determina se è Type un puntatore.

(Ereditato da Type)
IsPrimitiveImpl()

Quando sottoposto a override in una classe derivata, implementa la IsPrimitive proprietà e determina se Type è uno dei tipi primitivi.

(Ereditato da Type)
IsSubclassOf(Type)

Determina se questo tipo è derivato da un tipo specificato.

IsValueTypeImpl()

Implementa la IsValueType proprietà e determina se Type è un tipo di valore, ovvero non una classe o un'interfaccia.

(Ereditato da Type)
MakeArrayType()

Restituisce un Type oggetto che rappresenta una matrice unidimensionale del tipo corrente, con un limite inferiore pari a zero.

MakeArrayType(Int32)

Restituisce un Type oggetto che rappresenta una matrice del tipo corrente, con il numero specificato di dimensioni.

MakeByRefType()

Restituisce un oggetto che rappresenta il tipo corrente quando viene passato come parametro /> in Visual Basic).

MakeGenericType(Type[])

Sostituisce gli elementi di una matrice di tipi per i parametri di tipo della definizione di tipo generico corrente e restituisce il tipo costruito risultante.

MakePointerType()

Restituisce un Type oggetto che rappresenta il tipo di un puntatore non gestito al tipo corrente.

MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
SetCustomAttribute(ConstructorInfo, Byte[])

Imposta un attributo personalizzato usando un BLOB di attributi personalizzato specificato.

SetCustomAttribute(CustomAttributeBuilder)

Impostare un attributo personalizzato usando un generatore di attributi personalizzato.

SetParent(Type)

Imposta il tipo di base del tipo attualmente in fase di costruzione.

ToString()

Restituisce il nome del tipo escluso lo spazio dei nomi.

Implementazioni dell'interfaccia esplicita

Nome Descrizione
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch.

(Ereditato da MemberInfo)
_MemberInfo.GetType()

Ottiene un Type oggetto che rappresenta la MemberInfo classe .

(Ereditato da MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto .

(Ereditato da MemberInfo)
_Type.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch.

(Ereditato da Type)
_Type.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Type)
_Type.GetTypeInfoCount(UInt32)

Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Type)
_Type.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto .

(Ereditato da Type)
_TypeBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch.

_TypeBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

_TypeBuilder.GetTypeInfoCount(UInt32)

Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

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

Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto .

IReflectableType.GetTypeInfo()

Restituisce una rappresentazione del tipo corrente come TypeInfo oggetto .

(Ereditato da TypeInfo)

Metodi di estensione

Nome Descrizione
GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.

GetCustomAttribute(MemberInfo, Type)

Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato.

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.

GetCustomAttribute<T>(MemberInfo)

Recupera un attributo personalizzato di un tipo specificato applicato a un membro specificato.

GetCustomAttributes(MemberInfo, Boolean)

Recupera una raccolta di attributi personalizzati applicati a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.

GetCustomAttributes(MemberInfo, Type, Boolean)

Recupera una raccolta di attributi personalizzati di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.

GetCustomAttributes(MemberInfo, Type)

Recupera una raccolta di attributi personalizzati di un tipo specificato applicato a un membro specificato.

GetCustomAttributes(MemberInfo)

Recupera una raccolta di attributi personalizzati applicati a un membro specificato.

GetCustomAttributes<T>(MemberInfo, Boolean)

Recupera una raccolta di attributi personalizzati di un tipo specificato applicato a un membro specificato e, facoltativamente, controlla i predecessori di tale membro.

GetCustomAttributes<T>(MemberInfo)

Recupera una raccolta di attributi personalizzati di un tipo specificato applicato a un membro specificato.

GetRuntimeEvent(Type, String)

Recupera un oggetto che rappresenta l'evento specificato.

GetRuntimeEvents(Type)

Recupera una raccolta che rappresenta tutti gli eventi definiti in un tipo specificato.

GetRuntimeField(Type, String)

Recupera un oggetto che rappresenta un campo specificato.

GetRuntimeFields(Type)

Recupera un insieme che rappresenta tutti i campi definiti in un tipo specificato.

GetRuntimeInterfaceMap(TypeInfo, Type)

Restituisce un mapping dell'interfaccia per il tipo specificato e l'interfaccia specificata.

GetRuntimeMethod(Type, String, Type[])

Recupera un oggetto che rappresenta un metodo specificato.

GetRuntimeMethods(Type)

Recupera una raccolta che rappresenta tutti i metodi definiti in un tipo specificato.

GetRuntimeProperties(Type)

Recupera una raccolta che rappresenta tutte le proprietà definite in un tipo specificato.

GetRuntimeProperty(Type, String)

Recupera un oggetto che rappresenta una proprietà specificata.

GetTypeInfo(Type)

Restituisce la TypeInfo rappresentazione del tipo specificato.

IsDefined(MemberInfo, Type, Boolean)

Indica se gli attributi personalizzati di un tipo specificato vengono applicati a un membro specificato e, facoltativamente, applicati ai relativi predecessori.

IsDefined(MemberInfo, Type)

Indica se gli attributi personalizzati di un tipo specificato vengono applicati a un membro specificato.

Si applica a

Vedi anche