Type.IsMarshalByRefImpl 메서드

IsMarshalByRef 속성을 구현하고, Type이 참조에 의해 마샬링되는지 여부를 확인합니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Protected Overridable Function IsMarshalByRefImpl As Boolean
‘사용 방법
Dim returnValue As Boolean

returnValue = Me.IsMarshalByRefImpl
protected virtual bool IsMarshalByRefImpl ()
protected:
virtual bool IsMarshalByRefImpl ()
protected boolean IsMarshalByRefImpl ()
protected function IsMarshalByRefImpl () : boolean

반환 값

Type이 참조에 의해 마샬링되면 true이고, 그렇지 않으면 false입니다.

설명

이 메서드는 파생된 클래스에서 재정의할 수 있습니다.

예제

다음 예제에서는 주어진 형식이 참조로 마샬링되는지 확인하여 결과를 표시합니다.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class MyTypeDelegatorClass
    Inherits TypeDelegator
    Public myElementType As String = Nothing
    Private myType As Type = Nothing
    Public Sub New(ByVal myType As Type)
        MyBase.New(myType)
        Me.myType = myType
    End Sub 'New

    ' Override IsMarshalByRefImpl.
    Protected Overrides Function IsMarshalByRefImpl() As Boolean
        ' Determine whether the type is marshalled by reference.
        If myType.IsMarshalByRef Then
            myElementType = " marshalled by reference"
            Return True
        End If
        Return False
    End Function 'IsMarshalByRefImpl
End Class 'MyTypeDelegatorClass

Public Class MyTypeDemoClass

    Public Shared Sub Main()
        Try
            Dim myType As MyTypeDelegatorClass
            Console.WriteLine("Determine whether MyContextBoundClass is marshalled by reference.")
            ' Determine whether MyContextBoundClass is marshalled by reference.
            myType = New MyTypeDelegatorClass(GetType(MyContextBoundClass))
            If myType.IsMarshalByRef Then
                Console.WriteLine(GetType(MyContextBoundClass).ToString() + " is marshalled by reference.")
            Else
                Console.WriteLine(GetType(MyContextBoundClass).ToString() + " is not marshalled by reference.")
            End If

            ' Determine whether int is marshalled by reference.
            myType = New MyTypeDelegatorClass(GetType(Integer))
            Console.WriteLine(ControlChars.NewLine + "Determine whether int is marshalled by reference.")
            If myType.IsMarshalByRef Then
                Console.WriteLine(GetType(Integer).ToString() + " is marshalled by reference.")
            Else
                Console.WriteLine(GetType(Integer).ToString() + " is not marshalled by reference.")
            End If
        Catch e As Exception
            Console.WriteLine("Exception: {0}", e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'MyTypeDemoClass

' This class is used to demonstrate 'IsMarshalByRefImpl' method.
Public Class MyContextBoundClass
    Inherits ContextBoundObject
    Public myString As String = "This class is used to demonstrate members of the Type class."
End Class 'MyContextBoundClass
using System;
using System.Reflection;
public class MyTypeDelegatorClass : TypeDelegator
{
    public string myElementType = null;
    private Type myType = null ; 
    public MyTypeDelegatorClass(Type myType) : base(myType)
    {
        this.myType = myType;
    }
    // Override IsMarshalByRefImpl.
    protected override bool IsMarshalByRefImpl()
    {
        // Determine whether the type is marshalled by reference.
        if(myType.IsMarshalByRef)
        { 
            myElementType = " marshalled by reference";
            return true;
        }
        return false;
    }
}
public class MyTypeDemoClass
{
    public static void Main()
    {
        try
        {
            MyTypeDelegatorClass myType;
            Console.WriteLine ("Determine whether MyContextBoundClass is marshalled by reference.");
            // Determine whether MyContextBoundClass type is marshalled by reference.
            myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass));
            if( myType.IsMarshalByRef )
            {
                Console.WriteLine(typeof(MyContextBoundClass) + " is marshalled by reference.");
            }
            else
            {
                Console.WriteLine(typeof(MyContextBoundClass) + " is not marshalled by reference.");
            }

            // Determine whether int type is marshalled by reference.
            myType = new MyTypeDelegatorClass(typeof(int));
            Console.WriteLine ("\nDetermine whether int is marshalled by reference.");
            if( myType.IsMarshalByRef)
            {
                Console.WriteLine(typeof(int) + " is marshalled by reference.");
            }
            else
            {
                Console.WriteLine(typeof(int) + " is not marshalled by reference.");
            }
        }
        catch( Exception e )
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
}
// This class is used to demonstrate the IsMarshalByRefImpl method.
public class MyContextBoundClass : ContextBoundObject
{
    public string myString = "This class is used to demonstrate members of the Type class.";
}
using namespace System;
using namespace System::Reflection;
public ref class MyTypeDelegatorClass: public TypeDelegator
{
public:
   String^ myElementType;

private:
   Type^ myType;

public:
   MyTypeDelegatorClass( Type^ myType )
      : TypeDelegator( myType )
   {
      this->myType = myType;
   }

protected:

   // Override IsMarshalByRefImpl.
   virtual bool IsMarshalByRefImpl() override
   {
      // Determine whether the type is marshalled by reference.
      if ( myType->IsMarshalByRef )
      {
         myElementType = " marshalled by reference";
         return true;
      }

      return false;
   }
};

public ref class MyTypeDemoClass{};


// This class is used to demonstrate the IsMarshalByRefImpl method.
public ref class MyContextBoundClass: public ContextBoundObject
{
public:
   String^ myString;
};

int main()
{
   try
   {
      MyTypeDelegatorClass^ myType;
      Console::WriteLine( "Determine whether MyContextBoundClass is marshalled by reference." );
      
      // Determine whether MyContextBoundClass type is marshalled by reference.
      myType = gcnew MyTypeDelegatorClass( MyContextBoundClass::typeid );
      if ( myType->IsMarshalByRef )
      {
         Console::WriteLine( "{0} is marshalled by reference.", MyContextBoundClass::typeid );
      }
      else
      {
         Console::WriteLine( "{0} is not marshalled by reference.", MyContextBoundClass::typeid );
      }
      
      // Determine whether int type is marshalled by reference.
      myType = gcnew MyTypeDelegatorClass( int::typeid );
      Console::WriteLine( "\nDetermine whether int is marshalled by reference." );
      if ( myType->IsMarshalByRef )
      {
         Console::WriteLine( "{0} is marshalled by reference.", int::typeid );
      }
      else
      {
         Console::WriteLine( "{0} is not marshalled by reference.", int::typeid );
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
import System.*;
import System.Reflection.*;

public class MyTypeDelegatorClass extends TypeDelegator
{
    public String myElementType = null;
    private Type myType = null;

    public MyTypeDelegatorClass(Type myType)
    {
        super(myType);
        this.myType = myType;
    } //MyTypeDelegatorClass

    // Override IsMarshalByRefImpl.
    protected boolean IsMarshalByRefImpl()
    {
        // Determine whether the type is marshalled by reference.
        if (myType.get_IsMarshalByRef()) {
            myElementType = " marshalled by reference";
            return true;
        }
        return false;
    } //IsMarshalByRefImpl
} //MyTypeDelegatorClass

public class MyTypeDemoClass
{
    public static void main(String[] args)
    {
        try {
            MyTypeDelegatorClass myType;
            Console.WriteLine("Determine whether MyContextBoundClass is" 
                + " marshalled by reference.");
            // Determine whether MyContextBoundClass type is marshalled
            // by reference.
            myType = new MyTypeDelegatorClass(MyContextBoundClass.
                class.ToType());
            if (myType.get_IsMarshalByRef()) {
                Console.WriteLine(MyContextBoundClass.class.ToType() 
                    + " is marshalled by reference.");
            }
            else {
                Console.WriteLine(MyContextBoundClass.class.ToType() 
                    + " is not marshalled by reference.");
            }
            // Determine whether int type is marshalled by reference.
            myType = new MyTypeDelegatorClass(int.class.ToType());
            Console.WriteLine("\nDetermine whether int is marshalled by" 
                + " reference.");
            if (myType.get_IsMarshalByRef()) {
                Console.WriteLine(int.class.ToType() 
                    + " is marshalled by reference.");
            }
            else {
                Console.WriteLine(int.class.ToType() 
                    + " is not marshalled by reference.");
            }
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception: {0}", e.get_Message());
        }
    } //main
} //MyTypeDemoClass

// This class is used to demonstrate the IsMarshalByRefImpl method.
public class MyContextBoundClass extends ContextBoundObject
{
    public String myString = "This class is used to demonstrate members" 
        + " of the Type class.";
} //MyContextBoundClass

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Type 클래스
Type 멤버
System 네임스페이스
IsMarshalByRef