RealProxy 클래스

정의

프록시의 기본 기능을 제공합니다.

public ref class RealProxy abstract
public abstract class RealProxy
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RealProxy
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public abstract class RealProxy
type RealProxy = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type RealProxy = class
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
type RealProxy = class
Public MustInherit Class RealProxy
상속
RealProxy
특성

예제

// Create a custom 'RealProxy'.
public ref class MyProxy: public RealProxy
{
private:
   String^ myURIString;
   MarshalByRefObject^ myMarshalByRefObject;

public:
   MyProxy( Type^ myType )
      : RealProxy( myType )
   {
      
      // RealProxy uses the Type to generate a transparent proxy.
      myMarshalByRefObject = dynamic_cast<MarshalByRefObject^>(Activator::CreateInstance(myType));
      
      // Get 'ObjRef', for transmission serialization between application domains.
      ObjRef^ myObjRef = RemotingServices::Marshal( myMarshalByRefObject );
      
      // Get the 'URI' property of 'ObjRef' and store it.
      myURIString = myObjRef->URI;
      Console::WriteLine( "URI :{0}", myObjRef->URI );
   }

   virtual IMessage^ Invoke ( IMessage^ myIMessage ) override 
    {
      Console::WriteLine( "MyProxy.Invoke Start" );
      Console::WriteLine( "" );
      if ( dynamic_cast<IMethodCallMessage^>(myIMessage) )
            Console::WriteLine( "IMethodCallMessage" );

      if ( dynamic_cast<IMethodReturnMessage^>(myIMessage) )
            Console::WriteLine( "IMethodReturnMessage" );

      Type^ msgType = myIMessage->GetType();
      Console::WriteLine( "Message Type: {0}", msgType );
      Console::WriteLine( "Message Properties" );
      IDictionary^ myIDictionary = myIMessage->Properties;
      
      // Set the '__Uri' property of 'IMessage' to 'URI' property of 'ObjRef'.
      myIDictionary->default[ "__Uri" ] = myURIString;
      IDictionaryEnumerator^ myIDictionaryEnumerator = dynamic_cast<IDictionaryEnumerator^>(myIDictionary->GetEnumerator());
      while ( myIDictionaryEnumerator->MoveNext() )
      {
         Object^ myKey = myIDictionaryEnumerator->Key;
         String^ myKeyName = myKey->ToString();
         Object^ myValue = myIDictionaryEnumerator->Value;
         Console::WriteLine( "\t{0} : {1}", myKeyName, myIDictionaryEnumerator->Value );
         if ( myKeyName->Equals( "__Args" ) )
         {
            array<Object^>^myObjectArray = (array<Object^>^)myValue;
            for ( int aIndex = 0; aIndex < myObjectArray->Length; aIndex++ )
               Console::WriteLine( "\t\targ: {0} myValue: {1}", aIndex, myObjectArray[ aIndex ] );
         }

         if ( (myKeyName->Equals( "__MethodSignature" )) && (nullptr != myValue) )
         {
            array<Object^>^myObjectArray = (array<Object^>^)myValue;
            for ( int aIndex = 0; aIndex < myObjectArray->Length; aIndex++ )
               Console::WriteLine( "\t\targ: {0} myValue: {1}", aIndex, myObjectArray[ aIndex ] );
         }
      }

      IMessage^ myReturnMessage;
      myIDictionary->default[ "__Uri" ] = myURIString;
      Console::WriteLine( "__Uri {0}", myIDictionary->default[ "__Uri" ] );
      Console::WriteLine( "ChannelServices.SyncDispatchMessage" );
      myReturnMessage = ChannelServices::SyncDispatchMessage( myIMessage );
      
      // Push return value and OUT parameters back onto stack.
      IMethodReturnMessage^ myMethodReturnMessage = dynamic_cast<IMethodReturnMessage^>(myReturnMessage);
      Console::WriteLine( "IMethodReturnMessage.ReturnValue: {0}", myMethodReturnMessage->ReturnValue );
      Console::WriteLine( "MyProxy.Invoke - Finish" );
      return myReturnMessage;
   }
};
// Create a custom 'RealProxy'.
public class MyProxy : RealProxy
{
   String myURIString;
   MarshalByRefObject myMarshalByRefObject;

   public MyProxy(Type myType) : base(myType)
   {
      // RealProxy uses the Type to generate a transparent proxy.
      myMarshalByRefObject = (MarshalByRefObject)Activator.CreateInstance((myType));
      // Get 'ObjRef', for transmission serialization between application domains.
      ObjRef myObjRef = RemotingServices.Marshal(myMarshalByRefObject);
      // Get the 'URI' property of 'ObjRef' and store it.
      myURIString = myObjRef.URI;
      Console.WriteLine("URI :{0}", myObjRef.URI);
   }

   public override IMessage Invoke(IMessage myIMessage)
   {
      Console.WriteLine("MyProxy.Invoke Start");
      Console.WriteLine("");

      if (myIMessage is IMethodCallMessage)
         Console.WriteLine("IMethodCallMessage");

      if (myIMessage is IMethodReturnMessage)
         Console.WriteLine("IMethodReturnMessage");

      Type msgType = myIMessage.GetType();
      Console.WriteLine("Message Type: {0}", msgType.ToString());
      Console.WriteLine("Message Properties");
      IDictionary myIDictionary = myIMessage.Properties;
      // Set the '__Uri' property of 'IMessage' to 'URI' property of 'ObjRef'.
      myIDictionary["__Uri"] = myURIString;
      IDictionaryEnumerator myIDictionaryEnumerator =
         (IDictionaryEnumerator) myIDictionary.GetEnumerator();

      while (myIDictionaryEnumerator.MoveNext())
      {
         Object myKey = myIDictionaryEnumerator.Key;
         String myKeyName = myKey.ToString();
         Object myValue = myIDictionaryEnumerator.Value;

         Console.WriteLine("\t{0} : {1}", myKeyName,
            myIDictionaryEnumerator.Value);
         if (myKeyName == "__Args")
         {
            Object[] myObjectArray = (Object[])myValue;
            for (int aIndex = 0; aIndex < myObjectArray.Length; aIndex++)
               Console.WriteLine("\t\targ: {0} myValue: {1}", aIndex,
                  myObjectArray[aIndex]);
         }

         if ((myKeyName == "__MethodSignature") && (null != myValue))
         {
            Object[] myObjectArray = (Object[])myValue;
            for (int aIndex = 0; aIndex < myObjectArray.Length; aIndex++)
               Console.WriteLine("\t\targ: {0} myValue: {1}", aIndex,
                  myObjectArray[aIndex]);
         }
      }

      IMessage myReturnMessage;

      myIDictionary["__Uri"] = myURIString;
      Console.WriteLine("__Uri {0}", myIDictionary["__Uri"]);

      Console.WriteLine("ChannelServices.SyncDispatchMessage");
      myReturnMessage = ChannelServices.SyncDispatchMessage(myIMessage);

      // Push return value and OUT parameters back onto stack.

      IMethodReturnMessage myMethodReturnMessage = (IMethodReturnMessage)
         myReturnMessage;
      Console.WriteLine("IMethodReturnMessage.ReturnValue: {0}",
         myMethodReturnMessage.ReturnValue);

      Console.WriteLine("MyProxy.Invoke - Finish");

      return myReturnMessage;
   }
}
' Create a custom 'RealProxy'.
Public Class MyProxy
   Inherits RealProxy
   Private myURIString As String
   Private myMarshalByRefObject As MarshalByRefObject

   <PermissionSet(SecurityAction.LinkDemand)> _
   Public Sub New(ByVal myType As Type)
      MyBase.New(myType)
      ' RealProxy uses the Type to generate a transparent proxy.
      myMarshalByRefObject = CType(Activator.CreateInstance(myType), MarshalByRefObject)
      ' Get 'ObjRef', for transmission serialization between application domains.
      Dim myObjRef As ObjRef = RemotingServices.Marshal(myMarshalByRefObject)
      ' Get the 'URI' property of 'ObjRef' and store it.
      myURIString = myObjRef.URI
      Console.WriteLine("URI :{0}", myObjRef.URI)
   End Sub

<SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags:=SecurityPermissionFlag.Infrastructure)> _
   Public Overrides Function Invoke(ByVal myIMessage As IMessage) As IMessage
      Console.WriteLine("MyProxy.Invoke Start")
      Console.WriteLine("")

      If TypeOf myIMessage Is IMethodCallMessage Then
         Console.WriteLine("IMethodCallMessage")
      End If
      If TypeOf myIMessage Is IMethodReturnMessage Then
         Console.WriteLine("IMethodReturnMessage")
      End If
      Dim msgType As Type
      msgType = CObj(myIMessage).GetType
      Console.WriteLine("Message Type: {0}", msgType.ToString())
      Console.WriteLine("Message Properties")
      Dim myIDictionary As IDictionary = myIMessage.Properties
      ' Set the '__Uri' property of 'IMessage' to 'URI' property of 'ObjRef'.
      myIDictionary("__Uri") = myURIString
      Dim myIDictionaryEnumerator As IDictionaryEnumerator = CType(myIDictionary.GetEnumerator(), _
                                                                    IDictionaryEnumerator)

      While myIDictionaryEnumerator.MoveNext()
         Dim myKey As Object = myIDictionaryEnumerator.Key
         Dim myKeyName As String = myKey.ToString()
         Dim myValue As Object = myIDictionaryEnumerator.Value

         Console.WriteLine(ControlChars.Tab + "{0} : {1}", myKeyName, myIDictionaryEnumerator.Value)
         If myKeyName = "__Args" Then
            Dim myObjectArray As Object() = CType(myValue, Object())
            Dim aIndex As Integer
            For aIndex = 0 To myObjectArray.Length - 1
               Console.WriteLine(ControlChars.Tab + ControlChars.Tab + "arg: {0} myValue: {1}", _
                                                              aIndex, myObjectArray(aIndex))
             Next aIndex
         End If

         If myKeyName = "__MethodSignature" And Not Nothing Is myValue Then
            Dim myObjectArray As Object() = CType(myValue, Object())
            Dim aIndex As Integer
            For aIndex = 0 To myObjectArray.Length - 1
               Console.WriteLine(ControlChars.Tab + ControlChars.Tab + "arg: {0} myValue: {1}", _
                                                           aIndex, myObjectArray(aIndex))
            Next aIndex
         End If
      End While

        Dim myReturnMessage As IMessage

        myIDictionary("__Uri") = myURIString
        Console.WriteLine("__Uri {0}", myIDictionary("__Uri"))

        Console.WriteLine("ChannelServices.SyncDispatchMessage")
        myReturnMessage = ChannelServices.SyncDispatchMessage(CObj(myIMessage))

        ' Push return value and OUT parameters back onto stack.
        Dim myMethodReturnMessage As IMethodReturnMessage = CType(myReturnMessage, IMethodReturnMessage)
        Console.WriteLine("IMethodReturnMessage.ReturnValue: {0}", myMethodReturnMessage.ReturnValue)

        Console.WriteLine("MyProxy.Invoke - Finish")

        Return myReturnMessage
    End Function 'Invoke
End Class

설명

RealProxy 클래스는 abstract 기본 프록시가 파생 되어야 하는 클래스입니다.

모든 종류의 remoting 경계 간에 개체를 사용 하는 클라이언트 실제로 투명 프록시를 사용 하 여 개체에 대 한 됩니다. 투명 프록시는 실제 개체는 클라이언트의 공간에 상주 하는 효과 제공 합니다. 원격 인프라를 사용 하 여 실제 개체에 대해 호출을 전달 하 여 달성 합니다.

투명 프록시 형식의 관리 되는 런타임 클래스의 인스턴스 자체는 RealProxy합니다. RealProxy 투명 프록시에서 작업을 전달 하는 데 필요한 기능 중 일부를 구현 합니다. 참고 프록시 개체는 가비지 컬렉션, 필드 및 메서드를 실행 하는 것에 대 한 지원 등의 관리 되는 개체의 연결 된 의미 체계를 상속 하며 양식 새 클래스를 확장할 수 있습니다. 프록시는 이중 특성: 원격 개체 (투명 프록시)와 동일한 클래스의 개체와 작동 하 고 자체 관리 되는 개체입니다.

모든 원격 하나당에 관계 없이 프록시 개체를 사용할 수는 AppDomain합니다.

참고

이 클래스는 클래스 수준에서 상속 요청과 링크 요청을 만듭니다. SecurityException 직접 실행 호출자 또는 파생된 클래스 중 하나에 인프라 권한이 없는 경우 throw 됩니다. 보안 요청에 대 한 자세한 내용은 참조 하세요 링크 요청 하 고 상속 요청합니다.

구현자 참고

상속 하는 경우 RealProxy를 재정의 해야 합니다는 Invoke(IMessage) 메서드.

생성자

RealProxy()

기본값을 사용하여 RealProxy 클래스의 새 인스턴스를 초기화합니다.

RealProxy(Type)

지정된 RealProxy의 원격 개체를 나타내는 Type 클래스의 새 인스턴스를 초기화합니다.

RealProxy(Type, IntPtr, Object)

RealProxy 클래스의 새 인스턴스를 초기화합니다.

메서드

AttachServer(MarshalByRefObject)

지정된 원격 MarshalByRefObject에 현재 프록시 인스턴스를 연결합니다.

CreateObjRef(Type)

지정된 개체 형식에 대해 ObjRef를 만들고 클라이언트 활성 개체로 원격 인프라와 함께 등록합니다.

DetachServer()

현재 프록시 인스턴스가 나타내는 원격 서버 개체로부터 해당 인스턴스를 분리합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetCOMIUnknown(Boolean)

현재 프록시 인스턴스가 표시하는 개체에 대해 관리되지 않는 참조를 요청합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

RealProxy의 현재 인스턴스에서 나타내는 개체의 투명 프록시를 지정된 SerializationInfo에 추가합니다.

GetProxiedType()

Type의 현재 인스턴스가 나타내는 개체의 RealProxy을 반환합니다.

GetStubData(RealProxy)

지정된 프록시에 저장된 스텁 데이터를 가져옵니다.

GetTransparentProxy()

RealProxy의 현재 인스턴스에 대한 투명 프록시를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetUnwrappedServer()

현재 프록시 인스턴스가 나타내는 서버 개체를 반환합니다.

InitializeServerObject(IConstructionCallMessage)

지정된 Type를 사용하여 RealProxy의 현재 인스턴스가 나타내는 원격 개체에 대한 개체 IConstructionCallMessage의 새 인스턴스를 초기화합니다.

Invoke(IMessage)

파생 클래스에서 재정의되면 현재 인스턴스가 나타내는 원격 개체에서 제공된 IMessage에 지정된 메서드를 호출합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SetCOMIUnknown(IntPtr)

현재 인스턴스에서 나타내는 개체의 비관리 프록시를 저장합니다.

SetStubData(RealProxy, Object)

지정된 프록시에 스텁 데이터를 설정합니다.

SupportsInterface(Guid)

지정된 ID로 COM 인터페이스를 요청합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상