本文整理汇总了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;未经允许,请勿转载。 |
请发表评论