本文整理汇总了C#中System.Runtime.Remoting.Messaging.IMethodReturnMessage接口的典型用法代码示例。如果您正苦于以下问题:C# IMethodReturnMessage接口的具体用法?C# IMethodReturnMessage怎么用?C# IMethodReturnMessage使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
IMethodReturnMessage接口属于System.Runtime.Remoting.Messaging命名空间,在下文中一共展示了IMethodReturnMessage接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyProxy
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class MyProxy : RealProxy
{
String stringUri;
MarshalByRefObject myMarshalByRefObject;
public MyProxy(Type myType): base(myType)
{
myMarshalByRefObject = (MarshalByRefObject)Activator.CreateInstance(myType);
ObjRef myObject = RemotingServices.Marshal(myMarshalByRefObject);
stringUri = myObject.URI;
}
public override IMessage Invoke(IMessage myMessage)
{
IMethodCallMessage myCallMessage = (IMethodCallMessage)myMessage;
IMethodReturnMessage myIMethodReturnMessage =
RemotingServices.ExecuteMessage(myMarshalByRefObject, myCallMessage);
Console.WriteLine("Method name : " + myIMethodReturnMessage.MethodName);
Console.WriteLine("The return value is : " + myIMethodReturnMessage.ReturnValue);
// Get number of 'ref' and 'out' parameters.
int myArgOutCount = myIMethodReturnMessage.OutArgCount;
Console.WriteLine("The number of 'ref', 'out' parameters are : " +
myIMethodReturnMessage.OutArgCount);
// Gets name and values of 'ref' and 'out' parameters.
for(int i = 0; i < myArgOutCount; i++)
{
Console.WriteLine("Name of argument {0} is '{1}'.",
i, myIMethodReturnMessage.GetOutArgName(i));
Console.WriteLine("Value of argument {0} is '{1}'.",
i, myIMethodReturnMessage.GetOutArg(i));
}
Console.WriteLine();
object[] myObjectArray = myIMethodReturnMessage.OutArgs;
for(int i = 0; i < myObjectArray.Length; i++)
Console.WriteLine("Value of argument {0} is '{1}' in OutArgs",
i, myObjectArray[i]);
return myIMethodReturnMessage;
}
}