IsByValue 클래스

정의

한정자가 지정된 메서드 인수를 값으로 전달된 개체 의미가 포함된 인수로 해석해야 함을 나타냅니다. 이 한정자는 참조 형식에 적용됩니다. 이 클래스는 상속될 수 없습니다.

public ref class IsByValue abstract sealed
public static class IsByValue
type IsByValue = class
Public Class IsByValue
상속
IsByValue

예제

다음 예제에서는 내보내는 방법을 보여 줍니다는 IsByValue 리플렉션을 사용 하 여 어셈블리에는 개체입니다.



#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Runtime::CompilerServices;
using namespace System::Threading;


ref class CodeEmitter
{
private:
    AssemblyBuilder^ asmBuilder;
    String^ asmName;
    ModuleBuilder^ modBuilder;


    void prepareAssembly(String^ name){
        
        // Check the input.
        if(!name){
        
            throw gcnew ArgumentNullException("AssemblyName");
        }

        asmName = name;

        // Create an AssemblyName object and set the name.
        AssemblyName^ asmName = gcnew AssemblyName();

        asmName->Name = name;

        // Use the AppDomain class to create an AssemblyBuilder instance.

        AppDomain^ currentDomain = Thread::GetDomain();

        asmBuilder = currentDomain->DefineDynamicAssembly(asmName,AssemblyBuilderAccess::RunAndSave);

        // Create a dynamic module.
        modBuilder = asmBuilder->DefineDynamicModule(name);
    }


public:

    // Constructor.
    CodeEmitter(String ^ AssemblyName){

        prepareAssembly(AssemblyName);
    }

    // Create a new type.
    TypeBuilder^ CreateType(String^ name){
       
        // Check the input.
        if(!name){
        
            throw gcnew ArgumentNullException("AssemblyName");
        }

        return modBuilder->DefineType( name );
    }

    // Write the assembly.
    void WriteAssembly(MethodBuilder^ entryPoint){
    
        // Check the input.
        if(!entryPoint){
        
            throw gcnew ArgumentNullException("entryPoint");
        }

        asmBuilder->SetEntryPoint( entryPoint );
        asmBuilder->Save( asmName );
    }

};

void main()
{

    // Create a CodeEmitter to handle assembly creation.
    CodeEmitter ^ e = gcnew CodeEmitter("program.exe");

    // Create a new type.
    TypeBuilder^ mainClass = e->CreateType("MainClass");
    
    // Create a new method.
    MethodBuilder^ mBuilder = mainClass->DefineMethod("mainMethod", MethodAttributes::Static);

    // Create an ILGenerator and emit IL for 
    // a simple "Hello World." program.
    ILGenerator^ ilGen = mBuilder->GetILGenerator();

    ilGen->Emit(OpCodes::Ldstr, "Hello World");

    array<Type^>^mType = {String::typeid};

    MethodInfo^ writeMI = Console::typeid->GetMethod( "WriteLine", mType );

    ilGen->EmitCall(OpCodes::Call, writeMI, nullptr );

    ilGen->Emit( OpCodes::Ret );

    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    // Apply a required custom modifier
    // to a field.
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////

    array<Type^>^fType = {IsByValue::typeid};

    mainClass->DefineField("modifiedInteger", Type::GetType("System.Int32"), fType, nullptr, FieldAttributes::Private);

    // Create the type.
    mainClass->CreateType();

    // Write the assembly using a reference to 
    // the entry point.
    e->WriteAssembly(mBuilder);

    Console::WriteLine(L"Assembly created.");
}

설명

클래스는 IsByValue Microsoft C++ 컴파일러에서 메서드 매개 변수를 나타내고 의미 체계가 값으로 전달된 개체에 대한 C++ 규칙을 따르는 값을 반환하는 데 사용됩니다.

컴파일러는 적시에 (JIT) 컴파일러가 기본 동작이 적절 하지 않은 경우 값을 처리 하는 방법을 변경 하려면 메타 데이터 내에서 사용자 지정 한정자를 내보냅니다. JIT 컴파일러는 사용자 지정 한정자를 발견 하는 경우에 한정자를 지정 하는 방식으로 값을 처리 합니다. 컴파일러는 메서드, 매개 변수를 사용자 지정 한정자를 적용 하 고 값을 반환할 수 있습니다. JIT 컴파일러는 필수 한정자에 응답 해야 하지만 선택적 한정자를 무시할 수 있습니다.

다음 방법 중 하나를 사용 하 여 메타 데이터를 사용자 지정 한정자를 내보낼 수 있습니다.

적용 대상