IMethodMessage 인터페이스

정의

메서드 메시지 인터페이스를 정의합니다.

public interface class IMethodMessage : System::Runtime::Remoting::Messaging::IMessage
public interface IMethodMessage : System.Runtime.Remoting.Messaging.IMessage
[System.Runtime.InteropServices.ComVisible(true)]
public interface IMethodMessage : System.Runtime.Remoting.Messaging.IMessage
type IMethodMessage = interface
    interface IMessage
[<System.Runtime.InteropServices.ComVisible(true)>]
type IMethodMessage = interface
    interface IMessage
Public Interface IMethodMessage
Implements IMessage
파생
특성
구현

예제

다음 예제 코드에서는 사용자 지정 프록시를 해당 재정의 RealProxy.Invoke 메시지 정보를 콘솔에 작성 하 고 원격 호출을 수행 하지 않고 즉시 반환 하기 위해.

// This class requires full trust
[PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")]
public ref class MyProxyClass: public RealProxy
{
private:
   Object^ myObjectInstance;
   Type^ myType;

public:
   MyProxyClass( Type^ argType )
      : RealProxy( argType )
   {
      myType = argType;
      myObjectInstance = Activator::CreateInstance( argType );
   }

   // Overriding the Invoke method of RealProxy.
   virtual IMessage^ Invoke( IMessage^ message ) override
   {
      IMethodMessage^ myMethodMessage = dynamic_cast<IMethodMessage^>(message);
      Console::WriteLine( "**** Begin Invoke ****" );
      Console::WriteLine( "\tType is : {0}", myType );
      Console::WriteLine( "\tMethod name : {0}", myMethodMessage->MethodName );
      for ( int i = 0; i < myMethodMessage->ArgCount; i++ )
      {
         Console::WriteLine( "\tArgName is : {0}", myMethodMessage->GetArgName( i ) );
         Console::WriteLine( "\tArgValue is: {0}", myMethodMessage->GetArg( i ) );

      }
      if ( myMethodMessage->HasVarArgs )
            Console::WriteLine( "\t The method have variable arguments!!" );
      else
            Console::WriteLine( "\t The method does not have variable arguments!!" );

      
      // Dispatch the method call to the real Object*.
      Object^ returnValue = myType->InvokeMember( myMethodMessage->MethodName, BindingFlags::InvokeMethod, nullptr, myObjectInstance, myMethodMessage->Args );
      Console::WriteLine( "**** End Invoke ****" );
      
      // Build the return message to pass back to the transparent proxy.
      ReturnMessage^ myReturnMessage = gcnew ReturnMessage( returnValue,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(message) );
      return myReturnMessage;
   }
};
public class MyProxyClass : RealProxy
{
   private Object  myObjectInstance  = null;
   private Type    myType      = null;

   public MyProxyClass(Type argType) : base(argType)
   {
      myType = argType;
      myObjectInstance = Activator.CreateInstance(argType);
   }

   // Overriding the Invoke method of RealProxy.
   public override IMessage Invoke(IMessage message)
   {
      IMethodMessage myMethodMessage = (IMethodMessage)message;

      Console.WriteLine("**** Begin Invoke ****");
      Console.WriteLine("\tType is : " + myType);
      Console.WriteLine("\tMethod name : " +  myMethodMessage.MethodName);

      for (int i=0; i < myMethodMessage.ArgCount; i++)
      {
         Console.WriteLine("\tArgName is : " + myMethodMessage.GetArgName(i));
         Console.WriteLine("\tArgValue is: " + myMethodMessage.GetArg(i));
      }

      if(myMethodMessage.HasVarArgs)
          Console.WriteLine("\t The method have variable arguments!!");
      else
          Console.WriteLine("\t The method does not have variable arguments!!");

      // Dispatch the method call to the real object.
      Object returnValue = myType.InvokeMember( myMethodMessage.MethodName, BindingFlags.InvokeMethod, null,
                                           myObjectInstance, myMethodMessage.Args );
      Console.WriteLine("**** End Invoke ****");

      // Build the return message to pass back to the transparent proxy.
      ReturnMessage myReturnMessage = new ReturnMessage( returnValue, null, 0, null,
          (IMethodCallMessage)message );
      return myReturnMessage;
   }
}
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Public Class MyProxyClass
   Inherits RealProxy
   Private myObjectInstance As Object = Nothing
   Private myType As Type = Nothing
   
   Public Sub New(argType As Type)
      MyBase.New(argType)
      myType = argType
      myObjectInstance = Activator.CreateInstance(argType)
   End Sub
   
   ' Overriding the Invoke method of RealProxy.
   Public Overrides Function Invoke(message As IMessage) As IMessage
      Dim myMethodMessage As IMethodMessage = CType(message, IMethodMessage)
      
      Console.WriteLine("**** Begin Invoke ****")
      Console.WriteLine(ControlChars.Tab + "Type is : " + myType.ToString())
      Console.WriteLine(ControlChars.Tab + "Method name : " + myMethodMessage.MethodName)
      
      Dim i As Integer
      For i = 0 To myMethodMessage.ArgCount - 1
         Console.WriteLine(ControlChars.Tab + "ArgName is : " + myMethodMessage.GetArgName(i))
         Console.WriteLine(ControlChars.Tab + "ArgValue is: " + myMethodMessage.GetArg(i))
      Next i
      
      If myMethodMessage.HasVarArgs Then
         Console.WriteLine(ControlChars.Tab + " The method have variable arguments!!")
      Else
         Console.WriteLine(ControlChars.Tab + " The method does not have variable arguments!!")
      End If 
      ' Dispatch the method call to the real object.
      Dim returnValue As Object = myType.InvokeMember(myMethodMessage.MethodName, _
                     BindingFlags.InvokeMethod, Nothing, myObjectInstance, myMethodMessage.Args)
      Console.WriteLine("**** End Invoke ****")
      
      ' Build the return message to pass back to the transparent proxy.
      Dim myReturnMessage As New ReturnMessage(returnValue, Nothing, 0, Nothing, _
                                                         CType(message, IMethodCallMessage))
      Return myReturnMessage
   End Function 'Invoke
End Class

설명

메서드 메시지는 정보를 보내고 원격 메서드에서 합니다. 원격 메서드 호출에 사용 되는 메시지의 구현 예를 들어를 IMethodMessage 인터페이스입니다.

속성

ArgCount

‘메서드에 전달된 인수의 개수를 가져옵니다.

Args

메서드에 전달된 인수의 배열을 가져옵니다.

HasVarArgs

메시지에 가변 인수가 있는지 나타내는 값을 가져옵니다.

LogicalCallContext

현재 메서드 호출에 대한 LogicalCallContext를 가져옵니다.

MethodBase

호출된 메서드의 MethodBase를 가져옵니다.

MethodName

호출된 메서드의 이름을 가져옵니다.

MethodSignature

메서드 시그니처가 들어 있는 개체를 가져옵니다.

Properties

메시지의 속성 컬렉션을 나타내는 IDictionary를 가져옵니다.

(다음에서 상속됨 IMessage)
TypeName

호출이 향하는 특정 개체의 전체 Type 이름을 가져옵니다.

Uri

호출이 향하는 특정 개체의 URI를 가져옵니다.

메서드

GetArg(Int32)

특정 인수를 Object로 가져옵니다.

GetArgName(Int32)

메서드에 전달된 인수의 이름을 가져옵니다.

적용 대상