本文整理汇总了C#中System.Runtime.Remoting.Messaging.ReturnMessage类的典型用法代码示例。如果您正苦于以下问题:C# ReturnMessage类的具体用法?C# ReturnMessage怎么用?C# ReturnMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReturnMessage类属于System.Runtime.Remoting.Messaging命名空间,在下文中一共展示了ReturnMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Invoke
public override System.Runtime.Remoting.Messaging.IMessage Invoke(System.Runtime.Remoting.Messaging.IMessage msg)
{
IMethodCallMessage mcMsg = msg as IMethodCallMessage;
if (mcMsg != null)
{
ReturnMessage rlt = null;
if (!string.Equals(mcMsg.MethodName, "Test", StringComparison.OrdinalIgnoreCase))
{
object instance = null;
if (Entity == null)
{
Type type = Type.GetType(mcMsg.TypeName);
instance = Activator.CreateInstance(type);
}
else
{
instance = Entity;
}
object returnValueObject = mcMsg.MethodBase.Invoke(instance, null);
rlt = new ReturnMessage(returnValueObject, mcMsg.Args, mcMsg.ArgCount, mcMsg.LogicalCallContext, mcMsg);
}
else
{
rlt = new ReturnMessage(new ProxyResult(), mcMsg.Args, mcMsg.ArgCount, mcMsg.LogicalCallContext, mcMsg);
}
return rlt;
}
return null;
}
开发者ID:mind0n,项目名称:hive,代码行数:30,代码来源:EntityProxy.cs
示例2: Invoke
public override System.Runtime.Remoting.Messaging.IMessage Invoke(System.Runtime.Remoting.Messaging.IMessage msg)
{
if (msg is IConstructionCallMessage) // 如果是构造函数,按原来的方式返回即可。
{
IConstructionCallMessage constructCallMsg = msg as IConstructionCallMessage;
IConstructionReturnMessage constructionReturnMessage = this.InitializeServerObject((IConstructionCallMessage)msg);
RealProxy.SetStubData(this, constructionReturnMessage.ReturnValue);
return constructionReturnMessage;
}
else if (msg is IMethodCallMessage) //如果是方法调用(属性也是方法调用的一种)
{
IMethodCallMessage callMsg = msg as IMethodCallMessage;
object[] args = callMsg.Args;
IMessage message;
try
{
if (callMsg.MethodName.StartsWith("set_") && args.Length == 1)
{
method.Invoke(GetUnwrappedServer(), new object[] { callMsg.MethodName.Substring(4)});
}
object o = callMsg.MethodBase.Invoke(GetUnwrappedServer(), args);
message = new ReturnMessage(o, args, args.Length, callMsg.LogicalCallContext, callMsg);
}
catch (Exception e)
{
message = new ReturnMessage(e, callMsg);
}
return message;
}
return msg;
}
开发者ID:RushHang,项目名称:H_DataAssembly,代码行数:31,代码来源:AopProxy.cs
示例3: SyncProcessMessage
public IMessage SyncProcessMessage(IMessage msg)
{
var mcm = (msg as IMethodCallMessage);
var mrm = null as IMethodReturnMessage;
var handler = ContextBoundObjectInterceptor.GetInterceptor(this.Target);
if (handler != null)
{
var arg = new InterceptionArgs(this.Target, mcm.MethodBase as MethodInfo, mcm.Args);
try
{
handler.Invoke(arg);
if (arg.Handled == true)
{
mrm = new ReturnMessage(arg.Result, new object[0], 0, mcm.LogicalCallContext, mcm);
}
}
catch (Exception ex)
{
mrm = new ReturnMessage(ex, mcm);
}
}
if (mrm == null)
{
mrm = this.NextSink.SyncProcessMessage(msg) as IMethodReturnMessage;
}
return mrm;
}
开发者ID:rjperes,项目名称:DevelopmentWithADot.Interception,代码行数:33,代码来源:InterceptionMessageSink.cs
示例4: SyncProcessMessage
} // ObjectMode
public virtual IMessage SyncProcessMessage(IMessage msg)
{
IMessage replyMsg = null;
try
{
msg.Properties["__Uri"] = _realProxy.IdentityObject.URI;
if (_objectMode == WellKnownObjectMode.Singleton)
{
replyMsg = _realProxy.Invoke(msg);
}
else
{
// This is a single call object, so we need to create
// a new instance.
MarshalByRefObject obj = (MarshalByRefObject)Activator.CreateInstance(_serverType, true);
BCLDebug.Assert(RemotingServices.IsTransparentProxy(obj), "expecting a proxy");
RealProxy rp = RemotingServices.GetRealProxy(obj);
replyMsg = rp.Invoke(msg);
}
}
catch (Exception e)
{
replyMsg = new ReturnMessage(e, msg as IMethodCallMessage);
}
return replyMsg;
} // SyncProcessMessage
开发者ID:ArildF,项目名称:masters,代码行数:32,代码来源:redirectionproxy.cs
示例5: SyncProcessMessage
public IMessage SyncProcessMessage (IMessage msg)
{
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
Context oldContext = null;
IMessage response;
if (Threading.Thread.CurrentContext != identity.Context)
oldContext = Context.SwitchToContext (identity.Context);
try
{
Context.NotifyGlobalDynamicSinks (true, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (true, msg, false, false);
response = identity.Context.GetServerContextSinkChain().SyncProcessMessage (msg);
Context.NotifyGlobalDynamicSinks (false, msg, false, false);
Thread.CurrentContext.NotifyDynamicSinks (false, msg, false, false);
}
catch (Exception ex)
{
response = new ReturnMessage (ex, (IMethodCallMessage)msg);
}
finally
{
if (oldContext != null)
Context.SwitchToContext (oldContext);
}
return response;
}
开发者ID:jack-pappas,项目名称:mono,代码行数:32,代码来源:CrossContextChannel.cs
示例6: Invoke
/// <summary>
/// 函数消息
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public override IMessage Invoke(IMessage msg)
{
IMessage message;
var callMessage = msg as IConstructionCallMessage;
if (callMessage != null)
{
message = InitializeServerObject(callMessage);
if (message != null)
{
SetStubData(this, ((IConstructionReturnMessage)message).ReturnValue);
}
}
else
{
var callMsg = (IMethodCallMessage)msg;
var attributes = serverType.GetMethod(callMsg.MethodName).GetCustomAttributes(false);
var args = callMsg.Args;
try
{
OnBegin(attributes, callMsg);
var ret = callMsg.MethodBase.Invoke(GetUnwrappedServer(), args);
OnComplete(attributes, ref ret, callMsg);
message = new ReturnMessage(ret, args, args.Length, callMsg.LogicalCallContext, callMsg);
}
catch (Exception e)
{
OnException(attributes, e.InnerException, callMsg);
message = new ReturnMessage(e.InnerException, callMsg);
}
}
return message;
}
开发者ID:qq5013,项目名称:yqbbxt,代码行数:40,代码来源:AspectProxy.cs
示例7: DeserializeMessage
private IMessage DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream)
{
IMessage message;
string str2;
string str3;
Header[] h = new Header[] { new Header("__TypeName", mcm.TypeName), new Header("__MethodName", mcm.MethodName), new Header("__MethodSignature", mcm.MethodSignature) };
string contentType = headers["Content-Type"] as string;
HttpChannelHelper.ParseContentType(contentType, out str2, out str3);
if (string.Compare(str2, "text/xml", StringComparison.Ordinal) == 0)
{
message = CoreChannel.DeserializeSoapResponseMessage(stream, mcm, h, this._strictBinding);
}
else
{
int count = 0x400;
byte[] buffer = new byte[count];
StringBuilder builder = new StringBuilder();
for (int i = stream.Read(buffer, 0, count); i > 0; i = stream.Read(buffer, 0, count))
{
builder.Append(Encoding.ASCII.GetString(buffer, 0, i));
}
message = new ReturnMessage(new RemotingException(builder.ToString()), mcm);
}
stream.Close();
return message;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:SoapClientFormatterSink.cs
示例8: Invoke
public override IMessage Invoke(IMessage msg)
{
using (var client = WcfServiceClientFactory.CreateServiceClient<IWcfLogService>())
{
var channel = client.Channel;
IMethodCallMessage methodCall = (IMethodCallMessage)msg;
IMethodReturnMessage methodReturn = null;
object[] copiedArgs = Array.CreateInstance(typeof(object), methodCall.Args.Length) as object[];
methodCall.Args.CopyTo(copiedArgs, 0);
try
{
object returnValue = methodCall.MethodBase.Invoke(channel, copiedArgs);
methodReturn = new ReturnMessage(returnValue,
copiedArgs,
copiedArgs.Length,
methodCall.LogicalCallContext,
methodCall);
}
catch (Exception ex)
{
if (ex.InnerException != null)
{
LocalLogService.Log(ex.InnerException.ToString());
methodReturn = new ReturnMessage(ex.InnerException, methodCall);
}
else
{
LocalLogService.Log(ex.ToString());
methodReturn = new ReturnMessage(ex, methodCall);
}
}
return methodReturn;
}
}
开发者ID:gofixiao,项目名称:HYPDM_Pro,代码行数:34,代码来源:LogServiceRealProxy.cs
示例9: Invoke
/// <summary>
/// Proxy method for substitution of executing methods in adapter interface.
/// </summary>
/// <param name="methodCall">The IMessage containing method invoking data.</param>
/// <returns>The IMessage containing method return data.</returns>
protected override IMessage Invoke(IMethodCallMessage methodCall)
{
ReturnMessage mret = null;
// Check if this is a method from IAdapter. Any IAdapter methods should be ignored.
if ((methodCall.MethodBase.DeclaringType.FullName != typeof(IAdapter).FullName)
&& (methodCall.MethodBase.DeclaringType.FullName != typeof(IDisposable).FullName)
)
{
TestSite.Log.Add(LogEntryKind.EnterAdapter,
"Interactive adapter: {0}, method: {1}",
ProxyType.Name,
methodCall.MethodName);
try
{
// Instantiate a new UI window.
using (InteractiveAdapterDialog adapterDlg = new InteractiveAdapterDialog(methodCall, TestSite.Properties))
{
DialogResult dialogResult = adapterDlg.ShowDialog();
if (dialogResult != DialogResult.OK)
{
string msg = "Failed";
TestSite.Assume.Fail(msg);
}
else
{
mret = new ReturnMessage(
adapterDlg.ReturnValue,
adapterDlg.OutArgs.Length > 0 ? adapterDlg.OutArgs : null,
adapterDlg.OutArgs.Length,
methodCall.LogicalCallContext,
methodCall);
}
}
}
catch (Exception ex)
{
TestSite.Log.Add(LogEntryKind.Debug, ex.ToString());
throw;
}
finally
{
TestSite.Log.Add(LogEntryKind.ExitAdapter,
"Interactive adapter: {0}, method: {1}",
ProxyType.Name,
methodCall.MethodName);
}
}
else
{
// TODO: Do we need to take care ReturnMessage (Exception, IMethodCallMessage) ?
mret = new ReturnMessage(null, null, 0, methodCall.LogicalCallContext, methodCall);
}
return mret;
}
开发者ID:JessieF,项目名称:ProtocolTestFramework,代码行数:62,代码来源:InteractiveAdapterProxy.cs
示例10: ValidateMessage
/*
* Checks the replySink param for NULL and type.
* If the param is good, it returns NULL.
* Else it returns a Message with the relevant exception.
*/
internal static IMessage ValidateMessage(IMessage reqMsg)
{
IMessage retMsg = null;
if (reqMsg == null)
{
retMsg = new ReturnMessage( new ArgumentNullException("reqMsg"), null);
}
return retMsg;
}
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:terminatorsinks.cs
示例11: Invoke
public override IMessage Invoke(IMessage message)
{
IMessage result = null;
IMethodCallMessage methodCall = message as IMethodCallMessage;
MethodInfo method = methodCall.MethodBase as MethodInfo;
// Invoke
if (result == null) {
if (proxyTarget != null) {
Console.WriteLine("proxy going to invoke: {0}", method.Name);
object callResult;
object actualresult;
bool make_proxy = true;
if (method.ReturnType.IsInterface) {
actualresult = method.Invoke(proxyTarget, methodCall.InArgs);
if (method.ReturnType.IsGenericType) {
// Console.WriteLine("** return value is generic type: {0}", method.ReturnType.GetGenericTypeDefinition());
if (method.ReturnType.GetGenericTypeDefinition() == (typeof(IEnumerator<>))) {
Console.WriteLine("** method returning IEnumerator<>, making BatchProxy");
Type[] args = method.ReturnType.GetGenericArguments();
Type srvbatchtype = typeof(EnumeratorServerBatch<>).MakeGenericType(args);
object srv = Activator.CreateInstance(srvbatchtype, actualresult);
Type clbatchtype = typeof(EnumeratorClientBatch<>).MakeGenericType(args);
object client = Activator.CreateInstance(clbatchtype, srv);
make_proxy = false;
actualresult = client;
}
}
if (make_proxy) {
var newproxy = new MyProxy(method.ReturnType, actualresult);
callResult = newproxy.GetTransparentProxy();
} else {
callResult = actualresult;
}
} else {
callResult = method.Invoke(proxyTarget, methodCall.InArgs);
}
Console.WriteLine("proxy done Invoking: {0}", method.Name);
LogicalCallContext context = methodCall.LogicalCallContext;
result = new ReturnMessage(callResult, null, 0, context, message as IMethodCallMessage);
} else {
NotSupportedException exception = new NotSupportedException("proxyTarget is not defined");
result = new ReturnMessage(exception, message as IMethodCallMessage);
}
}
return result;
}
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:54,代码来源:MyProxy.cs
示例12: SetNewReturnValue
public void SetNewReturnValue(object newReturnValue)
{
IMethodReturnMessage message = this.methodCallReturnMessage;
if(message==null)
{
return ;
}
ReturnMessage newReturnMessage = new ReturnMessage(newReturnValue,message.OutArgs,message.OutArgCount,message.LogicalCallContext,this.MethodCallMessage);
this.MethodCallReturnMessage = newReturnMessage;
}
开发者ID:royosherove,项目名称:dotnet-test-extensions,代码行数:11,代码来源:PostProcessEventArgs.cs
示例13: Process
public void Process(IMethodCallMessage callMsg, ref IMethodReturnMessage retMsg)
{
Exception e = retMsg.Exception;
if (e != null)
{
this.HandleException(e);
Exception newException = this.GetNewException(e);
if (!object.ReferenceEquals(e, newException))
retMsg = new ReturnMessage(newException, callMsg);
}
}
开发者ID:WrongDog,项目名称:Aspect,代码行数:12,代码来源:ExceptionHandlingProcessor.cs
示例14: FlagCurrentMethodToBeSkipped
protected void FlagCurrentMethodToBeSkipped(ProcessEventArgs args)
{
IMethodCallMessage methodCallMessage = args.MethodCallMessage;
ReturnMessage customMessage = new ReturnMessage(
1,
new object[]{},
0,
methodCallMessage.LogicalCallContext,
methodCallMessage);
methodCallMessage.LogicalCallContext.SetData("CustomReturnMessage",customMessage) ;
}
开发者ID:royosherove,项目名称:dotnet-test-extensions,代码行数:13,代码来源:BaseProcessingAttribute.cs
示例15: Postprocess
public void Postprocess(MarshalByRefObject inst, IMessage msg, ref IMessage msgReturn)
{
IMethodCallMessage lMsgIn = msg as IMethodCallMessage;
IMethodReturnMessage lMsgOut = msgReturn as IMethodReturnMessage;
// Extract Server
ONServer lServer = inst as ONServer;
// Calculate OutputArgumets
object[] lArgs = lMsgOut.Args;
mServiceCacheItem.InvoqueOutboundArguments(lServer, lArgs);
// Pop the OID from Class Stack
lServer.OnContext.OperationStack.Pop();
mInStack = false;
msgReturn = new ReturnMessage(lMsgOut.ReturnValue, lArgs, lArgs.Length, lMsgOut.LogicalCallContext, lMsgIn);
}
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:18,代码来源:ONOperationAttribute.cs
示例16: Invoke
public override IMessage Invoke( IMessage msg )
{
IMethodCallMessage call = (IMethodCallMessage)msg;
IMethodReturnMessage result = null;
if ( call != null )
{
try
{
object ret = callHandler.Call( call.MethodName, call.Args );
if ( ret == null )
{
MethodInfo info = call.MethodBase as MethodInfo;
Type returnType = info.ReturnType;
if( returnType == typeof( System.Boolean ) ) ret = false;
if( returnType == typeof( System.Byte ) ) ret = (System.Byte)0;
if( returnType == typeof( System.SByte ) ) ret = (System.SByte)0;
if( returnType == typeof( System.Decimal ) ) ret = (System.Decimal)0;
if( returnType == typeof( System.Double ) ) ret = (System.Double)0;
if( returnType == typeof( System.Single ) ) ret = (System.Single)0;
if( returnType == typeof( System.Int32 ) ) ret = (System.Int32)0;
if( returnType == typeof( System.UInt32 ) ) ret = (System.UInt32)0;
if( returnType == typeof( System.Int64 ) ) ret = (System.Int64)0;
if( returnType == typeof( System.UInt64 ) ) ret = (System.UInt64)0;
if( returnType == typeof( System.Int16 ) ) ret = (System.Int16)0;
if( returnType == typeof( System.UInt16 ) ) ret = (System.UInt16)0;
if( returnType == typeof( System.Char ) ) ret = '?';
}
result = new ReturnMessage( ret, null, 0, null, call );
}
catch( Exception e )
{
result = new ReturnMessage( e, call );
}
}
return result;
}
开发者ID:rmterra,项目名称:AutoTest.Net,代码行数:43,代码来源:MockInterfaceHandler.cs
示例17: SyncProcessMessage
public IMessage SyncProcessMessage(IMessage msg)
{
var mcm = (msg as IMethodCallMessage);
IMessage rtnMsg = null;
try
{
ExecuteBeforeStrategy(ref mcm);
}
catch (Exception exception)
{
var returnMessage = new ReturnMessage(exception,mcm) as IMethodReturnMessage;
ExecuteAfterStrategy(mcm, ref returnMessage);
return returnMessage;
}
rtnMsg = _nextSink.SyncProcessMessage(msg);
var methodReturnMessage = (rtnMsg as IMethodReturnMessage);
ExecuteAfterStrategy(mcm, ref methodReturnMessage);
return (rtnMsg as IMethodReturnMessage);
}
开发者ID:ilkerhalil,项目名称:Interception_Sample_BE,代码行数:19,代码来源:InterceptSink.cs
示例18: SyncProcessMessage
public IMessage SyncProcessMessage(IMessage msg)
{
if (msg is IMethodMessage)
{
var call = msg as IMethodMessage;
var type = Type.GetType(call.TypeName);
if (type != null)
{
//var key = call.TypeName + "." + call.MethodName;
//var cached = CachingConfiguration.SystemRuntimeCachingProvider.Get<object>(key);
//if (null == cached)
//{
IMessage returnMethod = m_next.SyncProcessMessage(msg);
if (!(returnMethod is IMethodReturnMessage)) return returnMethod;
var retMsg = (IMethodReturnMessage)returnMethod;
System.Exception e = retMsg.Exception;
if (null == e)
{
if (retMsg.ReturnValue.GetType() != typeof (void))
{
var methodMessage = (IMethodCallMessage)msg;
var overrideReturnMethod = new ReturnMessage(
(int)retMsg.ReturnValue * 2,
methodMessage.Args,
methodMessage.ArgCount,
methodMessage.LogicalCallContext, methodMessage);
return overrideReturnMethod;
}
}
return returnMethod;
//}
//var methodMessage = (IMethodCallMessage)msg;
//var overrideReturnMethod = new ReturnMessage(cached, methodMessage.Args, methodMessage.ArgCount, methodMessage.LogicalCallContext, methodMessage);
//return overrideReturnMethod;
}
}
return m_next.SyncProcessMessage(msg);
}
开发者ID:KenVanGilbergen,项目名称:ken.Spikes.Aspects,代码行数:41,代码来源:MessageSink.cs
示例19: Invoke
// メソッド実行時
public override IMessage Invoke(IMessage message)
{
IMethodMessage myMethodMessage = (IMethodMessage)message;
string LogString = myMethodMessage.MethodBase.ReflectedType + "." + myMethodMessage.MethodName + "(" + string.Join(", ", myMethodMessage.Args) + ")";
// 開始ログ
LoggerEx.Trace(LogString + " : start");
object returnValue = myType.InvokeMember(myMethodMessage.MethodName,
BindingFlags.InvokeMethod, null, myObjectInstance,
myMethodMessage.Args);
ReturnMessage myReturnMessage = new ReturnMessage(returnValue, null, 0,
((IMethodCallMessage)message).LogicalCallContext,
(IMethodCallMessage)message);
// 終了ログ
LoggerEx.Trace(LogString + " : end");
return myReturnMessage;
}
开发者ID:higeneko2015,项目名称:WcfSample,代码行数:22,代码来源:TraceProxy.cs
示例20: SyncProcessMessage
public IMessage SyncProcessMessage (IMessage msg)
{
IMethodCallMessage mcm = (IMethodCallMessage) msg;
int timeout = -1;
bool timedOut = false;
RemotingService.CallbackData data = RemotingService.GetCallbackData (mcm.Uri, mcm.MethodName);
if (data != null) {
timeout = data.Timeout;
if (data.Calling != null) {
IMessage r = data.Calling (data.Target, mcm);
if (r != null)
return r;
}
}
IMessage res = null;
if (timeout != -1) {
ManualResetEvent ev = new ManualResetEvent (false);
ThreadPool.QueueUserWorkItem (delegate {
res = ((IMessageSink)nextSink).SyncProcessMessage (msg);
});
if (!ev.WaitOne (timeout, false)) {
timedOut = true;
res = new ReturnMessage (null, null, 0, mcm.LogicalCallContext, mcm);
}
}
else {
res = ((IMessageSink)nextSink).SyncProcessMessage (msg);
}
if (data != null && data.Called != null) {
IMessage cr = data.Called (data.Target, mcm, res as IMethodReturnMessage, timedOut);
if (cr != null)
res = cr;
}
return res;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:40,代码来源:DisposerFormatterSink.cs
注:本文中的System.Runtime.Remoting.Messaging.ReturnMessage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论