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)

メソッドに渡された引数の名前を取得します。

適用対象