IMethodMessage IMethodMessage IMethodMessage IMethodMessage Interface

Definición

Define la interfaz de mensajes de métodos.Defines the method message interface.

public interface class IMethodMessage : System::Runtime::Remoting::Messaging::IMessage
[System.Runtime.InteropServices.ComVisible(true)]
public interface IMethodMessage : System.Runtime.Remoting.Messaging.IMessage
type IMethodMessage = interface
    interface IMessage
Public Interface IMethodMessage
Implements IMessage
Derivado
Atributos
Implementaciones

Ejemplos

RealProxy.Invoke En el ejemplo de código siguiente se muestra un proxy personalizado que invalida para escribir la información del mensaje en la consola y volver inmediatamente sin hacer una llamada remota.The following example code shows a custom proxy that overrides RealProxy.Invoke in order to write the message information to the console and return immediately without making a remote call.

// 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;
   }
};
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
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

Comentarios

Un mensaje de método se utiliza para enviar información hacia y desde métodos remotos.A method message is used to send information to and from remote methods. Por ejemplo, los mensajes que se usan para llamadas a IMethodMessage métodos remotos implementan la interfaz.For example, messages used for remote method calls implement the IMethodMessage interface.

Propiedades

ArgCount ArgCount ArgCount ArgCount

Obtiene el número de argumentos pasados al método.Gets the number of arguments passed to the method.

Args Args Args Args

Obtiene la matriz de argumentos pasados al método.Gets an array of arguments passed to the method.

HasVarArgs HasVarArgs HasVarArgs HasVarArgs

Obtiene un valor que indica si el mensaje contiene argumentos de variable.Gets a value indicating whether the message has variable arguments.

LogicalCallContext LogicalCallContext LogicalCallContext LogicalCallContext

Obtiene el valor de LogicalCallContext para la llamada de método actual.Gets the LogicalCallContext for the current method call.

MethodBase MethodBase MethodBase MethodBase

Obtiene el objeto MethodBase del método invocado.Gets the MethodBase of the called method.

MethodName MethodName MethodName MethodName

Obtiene el nombre del método invocado.Gets the name of the invoked method.

MethodSignature MethodSignature MethodSignature MethodSignature

Obtiene un objeto que contiene la firma del método.Gets an object containing the method signature.

Properties Properties Properties Properties

Obtiene una IDictionary que representa una colección de propiedades de los mensajes.Gets an IDictionary that represents a collection of the message's properties.

(Inherited from IMessage)
TypeName TypeName TypeName TypeName

Obtiene el nombre completo de Type del objeto específico al que se destina la llamada.Gets the full Type name of the specific object that the call is destined for.

Uri Uri Uri Uri

Obtiene la dirección URI del objeto específico al que se destina la llamada.Gets the URI of the specific object that the call is destined for.

Métodos

GetArg(Int32) GetArg(Int32) GetArg(Int32) GetArg(Int32)

Obtiene un argumento específico como un Object.Gets a specific argument as an Object.

GetArgName(Int32) GetArgName(Int32) GetArgName(Int32) GetArgName(Int32)

Obtiene el nombre del argumento pasado al método.Gets the name of the argument passed to the method.

Se aplica a