Type.IsMarshalByRef 속성

정의

Type이 참조로 마샬링되는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsMarshalByRef { bool get(); };
public bool IsMarshalByRef { get; }
member this.IsMarshalByRef : bool
Public ReadOnly Property IsMarshalByRef As Boolean

속성 값

Boolean

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

구현

예제

다음 예제에서는 IsContextful 합니다 IsMarshalByRef , , 및 의 IsPrimitive 속성을 Type 클래스입니다. 지정된 형식을 컨텍스트에서 호스트할 수 있는지 여부, 참조로 마샬링할 수 있는지 여부 및 형식이 기본 데이터 형식인지 여부를 확인합니다.

using namespace System;
using namespace System::Runtime::Remoting::Contexts;

public ref class ContextBoundClass: public ContextBoundObject
{
   public:
      String^ Value;
};

public ref class Example
{
public:
   void Demo()
   {
      // Determine whether the types can be hosted in a Context.
      Console::WriteLine("The IsContextful property for the {0} type is {1}.",
                         Example::typeid->Name, Example::typeid->IsContextful);
      Console::WriteLine("The IsContextful property for the {0} type is {1}.",
                         ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsContextful);
      
      // Determine whether the types are marshalled by reference.
      Console::WriteLine("The IsMarshalByRef property of {0} is {1}.",
                         Example::typeid->Name, Example::typeid->IsMarshalByRef );
      Console::WriteLine("The IsMarshalByRef property of {0} is {1}.",
                         ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsMarshalByRef );
      
      // Determine whether the types are primitive datatypes.
      Console::WriteLine("{0} is a primitive data type: {1}.",
                         int::typeid->Name, int::typeid->IsPrimitive );
      Console::WriteLine("{0} is a primitive data type: {1}.",
                         String::typeid->Name, String::typeid->IsPrimitive );
   }
};

int main()
{
   Example^ ex = gcnew Example;
   ex->Demo();
}
// The example displays the following output:
//    The IsContextful property for the Example type is False.
//    The IsContextful property for the ContextBoundClass type is True.
//    The IsMarshalByRef property of Example is False.
//    The IsMarshalByRef property of ContextBoundClass is True.
//    Int32 is a primitive data type: True.
//    String is a primitive data type: False.
using System;
using System.Runtime.Remoting.Contexts;

public class ContextBoundClass: ContextBoundObject
{
    public string Value = "The Value property.";
}

public class Example
{
    public static void Main()
    {
         // Determine whether the types can be hosted in a Context.
         Console.WriteLine("The IsContextful property for the {0} type is {1}.",
                           typeof(Example).Name, typeof(Example).IsContextful);
         Console.WriteLine("The IsContextful property for the {0} type is {1}.",
                           typeof(ContextBoundClass).Name, typeof(ContextBoundClass).IsContextful);

         // Determine whether the types are marshalled by reference.
         Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
                           typeof(Example).Name, typeof(Example).IsMarshalByRef);
         Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
                           typeof(ContextBoundClass).Name, typeof(ContextBoundClass).IsMarshalByRef);

         // Determine whether the types are primitive datatypes.
         Console.WriteLine("{0} is a primitive data type: {1}.",
                           typeof(int).Name, typeof(int).IsPrimitive);
         Console.WriteLine("{0} is a primitive data type: {1}.",
                           typeof(string).Name, typeof(string).IsPrimitive);
    }
}
// The example displays the following output:
//    The IsContextful property for the Example type is False.
//    The IsContextful property for the ContextBoundClass type is True.
//    The IsMarshalByRef property of Example is False.
//    The IsMarshalByRef property of ContextBoundClass is True.
//    Int32 is a primitive data type: True.
//    String is a primitive data type: False.
Imports System.Runtime.Remoting.Contexts

Public Class ContextBoundClass : Inherits ContextBoundObject
    Public Value As String = "The Value property."
End Class

Public Class Example
    Public Shared Sub Main()
         ' Determine whether the types can be hosted in a Context.
         Console.WriteLine("The IsContextful property for the {0} type is {1}.",
                           GetType(Example).Name, GetType(Example).IsContextful)
         Console.WriteLine("The IsContextful property for the {0} type is {1}.",
                           GetType(ContextBoundClass).Name, GetType(ContextBoundClass).IsContextful)
         ' Determine whether the types are marshalled by reference.
         Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
                           GetType(Example).Name, GetType(Example).IsMarshalByRef)
         Console.WriteLine("The IsMarshalByRef property of {0} is {1}.",
                           GetType(ContextBoundClass).Name, GetType(ContextBoundClass).IsMarshalByRef)
         ' Determine whether the types are primitive datatypes.
         Console.WriteLine("{0} is a primitive data type: {1}.",
                           GetType(Integer).Name, GetType(Integer).IsPrimitive)
         Console.WriteLine("{0} is a primitive data type: {1}.",
                           GetType(String).Name, GetType(String).IsPrimitive)
    End Sub
End Class
' The example displays the following output:
'    The IsContextful property for the Example type is False.
'    The IsContextful property for the ContextBoundClass type is True.
'    The IsMarshalByRef property of Example is False.
'    The IsMarshalByRef property of ContextBoundClass is True.
'    Int32 is a primitive data type: True.
'    String is a primitive data type: False.

적용 대상

추가 정보