本文整理汇总了C#中IMethodCallMessage类的典型用法代码示例。如果您正苦于以下问题:C# IMethodCallMessage类的具体用法?C# IMethodCallMessage怎么用?C# IMethodCallMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMethodCallMessage类属于命名空间,在下文中一共展示了IMethodCallMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MethodCallContext
public MethodCallContext(IMethodCallMessage mcm, IMessageSink nextSink)
{
mcm.ThrowIfNullArgument(nameof(mcm));
nextSink.ThrowIfNullArgument(nameof(nextSink));
_mcm = mcm;
_nextSink = nextSink;
}
示例2: MethodResponse
internal MethodResponse(IMethodCallMessage msg, object handlerObject, BinaryMethodReturnMessage smuggledMrm)
{
if (msg != null)
{
this.MI = msg.MethodBase;
this._methodCache = InternalRemotingServices.GetReflectionCachedData(this.MI);
this.methodName = msg.MethodName;
this.uri = msg.Uri;
this.typeName = msg.TypeName;
if (this._methodCache.IsOverloaded())
{
this.methodSignature = (Type[]) msg.MethodSignature;
}
this.argCount = this._methodCache.Parameters.Length;
}
this.retVal = smuggledMrm.ReturnValue;
this.outArgs = smuggledMrm.Args;
this.fault = smuggledMrm.Exception;
this.callContext = smuggledMrm.LogicalCallContext;
if (smuggledMrm.HasProperties)
{
smuggledMrm.PopulateMessageProperties(this.Properties);
}
this.fSoap = false;
}
示例3: Process
public void Process(ref IMethodCallMessage msg)
{
//Console.WriteLine("Method details: " + msg.MethodBase);
PrintParameters printParameters = new PrintParameters();
printParameters.PrintValues(msg);
}
示例4: 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;
}
示例5: GetMethodData
private MethodData GetMethodData(IMethodCallMessage methodCall)
{
MethodData data;
MethodBase methodBase = methodCall.MethodBase;
if (!this.methodDataCache.TryGetMethodData(methodBase, out data))
{
bool flag;
System.Type declaringType = methodBase.DeclaringType;
if (declaringType == typeof(object))
{
MethodType getType;
if (methodCall.MethodBase == typeof(object).GetMethod("GetType"))
{
getType = MethodType.GetType;
}
else
{
getType = MethodType.Object;
}
flag = true;
data = new MethodData(methodBase, getType);
}
else if (declaringType.IsInstanceOfType(this.serviceChannel))
{
flag = true;
data = new MethodData(methodBase, MethodType.Channel);
}
else
{
MethodType service;
ProxyOperationRuntime operation = this.proxyRuntime.GetOperation(methodBase, methodCall.Args, out flag);
if (operation == null)
{
if (this.serviceChannel.Factory != null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.ServiceModel.SR.GetString("SFxMethodNotSupported1", new object[] { methodBase.Name })));
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.ServiceModel.SR.GetString("SFxMethodNotSupportedOnCallback1", new object[] { methodBase.Name })));
}
if (operation.IsSyncCall(methodCall))
{
service = MethodType.Service;
}
else if (operation.IsBeginCall(methodCall))
{
service = MethodType.BeginService;
}
else
{
service = MethodType.EndService;
}
data = new MethodData(methodBase, service, operation);
}
if (flag)
{
this.methodDataCache.SetMethodData(data);
}
}
return data;
}
示例6: PostMethodExecutionProcess
public void PostMethodExecutionProcess(IMethodCallMessage callMsg, ref IMethodReturnMessage retMsg)
{
_stopwatch.Stop();
//Console.WriteLine("Return value: {0}", retMsg.ReturnValue);
//Console.WriteLine("Ticks consumed: {0}", _stopwatch.ElapsedTicks);
}
示例7: BuildReturnMessage
/// <summary>
/// Builds a method call return message given the returnvalue, out arguments and methodcall.
/// </summary>
/// <param name="returnValue">Return value of the methodcall.</param>
/// <param name="arguments">Input and output argument values.</param>
/// <param name="callMessage">The original methodcall object.</param>
/// <remarks>
/// This method is to be used during recording phase only. A .NET return message object
/// is constructed based on the given information, where all non-serializable return
/// values and output arguments are mocked for recording.
/// </remarks>
public static IMethodReturnMessage BuildReturnMessage(object returnValue, object[] arguments, IMethodCallMessage callMessage) {
// Build return message:
IConstructionCallMessage ccm = callMessage as IConstructionCallMessage;
if (ccm != null) {
// If constructor message, build returnmessage from construction:
return EnterpriseServicesHelper.CreateConstructionReturnMessage(ccm, (MarshalByRefObject)returnValue);
} else {
// Wrap return value:
object wrappedReturnValue;
wrappedReturnValue = WrapObject(returnValue, ((MethodInfo)callMessage.MethodBase).ReturnType);
// Copy arguments, wrapping output arguments:
int outArgsCount = 0;
object[] wrappedArgs = new object[arguments.Length];
foreach(ParameterInfo param in callMessage.MethodBase.GetParameters()) {
if (param.ParameterType.IsByRef) {
wrappedArgs[param.Position] = WrapObject(arguments[param.Position], param.ParameterType);
outArgsCount++;
} else {
wrappedArgs[param.Position] = arguments[param.Position];
}
}
// Build return message:
return new ReturnMessage(wrappedReturnValue, wrappedArgs, outArgsCount, callMessage.LogicalCallContext, callMessage);
}
}
示例8: CompositionException
public CompositionException(IMethodCallMessage Message,string message, System.Exception innerException):this(String.Format("Exception:{0}\r\nAssembly:{1}\r\n{2}:{3}\r\nArgs:\r\n",message,Message.TypeName,Message.MethodBase.MemberType,Message.MethodName),innerException)
{
for(int i=0; i<Message.ArgCount; i+=2)
{
_message = String.Format("{0}\t{1}={2}\r\n",_message,Message.GetArgName(i),Message.GetArg(i).ToString());
}
}
示例9: CreateReturnMessage
private IMethodReturnMessage CreateReturnMessage(object ret, object[] returnArgs, IMethodCallMessage methodCall)
{
if (returnArgs != null)
{
return this.CreateReturnMessage(ret, returnArgs, returnArgs.Length, SetActivityIdInLogicalCallContext(methodCall.LogicalCallContext), methodCall);
}
return new SingleReturnMessage(ret, methodCall);
}
示例10: PreMethodExecutionProcess
public void PreMethodExecutionProcess(ref IMethodCallMessage msg)
{
_stopwatch.Start();
//Console.WriteLine("Method details: " + msg.MethodBase);
PrintParameters printParameters = new PrintParameters();
printParameters.PrintValues(msg);
}
示例11: CreateCommands
public IEnumerable<SqlCommand> CreateCommands(IMethodCallMessage mcm, SqlConnection connection, string schemaName, out SqlParameter returnValue, out SqlParameter[] outParameters, out ISerializationTypeInfo returnTypeInfo, out ICallDeserializationInfo procInfo, out XmlNameTable xmlNameTable,
IList<IDisposable> disposeList)
{
List<SqlCommand> sqlCommands = new List<SqlCommand>();
SqlCommand sqlCommand = methods[mcm.MethodBase].GetCommand(mcm, connection, out returnValue, out outParameters, out returnTypeInfo, out procInfo, out xmlNameTable, disposeList);
sqlCommands.Add(sqlCommand);
return sqlCommands;
}
示例12: CallInterceptionData
/// <summary>
/// Creates a new instance of the CallInterceptionData class.
/// </summary>
/// <param name="parameters">Parameter values of the intercepted call</param>
/// <param name="remoteInvoker">Delegate for remote invocation</param>
/// <param name="remotingMessage">Remoting message</param>
public CallInterceptionData(object[] parameters, InvokeRemoteMethodDelegate remoteInvoker, IMethodCallMessage remotingMessage)
{
Intercepted = false;
ReturnValue = null;
Parameters = parameters;
_remoteInvoker = remoteInvoker;
_remotingMessage = remotingMessage;
}
示例13: TransparentProxyMethodReturn
/// <summary>
/// Creates a new <see cref="TransparentProxyMethodReturn"/> object that contains an
/// exception thrown by the target.
/// </summary>
/// <param name="ex">Exception that was thrown.</param>
/// <param name="callMessage">The original call message that invoked the method.</param>
/// <param name="invocationContext">Invocation context dictionary passed into the call.</param>
public TransparentProxyMethodReturn(Exception ex, IMethodCallMessage callMessage, IDictionary invocationContext)
{
this.callMessage = callMessage;
this.invocationContext = invocationContext;
this.exception = ex;
this.arguments = new object[0];
this.outputs = new ParameterCollection(this.arguments, new ParameterInfo[0], pi => false);
}
示例14: FormatResponse
// used by the client
internal IMessage FormatResponse(ISoapMessage soapMsg, IMethodCallMessage mcm)
{
IMessage rtnMsg;
if(soapMsg.MethodName == "Fault") {
// an exception was thrown by the server
Exception e = new SerializationException();
int i = Array.IndexOf(soapMsg.ParamNames, "detail");
if(_serverFaultExceptionField != null)
// todo: revue this 'cause it's not safe
e = (Exception) _serverFaultExceptionField.GetValue(
soapMsg.ParamValues[i]);
rtnMsg = new ReturnMessage((System.Exception)e, mcm);
}
else {
object rtnObject = null;
//RemMessageType messageType;
// Get the output of the function if it is not *void*
if(_methodCallInfo.ReturnType != typeof(void)){
int index = Array.IndexOf(soapMsg.ParamNames, "return");
rtnObject = soapMsg.ParamValues[index];
if(rtnObject is IConvertible)
rtnObject = Convert.ChangeType(
rtnObject,
_methodCallInfo.ReturnType);
}
object[] outParams = new object [_methodCallParameters.Length];
int n=0;
// check if there are *out* parameters
foreach(ParameterInfo paramInfo in _methodCallParameters) {
if(paramInfo.ParameterType.IsByRef || paramInfo.IsOut) {
int index = Array.IndexOf(soapMsg.ParamNames, paramInfo.Name);
object outParam = soapMsg.ParamValues[index];
if(outParam is IConvertible)
outParam = Convert.ChangeType (outParam, paramInfo.ParameterType.GetElementType());
outParams[n] = outParam;
}
else
outParams [n] = null;
n++;
}
Header[] headers = new Header [2 + (soapMsg.Headers != null ? soapMsg.Headers.Length : 0)];
headers [0] = new Header ("__Return", rtnObject);
headers [1] = new Header ("__OutArgs", outParams);
if (soapMsg.Headers != null)
soapMsg.Headers.CopyTo (headers, 2);
rtnMsg = new MethodResponse (headers, mcm);
}
return rtnMsg;
}
示例15: RemotingInvocation
public RemotingInvocation(RealProxy proxy, IMethodCallMessage message)
{
this.message = message;
this.proxy = proxy;
arguments = message.Args;
if (arguments == null)
arguments = new object[0];
}