本文整理匯總了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;
}
}