IMethodCallMessage Arabirim

Tanım

Yöntem çağrı iletisi arabirimini tanımlar.

public interface class IMethodCallMessage : System::Runtime::Remoting::Messaging::IMethodMessage
public interface IMethodCallMessage : System.Runtime.Remoting.Messaging.IMethodMessage
[System.Runtime.InteropServices.ComVisible(true)]
public interface IMethodCallMessage : System.Runtime.Remoting.Messaging.IMethodMessage
type IMethodCallMessage = interface
    interface IMethodMessage
    interface IMessage
[<System.Runtime.InteropServices.ComVisible(true)>]
type IMethodCallMessage = interface
    interface IMethodMessage
    interface IMessage
Public Interface IMethodCallMessage
Implements IMethodMessage
Türetilmiş
Öznitelikler
Uygulamalar

Örnekler

using namespace System;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Proxies;
using namespace System::Runtime::Remoting::Messaging;

// MyProxy extends the CLR Remoting RealProxy.
// In the same class, in the Invoke method, the methods and properties of the 
// IMethodCallMessage are demonstrated.

[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::LinkDemand, 
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]
[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::InheritanceDemand, 
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]

public ref class MyProxy: public RealProxy
{
public:
   MyProxy( Type^ myType )
      : RealProxy( myType )
   {
      // This constructor forwards the call to base RealProxy.
      // RealProxy uses the Type to generate a transparent proxy.
   }

   virtual IMessage^ Invoke( IMessage^ myIMessage ) override
   {
      Console::WriteLine( "MyProxy::Invoke Start" );
      Console::WriteLine( "" );
      ReturnMessage^ myReturnMessage = nullptr;
      if ( dynamic_cast<IMethodCallMessage^>(myIMessage) )
      {
         Console::WriteLine( "Message is of type 'IMethodCallMessage*'." );
         Console::WriteLine( "" );
         IMethodCallMessage^ myIMethodCallMessage;
         myIMethodCallMessage = dynamic_cast<IMethodCallMessage^>(myIMessage);
         Console::WriteLine( "InArgCount is  : {0}", myIMethodCallMessage->InArgCount );
         IEnumerator^ myEnum = myIMethodCallMessage->InArgs->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            Object^ myObj = safe_cast<Object^>(myEnum->Current);
            Console::WriteLine( "InArgs is : {0}", myObj );
         }

         for ( int i = 0; i < myIMethodCallMessage->InArgCount; i++ )
         {
            Console::WriteLine( "GetArgName({0}) is : {1}", i, myIMethodCallMessage->GetArgName( i ) );
            Console::WriteLine( "GetInArg({0}) is : {0}", i, myIMethodCallMessage->GetInArg( i ) );

         }
         Console::WriteLine( "" );
      }
      else
      if ( dynamic_cast<IMethodReturnMessage^>(myIMessage) )
            Console::WriteLine( "Message is of type 'IMethodReturnMessage*'." );

      // Build Return Message 
      myReturnMessage = gcnew ReturnMessage( 5,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(myIMessage) );
      Console::WriteLine( "MyProxy::Invoke - Finish" );
      return myReturnMessage;
   }
};

// The class used to obtain Metadata.
public ref class MyMarshalByRefClass: public MarshalByRefObject
{
public:
   int MyMethod( String^ str, double dbl, int i )
   {
      Console::WriteLine( "MyMarshalByRefClass::MyMethod {0} {1} {2}", str, dbl, i );
      return 0;
   }

};

// Main routine that drives the whole sample.
int main()
{
   Console::WriteLine( "Generate a new MyProxy." );
   MyProxy^ myProxy = gcnew MyProxy( MyMarshalByRefClass::typeid );
   Console::WriteLine( "Obtain the transparent proxy from myProxy." );
   MyMarshalByRefClass^ myMarshalByRefClassObj = dynamic_cast<MyMarshalByRefClass^>(myProxy->GetTransparentProxy());
   Console::WriteLine( "Calling the Proxy." );
   Object^ myReturnValue = myMarshalByRefClassObj->MyMethod( "Microsoft", 1.2, 6 );
   Console::WriteLine( "Sample Done." );
   return 0;
}
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;

namespace IMethodCallMessageNS
{
   // MyProxy extends the CLR Remoting RealProxy.
   // In the same class, in the Invoke method, the methods and properties of the
   // IMethodCallMessage are demonstrated.

   public class MyProxy : RealProxy
   {
      public MyProxy(Type myType) : base(myType)
      {
         // This constructor forwards the call to base RealProxy.
         // RealProxy uses the Type to generate a transparent proxy.
      }


      public override IMessage Invoke(IMessage myIMessage)
      {
         Console.WriteLine("MyProxy.Invoke Start");
         Console.WriteLine("");
         ReturnMessage myReturnMessage = null;

         if (myIMessage is IMethodCallMessage)
         {
            Console.WriteLine("Message is of type 'IMethodCallMessage'.");
            Console.WriteLine("");

            IMethodCallMessage myIMethodCallMessage;
            myIMethodCallMessage=(IMethodCallMessage)myIMessage;
            Console.WriteLine("InArgCount is  : " +
                              myIMethodCallMessage.InArgCount.ToString());

            foreach (object myObj in myIMethodCallMessage.InArgs)
            {
               Console.WriteLine("InArgs is : " + myObj.ToString());
            }

            for(int i=0; i<myIMethodCallMessage.InArgCount; i++)
            {
               Console.WriteLine("GetArgName(" +i.ToString() +") is : " +
                                       myIMethodCallMessage.GetArgName(i));
               Console.WriteLine("GetInArg("+i.ToString() +") is : " +
                              myIMethodCallMessage.GetInArg(i).ToString());
            }
            Console.WriteLine("");
         }
         else if (myIMessage is IMethodReturnMessage)
            {
                Console.WriteLine("Message is of type 'IMethodReturnMessage'.");
            }

            // Build Return Message
            myReturnMessage = new ReturnMessage(5,null,0,null,
                                       (IMethodCallMessage)myIMessage);

         Console.WriteLine("MyProxy.Invoke - Finish");
         return myReturnMessage;
      }
   }

   // The class used to obtain Metadata.
   public class MyMarshalByRefClass : MarshalByRefObject
   {
      public int MyMethod(string str, double dbl, int i)
      {
         Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i);
         return 0;
      }
   }
   // Main class that drives the whole sample.
   public class ProxySample
   {
      public static void Main()
      {
         Console.WriteLine("Generate a new MyProxy.");
         MyProxy myProxy = new MyProxy(typeof(MyMarshalByRefClass));

         Console.WriteLine("Obtain the transparent proxy from myProxy.");
         MyMarshalByRefClass myMarshalByRefClassObj =
                              (MyMarshalByRefClass)myProxy.GetTransparentProxy();

         Console.WriteLine("Calling the Proxy.");
         object myReturnValue = myMarshalByRefClassObj.MyMethod("Microsoft", 1.2, 6);

         Console.WriteLine("Sample Done.");
      }
   }
}
Imports System.Collections
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Proxies
Imports System.Runtime.Remoting.Messaging
Imports System.Security.Permissions

Namespace IMethodCallMessageNS

   ' MyProxy extends the CLR Remoting RealProxy.
   ' In the same class, in the Invoke method, we demonstrate the
   ' methods and properties of the IMethodCallMessage.

   <PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
   Public Class MyProxy
      Inherits RealProxy

      Public Sub New(ByVal myType As Type)
         ' This constructor forwards the call to base RealProxy.
         ' RealProxy uses the Type to generate a transparent proxy.
         MyBase.New(myType)
      End Sub

      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("Message is of type 'IMethodCallMessage'.")
            Console.WriteLine("")

            Dim myIMethodCallMessage As IMethodCallMessage
            myIMethodCallMessage = CType(myIMessage, IMethodCallMessage)

            Console.WriteLine("InArgCount is : " + myIMethodCallMessage.InArgCount.ToString)
            Dim myObj As Object
            For Each myObj In myIMethodCallMessage.InArgs
               Console.WriteLine("InArgs is : " + myObj.ToString())
            Next

            Dim i As Integer
            For i = 0 To myIMethodCallMessage.InArgCount - 1
               Console.WriteLine("GetArgName(" + i.ToString() + ") is : " + myIMethodCallMessage.GetArgName(i))
               Console.WriteLine("GetInArg(" + i.ToString() + ") is : " + myIMethodCallMessage.GetInArg(i).ToString)
            Next i

            Console.WriteLine("")
         ElseIf TypeOf myIMessage Is IMethodReturnMessage Then
            Console.WriteLine("Message is of type 'IMethodReturnMessage'.")
         End If

         ' Build Return Message
         Dim myReturnMessage As New ReturnMessage(5, Nothing, 0, Nothing, _
                                    CType(myIMessage, IMethodCallMessage))

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

      End Function 'Invoke



   End Class

   ' The class used to obtain Metadata.
   <PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
   Public Class MyMarshalByRefClass
      Inherits MarshalByRefObject

      Public Function MyMethod(ByVal str As String, ByVal dbl As Double, ByVal i As Integer) As Integer
         Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i)
         Return 0
      End Function 'MyMethod
   End Class

   ' Main class that drives the whole sample.
   Public Class ProxySample

      <SecurityPermission(SecurityAction.LinkDemand)> _
      Shared Sub Main()
         Console.WriteLine("Generate a new MyProxy.")
         Dim myProxy As New MyProxy(GetType(MyMarshalByRefClass))

         Console.WriteLine("Obtain the transparent proxy from myProxy.")
         Dim myMarshalByRefClassObj As MyMarshalByRefClass = _
                        CType(myProxy.GetTransparentProxy(), MyMarshalByRefClass)

         Console.WriteLine("Calling the Proxy.")
         Dim myReturnValue As Object = myMarshalByRefClassObj.MyMethod("Microsoft", 1.2, 6)

         Console.WriteLine("Sample Done.")
      End Sub
   End Class
End Namespace 'IMethodCallMessageNS

Açıklamalar

uzak IMethodCallMessage nesnede çağrılan bir yöntemin sonucu olarak oluşturulur ve uzak yöntem çağrısı hakkındaki ayrıntıları sunucu tarafına taşımak için kullanılır.

Özellikler

ArgCount

yöntemine geçirilen bağımsız değişkenlerin sayısını alır.

(Devralındığı yer: IMethodMessage)
Args

yöntemine geçirilen bir bağımsız değişken dizisi alır.

(Devralındığı yer: IMethodMessage)
HasVarArgs

İletinin değişken bağımsız değişkenleri olup olmadığını belirten bir değer alır.

(Devralındığı yer: IMethodMessage)
InArgCount

Çağrıdaki parametre olarak out işaretlenmemiş bağımsız değişkenlerin sayısını alır.

InArgs

Parametre olarak out işaretlenmemiş bir bağımsız değişken dizisi alır.

LogicalCallContext

Geçerli yöntem çağrısı için öğesini LogicalCallContext alır.

(Devralındığı yer: IMethodMessage)
MethodBase

MethodBase Çağrılan yöntemin öğesini alır.

(Devralındığı yer: IMethodMessage)
MethodName

Çağrılan yöntemin adını alır.

(Devralındığı yer: IMethodMessage)
MethodSignature

Yöntem imzasını içeren bir nesne alır.

(Devralındığı yer: IMethodMessage)
Properties

İletinin özelliklerinin koleksiyonunu temsil eden bir IDictionary alır.

(Devralındığı yer: IMessage)
TypeName

Çağrının hedeflendiği nesnenin tam Type adını alır.

(Devralındığı yer: IMethodMessage)
Uri

Çağrının hedeflendiği nesnenin URI'sini alır.

(Devralındığı yer: IMethodMessage)

Yöntemler

GetArg(Int32)

Belirli bir bağımsız değişkeni olarak Objectalır.

(Devralındığı yer: IMethodMessage)
GetArgName(Int32)

yöntemine geçirilen bağımsız değişkenin adını alır.

(Devralındığı yer: IMethodMessage)
GetInArg(Int32)

Parametre olarak out işaretlenmemiş belirtilen bağımsız değişkeni döndürür.

GetInArgName(Int32)

Parametre olarak out işaretlenmemiş belirtilen bağımsız değişkenin adını döndürür.

Şunlara uygulanır