446 lines
12 KiB
C#
446 lines
12 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace System.Reflection
|
|
{
|
|
// Token: 0x0200025A RID: 602
|
|
[Serializable]
|
|
internal class MonoMethod : MethodInfo, ISerializable
|
|
{
|
|
// Token: 0x06001F3E RID: 7998 RVA: 0x00072F50 File Offset: 0x00071150
|
|
internal MonoMethod()
|
|
{
|
|
}
|
|
|
|
// Token: 0x06001F3F RID: 7999 RVA: 0x00072F58 File Offset: 0x00071158
|
|
internal MonoMethod(RuntimeMethodHandle mhandle)
|
|
{
|
|
this.mhandle = mhandle.Value;
|
|
}
|
|
|
|
// Token: 0x06001F40 RID: 8000
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern string get_name(MethodBase method);
|
|
|
|
// Token: 0x06001F41 RID: 8001
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern MonoMethod get_base_definition(MonoMethod method);
|
|
|
|
// Token: 0x06001F42 RID: 8002 RVA: 0x00072F70 File Offset: 0x00071170
|
|
public override MethodInfo GetBaseDefinition()
|
|
{
|
|
return MonoMethod.get_base_definition(this);
|
|
}
|
|
|
|
// Token: 0x170005C3 RID: 1475
|
|
// (get) Token: 0x06001F43 RID: 8003 RVA: 0x00072F78 File Offset: 0x00071178
|
|
public override ParameterInfo ReturnParameter
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetReturnParameterInfo(this);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005C4 RID: 1476
|
|
// (get) Token: 0x06001F44 RID: 8004 RVA: 0x00072F80 File Offset: 0x00071180
|
|
public override Type ReturnType
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetReturnType(this.mhandle);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005C5 RID: 1477
|
|
// (get) Token: 0x06001F45 RID: 8005 RVA: 0x00072F90 File Offset: 0x00071190
|
|
public override ICustomAttributeProvider ReturnTypeCustomAttributes
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetReturnParameterInfo(this);
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001F46 RID: 8006 RVA: 0x00072F98 File Offset: 0x00071198
|
|
public override MethodImplAttributes GetMethodImplementationFlags()
|
|
{
|
|
return MonoMethodInfo.GetMethodImplementationFlags(this.mhandle);
|
|
}
|
|
|
|
// Token: 0x06001F47 RID: 8007 RVA: 0x00072FA8 File Offset: 0x000711A8
|
|
public override ParameterInfo[] GetParameters()
|
|
{
|
|
ParameterInfo[] parametersInfo = MonoMethodInfo.GetParametersInfo(this.mhandle, this);
|
|
ParameterInfo[] array = new ParameterInfo[parametersInfo.Length];
|
|
parametersInfo.CopyTo(array, 0);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06001F48 RID: 8008
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal extern object InternalInvoke(object obj, object[] parameters, out Exception exc);
|
|
|
|
// Token: 0x06001F49 RID: 8009 RVA: 0x00072FD4 File Offset: 0x000711D4
|
|
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
|
|
{
|
|
if (binder == null)
|
|
{
|
|
binder = Binder.DefaultBinder;
|
|
}
|
|
ParameterInfo[] parametersInfo = MonoMethodInfo.GetParametersInfo(this.mhandle, this);
|
|
if ((parameters == null && parametersInfo.Length != 0) || (parameters != null && parameters.Length != parametersInfo.Length))
|
|
{
|
|
throw new TargetParameterCountException("parameters do not match signature");
|
|
}
|
|
if ((invokeAttr & BindingFlags.ExactBinding) == BindingFlags.Default)
|
|
{
|
|
if (!Binder.ConvertArgs(binder, parameters, parametersInfo, culture))
|
|
{
|
|
throw new ArgumentException("failed to convert parameters");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < parametersInfo.Length; i++)
|
|
{
|
|
if (parameters[i].GetType() != parametersInfo[i].ParameterType)
|
|
{
|
|
throw new ArgumentException("parameters do not match signature");
|
|
}
|
|
}
|
|
}
|
|
if (this.ContainsGenericParameters)
|
|
{
|
|
throw new InvalidOperationException("Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.");
|
|
}
|
|
object obj2 = null;
|
|
Exception ex;
|
|
try
|
|
{
|
|
obj2 = this.InternalInvoke(obj, parameters, out ex);
|
|
}
|
|
catch (ThreadAbortException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (MethodAccessException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
throw new TargetInvocationException(ex2);
|
|
}
|
|
if (ex != null)
|
|
{
|
|
throw ex;
|
|
}
|
|
return obj2;
|
|
}
|
|
|
|
// Token: 0x170005C6 RID: 1478
|
|
// (get) Token: 0x06001F4A RID: 8010 RVA: 0x00073128 File Offset: 0x00071328
|
|
public override RuntimeMethodHandle MethodHandle
|
|
{
|
|
get
|
|
{
|
|
return new RuntimeMethodHandle(this.mhandle);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005C7 RID: 1479
|
|
// (get) Token: 0x06001F4B RID: 8011 RVA: 0x00073138 File Offset: 0x00071338
|
|
public override MethodAttributes Attributes
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetAttributes(this.mhandle);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005C8 RID: 1480
|
|
// (get) Token: 0x06001F4C RID: 8012 RVA: 0x00073148 File Offset: 0x00071348
|
|
public override CallingConventions CallingConvention
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetCallingConvention(this.mhandle);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005C9 RID: 1481
|
|
// (get) Token: 0x06001F4D RID: 8013 RVA: 0x00073158 File Offset: 0x00071358
|
|
public override Type ReflectedType
|
|
{
|
|
get
|
|
{
|
|
return this.reftype;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005CA RID: 1482
|
|
// (get) Token: 0x06001F4E RID: 8014 RVA: 0x00073160 File Offset: 0x00071360
|
|
public override Type DeclaringType
|
|
{
|
|
get
|
|
{
|
|
return MonoMethodInfo.GetDeclaringType(this.mhandle);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170005CB RID: 1483
|
|
// (get) Token: 0x06001F4F RID: 8015 RVA: 0x00073170 File Offset: 0x00071370
|
|
public override string Name
|
|
{
|
|
get
|
|
{
|
|
if (this.name != null)
|
|
{
|
|
return this.name;
|
|
}
|
|
return MonoMethod.get_name(this);
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001F50 RID: 8016 RVA: 0x0007318C File Offset: 0x0007138C
|
|
public override bool IsDefined(Type attributeType, bool inherit)
|
|
{
|
|
return MonoCustomAttrs.IsDefined(this, attributeType, inherit);
|
|
}
|
|
|
|
// Token: 0x06001F51 RID: 8017 RVA: 0x00073198 File Offset: 0x00071398
|
|
public override object[] GetCustomAttributes(bool inherit)
|
|
{
|
|
return MonoCustomAttrs.GetCustomAttributes(this, inherit);
|
|
}
|
|
|
|
// Token: 0x06001F52 RID: 8018 RVA: 0x000731A4 File Offset: 0x000713A4
|
|
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
|
{
|
|
return MonoCustomAttrs.GetCustomAttributes(this, attributeType, inherit);
|
|
}
|
|
|
|
// Token: 0x06001F53 RID: 8019
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern DllImportAttribute GetDllImportAttribute(IntPtr mhandle);
|
|
|
|
// Token: 0x06001F54 RID: 8020 RVA: 0x000731B0 File Offset: 0x000713B0
|
|
internal object[] GetPseudoCustomAttributes()
|
|
{
|
|
int num = 0;
|
|
MonoMethodInfo methodInfo = MonoMethodInfo.GetMethodInfo(this.mhandle);
|
|
if ((methodInfo.iattrs & MethodImplAttributes.PreserveSig) != MethodImplAttributes.IL)
|
|
{
|
|
num++;
|
|
}
|
|
if ((methodInfo.attrs & MethodAttributes.PinvokeImpl) != MethodAttributes.PrivateScope)
|
|
{
|
|
num++;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
return null;
|
|
}
|
|
object[] array = new object[num];
|
|
num = 0;
|
|
if ((methodInfo.iattrs & MethodImplAttributes.PreserveSig) != MethodImplAttributes.IL)
|
|
{
|
|
array[num++] = new PreserveSigAttribute();
|
|
}
|
|
if ((methodInfo.attrs & MethodAttributes.PinvokeImpl) != MethodAttributes.PrivateScope)
|
|
{
|
|
DllImportAttribute dllImportAttribute = MonoMethod.GetDllImportAttribute(this.mhandle);
|
|
if ((methodInfo.iattrs & MethodImplAttributes.PreserveSig) != MethodImplAttributes.IL)
|
|
{
|
|
dllImportAttribute.PreserveSig = true;
|
|
}
|
|
array[num++] = dllImportAttribute;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06001F55 RID: 8021 RVA: 0x00073268 File Offset: 0x00071468
|
|
private static bool ShouldPrintFullName(Type type)
|
|
{
|
|
return type.IsClass && (!type.IsPointer || (!type.GetElementType().IsPrimitive && !type.GetElementType().IsNested));
|
|
}
|
|
|
|
// Token: 0x06001F56 RID: 8022 RVA: 0x000732B4 File Offset: 0x000714B4
|
|
public override string ToString()
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
Type returnType = this.ReturnType;
|
|
if (MonoMethod.ShouldPrintFullName(returnType))
|
|
{
|
|
stringBuilder.Append(returnType.ToString());
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.Append(returnType.Name);
|
|
}
|
|
stringBuilder.Append(" ");
|
|
stringBuilder.Append(this.Name);
|
|
if (this.IsGenericMethod)
|
|
{
|
|
Type[] genericArguments = this.GetGenericArguments();
|
|
stringBuilder.Append("[");
|
|
for (int i = 0; i < genericArguments.Length; i++)
|
|
{
|
|
if (i > 0)
|
|
{
|
|
stringBuilder.Append(",");
|
|
}
|
|
stringBuilder.Append(genericArguments[i].Name);
|
|
}
|
|
stringBuilder.Append("]");
|
|
}
|
|
stringBuilder.Append("(");
|
|
ParameterInfo[] parameters = this.GetParameters();
|
|
for (int j = 0; j < parameters.Length; j++)
|
|
{
|
|
if (j > 0)
|
|
{
|
|
stringBuilder.Append(", ");
|
|
}
|
|
Type type = parameters[j].ParameterType;
|
|
bool isByRef = type.IsByRef;
|
|
if (isByRef)
|
|
{
|
|
type = type.GetElementType();
|
|
}
|
|
if (MonoMethod.ShouldPrintFullName(type))
|
|
{
|
|
stringBuilder.Append(type.ToString());
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.Append(type.Name);
|
|
}
|
|
if (isByRef)
|
|
{
|
|
stringBuilder.Append(" ByRef");
|
|
}
|
|
}
|
|
if ((this.CallingConvention & CallingConventions.VarArgs) != (CallingConventions)0)
|
|
{
|
|
if (parameters.Length > 0)
|
|
{
|
|
stringBuilder.Append(", ");
|
|
}
|
|
stringBuilder.Append("...");
|
|
}
|
|
stringBuilder.Append(")");
|
|
return stringBuilder.ToString();
|
|
}
|
|
|
|
// Token: 0x06001F57 RID: 8023 RVA: 0x00073458 File Offset: 0x00071658
|
|
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
|
{
|
|
Type[] array = ((!this.IsGenericMethod || this.IsGenericMethodDefinition) ? null : this.GetGenericArguments());
|
|
MemberInfoSerializationHolder.Serialize(info, this.Name, this.ReflectedType, this.ToString(), MemberTypes.Method, array);
|
|
}
|
|
|
|
// Token: 0x06001F58 RID: 8024 RVA: 0x000734A4 File Offset: 0x000716A4
|
|
public override MethodInfo MakeGenericMethod(Type[] methodInstantiation)
|
|
{
|
|
if (methodInstantiation == null)
|
|
{
|
|
throw new ArgumentNullException("methodInstantiation");
|
|
}
|
|
for (int i = 0; i < methodInstantiation.Length; i++)
|
|
{
|
|
if (methodInstantiation[i] == null)
|
|
{
|
|
throw new ArgumentNullException();
|
|
}
|
|
}
|
|
MethodInfo methodInfo = this.MakeGenericMethod_impl(methodInstantiation);
|
|
if (methodInfo == null)
|
|
{
|
|
throw new ArgumentException(string.Format("The method has {0} generic parameter(s) but {1} generic argument(s) were provided.", this.GetGenericArguments().Length, methodInstantiation.Length));
|
|
}
|
|
return methodInfo;
|
|
}
|
|
|
|
// Token: 0x06001F59 RID: 8025
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private extern MethodInfo MakeGenericMethod_impl(Type[] types);
|
|
|
|
// Token: 0x06001F5A RID: 8026
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
public override extern Type[] GetGenericArguments();
|
|
|
|
// Token: 0x06001F5B RID: 8027
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private extern MethodInfo GetGenericMethodDefinition_impl();
|
|
|
|
// Token: 0x06001F5C RID: 8028 RVA: 0x0007351C File Offset: 0x0007171C
|
|
public override MethodInfo GetGenericMethodDefinition()
|
|
{
|
|
MethodInfo genericMethodDefinition_impl = this.GetGenericMethodDefinition_impl();
|
|
if (genericMethodDefinition_impl == null)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
return genericMethodDefinition_impl;
|
|
}
|
|
|
|
// Token: 0x170005CC RID: 1484
|
|
// (get) Token: 0x06001F5D RID: 8029
|
|
public override extern bool IsGenericMethodDefinition
|
|
{
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
get;
|
|
}
|
|
|
|
// Token: 0x170005CD RID: 1485
|
|
// (get) Token: 0x06001F5E RID: 8030
|
|
public override extern bool IsGenericMethod
|
|
{
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
get;
|
|
}
|
|
|
|
// Token: 0x170005CE RID: 1486
|
|
// (get) Token: 0x06001F5F RID: 8031 RVA: 0x00073540 File Offset: 0x00071740
|
|
public override bool ContainsGenericParameters
|
|
{
|
|
get
|
|
{
|
|
if (this.IsGenericMethod)
|
|
{
|
|
foreach (Type type in this.GetGenericArguments())
|
|
{
|
|
if (type.ContainsGenericParameters)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return this.DeclaringType.ContainsGenericParameters;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001F60 RID: 8032 RVA: 0x00073590 File Offset: 0x00071790
|
|
public override MethodBody GetMethodBody()
|
|
{
|
|
return MethodBase.GetMethodBody(this.mhandle);
|
|
}
|
|
|
|
// Token: 0x04000ACE RID: 2766
|
|
internal IntPtr mhandle;
|
|
|
|
// Token: 0x04000ACF RID: 2767
|
|
private string name;
|
|
|
|
// Token: 0x04000AD0 RID: 2768
|
|
private Type reftype;
|
|
}
|
|
}
|