Files
Dec2017-Script-Dump/mscorlib/System/Runtime/Remoting/Messaging/MethodResponse.cs
T
2026-06-04 11:42:34 +02:00

609 lines
23 KiB
C#

using System;
using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.Runtime.Remoting.Messaging
{
/// <summary>Implements the <see cref="T:System.Runtime.Remoting.Messaging.IMethodReturnMessage" /> interface to create a message that acts as a method response on a remote object.</summary>
// Token: 0x020003FA RID: 1018
[ComVisible(true)]
[CLSCompliant(false)]
[Serializable]
public class MethodResponse : ISerializable, IInternalMessage, IMessage, IMethodMessage, IMethodReturnMessage, ISerializationRootObject
{
/// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.Messaging.MethodResponse" /> class from an array of remoting headers and a request message. </summary>
/// <param name="h1">An array of remoting headers that contains key/value pairs. This array is used to initialize <see cref="T:System.Runtime.Remoting.Messaging.MethodResponse" /> fields for headers that belong to the namespace "http://schemas.microsoft.com/clr/soap/messageProperties".</param>
/// <param name="mcm">A request message that acts as a method call on a remote object.</param>
// Token: 0x060027A3 RID: 10147 RVA: 0x0008213C File Offset: 0x0008033C
public MethodResponse(Header[] h1, IMethodCallMessage mcm)
{
if (mcm != null)
{
this._methodName = mcm.MethodName;
this._uri = mcm.Uri;
this._typeName = mcm.TypeName;
this._methodBase = mcm.MethodBase;
this._methodSignature = (Type[])mcm.MethodSignature;
this._args = mcm.Args;
}
if (h1 != null)
{
foreach (Header header in h1)
{
this.InitMethodProperty(header.Name, header.Value);
}
}
}
// Token: 0x060027A4 RID: 10148 RVA: 0x000821D4 File Offset: 0x000803D4
internal MethodResponse(Exception e, IMethodCallMessage msg)
{
this._callMsg = msg;
if (msg != null)
{
this._uri = msg.Uri;
}
else
{
this._uri = string.Empty;
}
this._exception = e;
this._returnValue = null;
this._outArgs = new object[0];
}
// Token: 0x060027A5 RID: 10149 RVA: 0x0008222C File Offset: 0x0008042C
internal MethodResponse(object returnValue, object[] outArgs, LogicalCallContext callCtx, IMethodCallMessage msg)
{
this._callMsg = msg;
this._uri = msg.Uri;
this._exception = null;
this._returnValue = returnValue;
this._args = outArgs;
}
// Token: 0x060027A6 RID: 10150 RVA: 0x0008226C File Offset: 0x0008046C
internal MethodResponse(IMethodCallMessage msg, CADMethodReturnMessage retmsg)
{
this._callMsg = msg;
this._methodBase = msg.MethodBase;
this._uri = msg.Uri;
this._methodName = msg.MethodName;
ArrayList arguments = retmsg.GetArguments();
this._exception = retmsg.GetException(arguments);
this._returnValue = retmsg.GetReturnValue(arguments);
this._args = retmsg.GetArgs(arguments);
this._callContext = retmsg.GetLogicalCallContext(arguments);
if (this._callContext == null)
{
this._callContext = new LogicalCallContext();
}
if (retmsg.PropertiesCount > 0)
{
CADMessageBase.UnmarshalProperties(this.Properties, retmsg.PropertiesCount, arguments);
}
}
// Token: 0x060027A7 RID: 10151 RVA: 0x0008231C File Offset: 0x0008051C
internal MethodResponse(SerializationInfo info, StreamingContext context)
{
foreach (SerializationEntry serializationEntry in info)
{
this.InitMethodProperty(serializationEntry.Name, serializationEntry.Value);
}
}
// Token: 0x170007A1 RID: 1953
// (get) Token: 0x060027A8 RID: 10152 RVA: 0x00082364 File Offset: 0x00080564
// (set) Token: 0x060027A9 RID: 10153 RVA: 0x0008236C File Offset: 0x0008056C
string IInternalMessage.Uri
{
get
{
return this.Uri;
}
set
{
this.Uri = value;
}
}
// Token: 0x170007A2 RID: 1954
// (get) Token: 0x060027AA RID: 10154 RVA: 0x00082378 File Offset: 0x00080578
// (set) Token: 0x060027AB RID: 10155 RVA: 0x00082380 File Offset: 0x00080580
Identity IInternalMessage.TargetIdentity
{
get
{
return this._targetIdentity;
}
set
{
this._targetIdentity = value;
}
}
// Token: 0x060027AC RID: 10156 RVA: 0x0008238C File Offset: 0x0008058C
internal void InitMethodProperty(string key, object value)
{
switch (key)
{
case "__TypeName":
this._typeName = (string)value;
return;
case "__MethodName":
this._methodName = (string)value;
return;
case "__MethodSignature":
this._methodSignature = (Type[])value;
return;
case "__Uri":
this._uri = (string)value;
return;
case "__Return":
this._returnValue = value;
return;
case "__OutArgs":
this._args = (object[])value;
return;
case "__fault":
this._exception = (Exception)value;
return;
case "__CallContext":
this._callContext = (LogicalCallContext)value;
return;
}
this.Properties[key] = value;
}
/// <summary>Gets the number of arguments passed to the method. </summary>
/// <returns>A <see cref="T:System.Int32" /> that represents the number of arguments passed to a method.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A3 RID: 1955
// (get) Token: 0x060027AD RID: 10157 RVA: 0x000824EC File Offset: 0x000806EC
public int ArgCount
{
get
{
if (this._args == null)
{
return 0;
}
return this._args.Length;
}
}
/// <summary>Gets an array of arguments passed to the method. </summary>
/// <returns>An array of type <see cref="T:System.Object" /> that represents the arguments passed to a method.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A4 RID: 1956
// (get) Token: 0x060027AE RID: 10158 RVA: 0x00082504 File Offset: 0x00080704
public object[] Args
{
get
{
return this._args;
}
}
/// <summary>Gets the exception thrown during the method call, or null if the method did not throw an exception. </summary>
/// <returns>The <see cref="T:System.Exception" /> thrown during the method call, or null if the method did not throw an exception.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A5 RID: 1957
// (get) Token: 0x060027AF RID: 10159 RVA: 0x0008250C File Offset: 0x0008070C
public Exception Exception
{
get
{
return this._exception;
}
}
/// <summary>Gets a value that indicates whether the method can accept a variable number of arguments. </summary>
/// <returns>true if the method can accept a variable number of arguments; otherwise, false.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A6 RID: 1958
// (get) Token: 0x060027B0 RID: 10160 RVA: 0x00082514 File Offset: 0x00080714
public bool HasVarArgs
{
get
{
return (this.MethodBase.CallingConvention | CallingConventions.VarArgs) != (CallingConventions)0;
}
}
/// <summary>Gets the <see cref="T:System.Runtime.Remoting.Messaging.LogicalCallContext" /> for the current method call. </summary>
/// <returns>The <see cref="T:System.Runtime.Remoting.Messaging.LogicalCallContext" /> for the current method call.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A7 RID: 1959
// (get) Token: 0x060027B1 RID: 10161 RVA: 0x0008252C File Offset: 0x0008072C
public LogicalCallContext LogicalCallContext
{
get
{
if (this._callContext == null)
{
this._callContext = new LogicalCallContext();
}
return this._callContext;
}
}
/// <summary>Gets the <see cref="T:System.Reflection.MethodBase" /> of the called method. </summary>
/// <returns>The <see cref="T:System.Reflection.MethodBase" /> of the called method.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A8 RID: 1960
// (get) Token: 0x060027B2 RID: 10162 RVA: 0x0008254C File Offset: 0x0008074C
public MethodBase MethodBase
{
get
{
if (this._methodBase == null)
{
if (this._callMsg != null)
{
this._methodBase = this._callMsg.MethodBase;
}
else if (this.MethodName != null && this.TypeName != null)
{
this._methodBase = RemotingServices.GetMethodBaseFromMethodMessage(this);
}
}
return this._methodBase;
}
}
/// <summary>Gets the name of the invoked method. </summary>
/// <returns>A <see cref="T:System.String" /> that contains the name of the invoked method.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007A9 RID: 1961
// (get) Token: 0x060027B3 RID: 10163 RVA: 0x000825B0 File Offset: 0x000807B0
public string MethodName
{
get
{
if (this._methodName == null && this._callMsg != null)
{
this._methodName = this._callMsg.MethodName;
}
return this._methodName;
}
}
/// <summary>Gets an object that contains the method signature. </summary>
/// <returns>A <see cref="T:System.Object" /> that contains the method signature.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AA RID: 1962
// (get) Token: 0x060027B4 RID: 10164 RVA: 0x000825E0 File Offset: 0x000807E0
public object MethodSignature
{
get
{
if (this._methodSignature == null && this._callMsg != null)
{
this._methodSignature = (Type[])this._callMsg.MethodSignature;
}
return this._methodSignature;
}
}
/// <summary>Gets the number of arguments in the method call marked as ref or out parameters.</summary>
/// <returns>A <see cref="T:System.Int32" /> that represents the number of arguments in the method call marked as ref or out parameters.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AB RID: 1963
// (get) Token: 0x060027B5 RID: 10165 RVA: 0x00082620 File Offset: 0x00080820
public int OutArgCount
{
get
{
if (this._args == null || this._args.Length == 0)
{
return 0;
}
if (this._inArgInfo == null)
{
this._inArgInfo = new ArgInfo(this.MethodBase, ArgInfoType.Out);
}
return this._inArgInfo.GetInOutArgCount();
}
}
/// <summary>Gets an array of arguments in the method call that are marked as ref or out parameters.</summary>
/// <returns>An array of type <see cref="T:System.Object" /> that represents the arguments in the method call that are marked as ref or out parameters.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AC RID: 1964
// (get) Token: 0x060027B6 RID: 10166 RVA: 0x00082670 File Offset: 0x00080870
public object[] OutArgs
{
get
{
if (this._outArgs == null && this._args != null)
{
if (this._inArgInfo == null)
{
this._inArgInfo = new ArgInfo(this.MethodBase, ArgInfoType.Out);
}
this._outArgs = this._inArgInfo.GetInOutArgs(this._args);
}
return this._outArgs;
}
}
/// <summary>Gets an <see cref="T:System.Collections.IDictionary" /> interface that represents a collection of the remoting message's properties. </summary>
/// <returns>An <see cref="T:System.Collections.IDictionary" /> interface that represents a collection of the remoting message's properties.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AD RID: 1965
// (get) Token: 0x060027B7 RID: 10167 RVA: 0x000826D0 File Offset: 0x000808D0
public virtual IDictionary Properties
{
get
{
if (this.ExternalProperties == null)
{
MethodReturnDictionary methodReturnDictionary = new MethodReturnDictionary(this);
this.ExternalProperties = methodReturnDictionary;
this.InternalProperties = methodReturnDictionary.GetInternalProperties();
}
return this.ExternalProperties;
}
}
/// <summary>Gets the return value of the method call. </summary>
/// <returns>A <see cref="T:System.Object" /> that represents the return value of the method call.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AE RID: 1966
// (get) Token: 0x060027B8 RID: 10168 RVA: 0x00082708 File Offset: 0x00080908
public object ReturnValue
{
get
{
return this._returnValue;
}
}
/// <summary>Gets the full type name of the remote object on which the method call is being made. </summary>
/// <returns>A <see cref="T:System.String" /> that contains the full type name of the remote object on which the method call is being made.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007AF RID: 1967
// (get) Token: 0x060027B9 RID: 10169 RVA: 0x00082710 File Offset: 0x00080910
public string TypeName
{
get
{
if (this._typeName == null && this._callMsg != null)
{
this._typeName = this._callMsg.TypeName;
}
return this._typeName;
}
}
/// <summary>Gets the Uniform Resource Identifier (URI) of the remote object on which the method call is being made. </summary>
/// <returns>The URI of a remote object.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x170007B0 RID: 1968
// (get) Token: 0x060027BA RID: 10170 RVA: 0x00082740 File Offset: 0x00080940
// (set) Token: 0x060027BB RID: 10171 RVA: 0x00082770 File Offset: 0x00080970
public string Uri
{
get
{
if (this._uri == null && this._callMsg != null)
{
this._uri = this._callMsg.Uri;
}
return this._uri;
}
set
{
this._uri = value;
}
}
/// <summary>Gets a method argument, as an object, at a specified index. </summary>
/// <returns>The method argument as an object.</returns>
/// <param name="argNum">The index of the requested argument.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027BC RID: 10172 RVA: 0x0008277C File Offset: 0x0008097C
public object GetArg(int argNum)
{
if (this._args == null)
{
return null;
}
return this._args[argNum];
}
/// <summary>Gets the name of a method argument at a specified index. </summary>
/// <returns>The name of the method argument.</returns>
/// <param name="index">The index of the requested argument.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027BD RID: 10173 RVA: 0x00082794 File Offset: 0x00080994
public string GetArgName(int index)
{
return this.MethodBase.GetParameters()[index].Name;
}
/// <summary>The <see cref="M:System.Runtime.Remoting.Messaging.MethodResponse.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" /> method is not implemented. </summary>
/// <param name="info">Data for serializing or deserializing the remote object.</param>
/// <param name="context">Context of a certain serialized stream.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter, Infrastructure" />
/// </PermissionSet>
// Token: 0x060027BE RID: 10174 RVA: 0x000827A8 File Offset: 0x000809A8
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (this._exception == null)
{
info.AddValue("__TypeName", this._typeName);
info.AddValue("__MethodName", this._methodName);
info.AddValue("__MethodSignature", this._methodSignature);
info.AddValue("__Uri", this._uri);
info.AddValue("__Return", this._returnValue);
info.AddValue("__OutArgs", this._args);
}
else
{
info.AddValue("__fault", this._exception);
}
info.AddValue("__CallContext", this._callContext);
if (this.InternalProperties != null)
{
foreach (object obj in this.InternalProperties)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
info.AddValue((string)dictionaryEntry.Key, dictionaryEntry.Value);
}
}
}
/// <summary>Returns the specified argument marked as a ref parameter or an out parameter. </summary>
/// <returns>The specified argument marked as a ref parameter or an out parameter.</returns>
/// <param name="argNum">The index of the requested argument.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027BF RID: 10175 RVA: 0x000828CC File Offset: 0x00080ACC
public object GetOutArg(int argNum)
{
if (this._args == null)
{
return null;
}
if (this._inArgInfo == null)
{
this._inArgInfo = new ArgInfo(this.MethodBase, ArgInfoType.Out);
}
return this._args[this._inArgInfo.GetInOutArgIndex(argNum)];
}
/// <summary>Returns the name of the specified argument marked as a ref parameter or an out parameter.</summary>
/// <returns>The argument name, or null if the current method is not implemented.</returns>
/// <param name="index">The index of the requested argument.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027C0 RID: 10176 RVA: 0x0008290C File Offset: 0x00080B0C
public string GetOutArgName(int index)
{
if (this._methodBase == null)
{
return "__method_" + index;
}
if (this._inArgInfo == null)
{
this._inArgInfo = new ArgInfo(this.MethodBase, ArgInfoType.Out);
}
return this._inArgInfo.GetInOutArgName(index);
}
/// <summary>Initializes an internal serialization handler from an array of remoting headers that are applied to a method. </summary>
/// <returns>An internal serialization handler.</returns>
/// <param name="h">An array of remoting headers that contain key/value pairs. This array is used to initialize <see cref="T:System.Runtime.Remoting.Messaging.MethodResponse" /> fields for headers that belong to the namespace "http://schemas.microsoft.com/clr/soap/messageProperties".</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027C1 RID: 10177 RVA: 0x00082960 File Offset: 0x00080B60
[MonoTODO]
public virtual object HeaderHandler(Header[] h)
{
throw new NotImplementedException();
}
/// <summary>Sets method information from serialization settings. </summary>
/// <param name="info">The data for serializing or deserializing the remote object.</param>
/// <param name="ctx">The context of a certain serialized stream.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060027C2 RID: 10178 RVA: 0x00082968 File Offset: 0x00080B68
[MonoTODO]
public void RootSetObjectData(SerializationInfo info, StreamingContext ctx)
{
throw new NotImplementedException();
}
// Token: 0x04000F62 RID: 3938
private string _methodName;
// Token: 0x04000F63 RID: 3939
private string _uri;
// Token: 0x04000F64 RID: 3940
private string _typeName;
// Token: 0x04000F65 RID: 3941
private MethodBase _methodBase;
// Token: 0x04000F66 RID: 3942
private object _returnValue;
// Token: 0x04000F67 RID: 3943
private Exception _exception;
// Token: 0x04000F68 RID: 3944
private Type[] _methodSignature;
// Token: 0x04000F69 RID: 3945
private ArgInfo _inArgInfo;
// Token: 0x04000F6A RID: 3946
private object[] _args;
// Token: 0x04000F6B RID: 3947
private object[] _outArgs;
// Token: 0x04000F6C RID: 3948
private IMethodCallMessage _callMsg;
// Token: 0x04000F6D RID: 3949
private LogicalCallContext _callContext;
// Token: 0x04000F6E RID: 3950
private Identity _targetIdentity;
/// <summary>Specifies an <see cref="T:System.Collections.IDictionary" /> interface that represents a collection of the remoting message's properties. </summary>
// Token: 0x04000F6F RID: 3951
protected IDictionary ExternalProperties;
/// <summary>Specifies an <see cref="T:System.Collections.IDictionary" /> interface that represents a collection of the remoting message's properties. </summary>
// Token: 0x04000F70 RID: 3952
protected IDictionary InternalProperties;
}
}