using System; using System.Collections; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; namespace System.Runtime.Remoting.Messaging { /// Implements the interface to create a request message that acts as a method call on a remote object. // Token: 0x020003F4 RID: 1012 [CLSCompliant(false)] [ComVisible(true)] [Serializable] public class MethodCall : ISerializable, IInternalMessage, IMessage, IMethodCallMessage, IMethodMessage, ISerializationRootObject { /// Initializes a new instance of the class from an array of remoting headers. /// An array of remoting headers that contains key/value pairs. This array is used to initialize fields for headers that belong to the namespace "http://schemas.microsoft.com/clr/soap/messageProperties". // Token: 0x06002741 RID: 10049 RVA: 0x00080B2C File Offset: 0x0007ED2C public MethodCall(Header[] h1) { this.Init(); if (h1 == null || h1.Length == 0) { return; } foreach (Header header in h1) { this.InitMethodProperty(header.Name, header.Value); } this.ResolveMethod(); } // Token: 0x06002742 RID: 10050 RVA: 0x00080B88 File Offset: 0x0007ED88 internal MethodCall(SerializationInfo info, StreamingContext context) { this.Init(); foreach (SerializationEntry serializationEntry in info) { this.InitMethodProperty(serializationEntry.Name, serializationEntry.Value); } } // Token: 0x06002743 RID: 10051 RVA: 0x00080BD4 File Offset: 0x0007EDD4 internal MethodCall(CADMethodCallMessage msg) { this._uri = string.Copy(msg.Uri); ArrayList arguments = msg.GetArguments(); this._args = msg.GetArgs(arguments); this._callContext = msg.GetLogicalCallContext(arguments); if (this._callContext == null) { this._callContext = new LogicalCallContext(); } this._methodBase = msg.GetMethod(); this.Init(); if (msg.PropertiesCount > 0) { CADMessageBase.UnmarshalProperties(this.Properties, msg.PropertiesCount, arguments); } } /// Initializes a new instance of the class by copying an existing message. /// A remoting message. // Token: 0x06002744 RID: 10052 RVA: 0x00080C60 File Offset: 0x0007EE60 public MethodCall(IMessage msg) { if (msg is IMethodMessage) { this.CopyFrom((IMethodMessage)msg); } else { foreach (object obj in msg.Properties) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; this.InitMethodProperty((string)dictionaryEntry.Key, dictionaryEntry.Value); } this.Init(); } } // Token: 0x06002745 RID: 10053 RVA: 0x00080D0C File Offset: 0x0007EF0C internal MethodCall(string uri, string typeName, string methodName, object[] args) { this._uri = uri; this._typeName = typeName; this._methodName = methodName; this._args = args; this.Init(); this.ResolveMethod(); } // Token: 0x06002746 RID: 10054 RVA: 0x00080D40 File Offset: 0x0007EF40 internal MethodCall() { } // Token: 0x17000777 RID: 1911 // (get) Token: 0x06002747 RID: 10055 RVA: 0x00080D48 File Offset: 0x0007EF48 // (set) Token: 0x06002748 RID: 10056 RVA: 0x00080D50 File Offset: 0x0007EF50 string IInternalMessage.Uri { get { return this.Uri; } set { this.Uri = value; } } // Token: 0x17000778 RID: 1912 // (get) Token: 0x06002749 RID: 10057 RVA: 0x00080D5C File Offset: 0x0007EF5C // (set) Token: 0x0600274A RID: 10058 RVA: 0x00080D64 File Offset: 0x0007EF64 Identity IInternalMessage.TargetIdentity { get { return this._targetIdentity; } set { this._targetIdentity = value; } } // Token: 0x0600274B RID: 10059 RVA: 0x00080D70 File Offset: 0x0007EF70 internal void CopyFrom(IMethodMessage call) { this._uri = call.Uri; this._typeName = call.TypeName; this._methodName = call.MethodName; this._args = call.Args; this._methodSignature = (Type[])call.MethodSignature; this._methodBase = call.MethodBase; this._callContext = call.LogicalCallContext; this.Init(); } // Token: 0x0600274C RID: 10060 RVA: 0x00080DDC File Offset: 0x0007EFDC internal virtual 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 "__Args": this._args = (object[])value; return; case "__CallContext": this._callContext = (LogicalCallContext)value; return; case "__Uri": this._uri = (string)value; return; case "__GenericArguments": this._genericArguments = (Type[])value; return; } this.Properties[key] = value; } /// The method is not implemented. /// The data for serializing or deserializing the remote object. /// The context of a certain serialized stream. /// /// /// // Token: 0x0600274D RID: 10061 RVA: 0x00080F00 File Offset: 0x0007F100 public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("__TypeName", this._typeName); info.AddValue("__MethodName", this._methodName); info.AddValue("__MethodSignature", this._methodSignature); info.AddValue("__Args", this._args); info.AddValue("__CallContext", this._callContext); info.AddValue("__Uri", this._uri); info.AddValue("__GenericArguments", this._genericArguments); if (this.InternalProperties != null) { foreach (object obj in this.InternalProperties) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; info.AddValue((string)dictionaryEntry.Key, dictionaryEntry.Value); } } } /// Gets the number of arguments passed to a method. /// A that represents the number of arguments passed to a method. /// /// /// // Token: 0x17000779 RID: 1913 // (get) Token: 0x0600274E RID: 10062 RVA: 0x00081004 File Offset: 0x0007F204 public int ArgCount { get { return this._args.Length; } } /// Gets an array of arguments passed to a method. /// An array of type that represents the arguments passed to a method. /// /// /// // Token: 0x1700077A RID: 1914 // (get) Token: 0x0600274F RID: 10063 RVA: 0x00081010 File Offset: 0x0007F210 public object[] Args { get { return this._args; } } /// Gets a value that indicates whether the method can accept a variable number of arguments. /// true if the method can accept a variable number of arguments; otherwise, false. /// /// /// // Token: 0x1700077B RID: 1915 // (get) Token: 0x06002750 RID: 10064 RVA: 0x00081018 File Offset: 0x0007F218 public bool HasVarArgs { get { return (this.MethodBase.CallingConvention | CallingConventions.VarArgs) != (CallingConventions)0; } } /// Gets the number of arguments in the method call that are not marked as out parameters. /// A that represents the number of arguments in the method call that are not marked as out parameters. /// /// /// // Token: 0x1700077C RID: 1916 // (get) Token: 0x06002751 RID: 10065 RVA: 0x00081030 File Offset: 0x0007F230 public int InArgCount { get { if (this._inArgInfo == null) { this._inArgInfo = new ArgInfo(this._methodBase, ArgInfoType.In); } return this._inArgInfo.GetInOutArgCount(); } } /// Gets an array of arguments in the method call that are not marked as out parameters. /// An array of type that represents arguments in the method call that are not marked as out parameters. /// /// /// // Token: 0x1700077D RID: 1917 // (get) Token: 0x06002752 RID: 10066 RVA: 0x00081068 File Offset: 0x0007F268 public object[] InArgs { get { if (this._inArgInfo == null) { this._inArgInfo = new ArgInfo(this._methodBase, ArgInfoType.In); } return this._inArgInfo.GetInOutArgs(this._args); } } /// Gets the for the current method call. /// The for the current method call. /// /// /// // Token: 0x1700077E RID: 1918 // (get) Token: 0x06002753 RID: 10067 RVA: 0x000810A4 File Offset: 0x0007F2A4 public LogicalCallContext LogicalCallContext { get { if (this._callContext == null) { this._callContext = new LogicalCallContext(); } return this._callContext; } } /// Gets the of the called method. /// The of the called method. /// /// /// // Token: 0x1700077F RID: 1919 // (get) Token: 0x06002754 RID: 10068 RVA: 0x000810C4 File Offset: 0x0007F2C4 public MethodBase MethodBase { get { if (this._methodBase == null) { this.ResolveMethod(); } return this._methodBase; } } /// Gets the name of the invoked method. /// A that contains the name of the invoked method. /// /// /// // Token: 0x17000780 RID: 1920 // (get) Token: 0x06002755 RID: 10069 RVA: 0x000810E0 File Offset: 0x0007F2E0 public string MethodName { get { if (this._methodName == null) { this._methodName = this._methodBase.Name; } return this._methodName; } } /// Gets an object that contains the method signature. /// A that contains the method signature. /// /// /// // Token: 0x17000781 RID: 1921 // (get) Token: 0x06002756 RID: 10070 RVA: 0x00081110 File Offset: 0x0007F310 public object MethodSignature { get { if (this._methodSignature == null && this._methodBase != null) { ParameterInfo[] parameters = this._methodBase.GetParameters(); this._methodSignature = new Type[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { this._methodSignature[i] = parameters[i].ParameterType; } } return this._methodSignature; } } /// Gets an interface that represents a collection of the remoting message's properties. /// An interface that represents a collection of the remoting message's properties. /// /// /// // Token: 0x17000782 RID: 1922 // (get) Token: 0x06002757 RID: 10071 RVA: 0x00081178 File Offset: 0x0007F378 public virtual IDictionary Properties { get { if (this.ExternalProperties == null) { this.InitDictionary(); } return this.ExternalProperties; } } // Token: 0x06002758 RID: 10072 RVA: 0x00081194 File Offset: 0x0007F394 internal virtual void InitDictionary() { MethodCallDictionary methodCallDictionary = new MethodCallDictionary(this); this.ExternalProperties = methodCallDictionary; this.InternalProperties = methodCallDictionary.GetInternalProperties(); } /// Gets the full type name of the remote object on which the method call is being made. /// A that contains the full type name of the remote object on which the method call is being made. /// /// /// // Token: 0x17000783 RID: 1923 // (get) Token: 0x06002759 RID: 10073 RVA: 0x000811BC File Offset: 0x0007F3BC public string TypeName { get { if (this._typeName == null) { this._typeName = this._methodBase.DeclaringType.AssemblyQualifiedName; } return this._typeName; } } /// Gets or sets the Uniform Resource Identifier (URI) of the remote object on which the method call is being made. /// The URI of a remote object. /// /// /// // Token: 0x17000784 RID: 1924 // (get) Token: 0x0600275A RID: 10074 RVA: 0x000811E8 File Offset: 0x0007F3E8 // (set) Token: 0x0600275B RID: 10075 RVA: 0x000811F0 File Offset: 0x0007F3F0 public string Uri { get { return this._uri; } set { this._uri = value; } } /// Gets a method argument, as an object, at a specified index. /// The method argument as an object. /// The index of the requested argument. /// /// /// // Token: 0x0600275C RID: 10076 RVA: 0x000811FC File Offset: 0x0007F3FC public object GetArg(int argNum) { return this._args[argNum]; } /// Gets the name of a method argument at a specified index. /// The name of the method argument. /// The index of the requested argument. /// /// /// /// // Token: 0x0600275D RID: 10077 RVA: 0x00081208 File Offset: 0x0007F408 public string GetArgName(int index) { return this._methodBase.GetParameters()[index].Name; } /// Gets a method argument at a specified index that is not marked as an out parameter. /// The method argument that is not marked as an out parameter. /// The index of the requested argument. /// /// /// // Token: 0x0600275E RID: 10078 RVA: 0x0008121C File Offset: 0x0007F41C public object GetInArg(int argNum) { if (this._inArgInfo == null) { this._inArgInfo = new ArgInfo(this._methodBase, ArgInfoType.In); } return this._args[this._inArgInfo.GetInOutArgIndex(argNum)]; } /// Gets the name of a method argument at a specified index that is not marked as an out parameter. /// The name of the method argument that is not marked as an out parameter. /// The index of the requested argument. /// /// /// // Token: 0x0600275F RID: 10079 RVA: 0x0008125C File Offset: 0x0007F45C public string GetInArgName(int index) { if (this._inArgInfo == null) { this._inArgInfo = new ArgInfo(this._methodBase, ArgInfoType.In); } return this._inArgInfo.GetInOutArgName(index); } /// Initializes an internal serialization handler from an array of remoting headers that are applied to a method. /// An internal serialization handler. /// An array of remoting headers that contain key/value pairs. This array is used to initialize fields for headers that belong to the namespace "http://schemas.microsoft.com/clr/soap/messageProperties". /// /// /// /// // Token: 0x06002760 RID: 10080 RVA: 0x00081288 File Offset: 0x0007F488 [MonoTODO] public virtual object HeaderHandler(Header[] h) { throw new NotImplementedException(); } /// Initializes a . /// /// /// // Token: 0x06002761 RID: 10081 RVA: 0x00081290 File Offset: 0x0007F490 public virtual void Init() { } /// Sets method information from previously initialized remoting message properties. /// /// /// /// // Token: 0x06002762 RID: 10082 RVA: 0x00081294 File Offset: 0x0007F494 public void ResolveMethod() { if (this._uri != null) { Type serverTypeForUri = RemotingServices.GetServerTypeForUri(this._uri); if (serverTypeForUri == null) { string text = ((this._typeName == null) ? string.Empty : (" (" + this._typeName + ")")); throw new RemotingException("Requested service not found" + text + ". No receiver for uri " + this._uri); } Type type = this.CastTo(this._typeName, serverTypeForUri); if (type == null) { throw new RemotingException(string.Concat(new string[] { "Cannot cast from client type '", this._typeName, "' to server type '", serverTypeForUri.FullName, "'" })); } this._methodBase = RemotingServices.GetMethodBaseFromName(type, this._methodName, this._methodSignature); if (this._methodBase == null) { throw new RemotingException(string.Concat(new object[] { "Method ", this._methodName, " not found in ", type })); } if (type != serverTypeForUri && type.IsInterface && !serverTypeForUri.IsInterface) { this._methodBase = RemotingServices.GetVirtualMethod(serverTypeForUri, this._methodBase); if (this._methodBase == null) { throw new RemotingException(string.Concat(new object[] { "Method ", this._methodName, " not found in ", serverTypeForUri })); } } } else { this._methodBase = RemotingServices.GetMethodBaseFromMethodMessage(this); if (this._methodBase == null) { throw new RemotingException("Method " + this._methodName + " not found in " + this.TypeName); } } if (this._methodBase.IsGenericMethod && this._methodBase.ContainsGenericParameters) { if (this.GenericArguments == null) { throw new RemotingException("The remoting infrastructure does not support open generic methods."); } this._methodBase = ((MethodInfo)this._methodBase).MakeGenericMethod(this.GenericArguments); } } // Token: 0x06002763 RID: 10083 RVA: 0x0008149C File Offset: 0x0007F69C private Type CastTo(string clientType, Type serverType) { clientType = MethodCall.GetTypeNameFromAssemblyQualifiedName(clientType); if (clientType == serverType.FullName) { return serverType; } for (Type type = serverType.BaseType; type != null; type = type.BaseType) { if (clientType == type.FullName) { return type; } } Type[] interfaces = serverType.GetInterfaces(); foreach (Type type2 in interfaces) { if (clientType == type2.FullName) { return type2; } } return null; } // Token: 0x06002764 RID: 10084 RVA: 0x0008152C File Offset: 0x0007F72C private static string GetTypeNameFromAssemblyQualifiedName(string aqname) { int num = aqname.IndexOf("]]"); int num2 = aqname.IndexOf(',', (num != -1) ? (num + 2) : 0); if (num2 != -1) { aqname = aqname.Substring(0, num2).Trim(); } return aqname; } /// Sets method information from serialization settings. /// The data for serializing or deserializing the remote object. /// The context of a given serialized stream. /// /// /// /// // Token: 0x06002765 RID: 10085 RVA: 0x00081578 File Offset: 0x0007F778 [MonoTODO] public void RootSetObjectData(SerializationInfo info, StreamingContext ctx) { throw new NotImplementedException(); } // Token: 0x17000785 RID: 1925 // (get) Token: 0x06002766 RID: 10086 RVA: 0x00081580 File Offset: 0x0007F780 private Type[] GenericArguments { get { if (this._genericArguments != null) { return this._genericArguments; } return this._genericArguments = this.MethodBase.GetGenericArguments(); } } // Token: 0x04000F46 RID: 3910 private string _uri; // Token: 0x04000F47 RID: 3911 private string _typeName; // Token: 0x04000F48 RID: 3912 private string _methodName; // Token: 0x04000F49 RID: 3913 private object[] _args; // Token: 0x04000F4A RID: 3914 private Type[] _methodSignature; // Token: 0x04000F4B RID: 3915 private MethodBase _methodBase; // Token: 0x04000F4C RID: 3916 private LogicalCallContext _callContext; // Token: 0x04000F4D RID: 3917 private ArgInfo _inArgInfo; // Token: 0x04000F4E RID: 3918 private Identity _targetIdentity; // Token: 0x04000F4F RID: 3919 private Type[] _genericArguments; /// An interface that represents a collection of the remoting message's properties. // Token: 0x04000F50 RID: 3920 protected IDictionary ExternalProperties; /// An interface that represents a collection of the remoting message's properties. // Token: 0x04000F51 RID: 3921 protected IDictionary InternalProperties; } }