當前位置: 首頁>>代碼示例>>C#>>正文


C# IMethodMessage接口代碼示例

本文整理匯總了C#中System.Runtime.Remoting.Messaging.IMethodMessage接口的典型用法代碼示例。如果您正苦於以下問題:C# IMethodMessage接口的具體用法?C# IMethodMessage怎麽用?C# IMethodMessage使用的例子?那麽, 這裏精選的接口代碼示例或許可以為您提供幫助。


IMethodMessage接口屬於System.Runtime.Remoting.Messaging命名空間,在下文中一共展示了IMethodMessage接口的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MyProxyClass

[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;
   }
}
開發者ID:.NET開發者,項目名稱:System.Runtime.Remoting.Messaging,代碼行數:43,代碼來源:IMethodMessage


注:本文中的System.Runtime.Remoting.Messaging.IMethodMessage接口示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。