[System.Security.SecurityCritical] // auto-generated private String GetExceptionMethodString() { MethodBase methBase = GetTargetSiteInternal(); if (methBase == null) { return(null); } if (methBase is System.Reflection.Emit.DynamicMethod.RTDynamicMethod) { // DynamicMethods cannot be serialized return(null); } // Note that the newline separator is only a separator, chosen such that // it won't (generally) occur in a method name. This string is used // only for serialization of the Exception Method. char separator = '\n'; StringBuilder result = new StringBuilder(); if (methBase is ConstructorInfo) { RuntimeConstructorInfo rci = (RuntimeConstructorInfo)methBase; Type t = rci.ReflectedType; result.Append((int)MemberTypes.Constructor); result.Append(separator); result.Append(rci.Name); if (t != null) { result.Append(separator); result.Append(t.Assembly.FullName); result.Append(separator); result.Append(t.FullName); } result.Append(separator); result.Append(rci.ToString()); } else { Contract.Assert(methBase is MethodInfo, "[Exception.GetExceptionMethodString]methBase is MethodInfo"); RuntimeMethodInfo rmi = (RuntimeMethodInfo)methBase; Type t = rmi.DeclaringType; result.Append((int)MemberTypes.Method); result.Append(separator); result.Append(rmi.Name); result.Append(separator); result.Append(rmi.Module.Assembly.FullName); result.Append(separator); if (t != null) { result.Append(t.FullName); result.Append(separator); } result.Append(rmi.ToString()); } return(result.ToString()); }
[System.Security.SecurityCritical] // auto-generated private String GetExceptionMethodString() { MethodBase methBase = GetTargetSiteInternal(); if (methBase == null) { return(null); } if (methBase is System.Reflection.Emit.DynamicMethod.RTDynamicMethod) { // DynamicMethods不能被序列化 return(null); } // 注意换行符分隔符只是一个分隔符,选择,这样它不会(通常)发生在方法名称。 // 这个字符串的仅用于序列化异常的方法。 char separator = '\n'; StringBuilder result = new StringBuilder(); if (methBase is ConstructorInfo) //如果函数是构造函数 { RuntimeConstructorInfo rci = (RuntimeConstructorInfo)methBase; //将目标函数转换为运行时构造函数 Type t = rci.ReflectedType; //获取构造函数的引用格式 result.Append((int)MemberTypes.Constructor); //添加成员属性为构造 result.Append(separator); //添加换行符 result.Append(rci.Name); //添加运行时构造函数名称 if (t != null) { result.Append(separator); //添加换行号 result.Append(t.Assembly.FullName); //添加程序集全称 result.Append(separator); //添加换行符 result.Append(t.FullName); //添加格式全称 } result.Append(separator); //添加换行符 result.Append(rci.ToString()); //添加运行时信息 } else //如果不是构造函数 { Contract.Assert(methBase is MethodInfo, "[Exception.GetExceptionMethodString]methBase is MethodInfo"); RuntimeMethodInfo rmi = (RuntimeMethodInfo)methBase; //将目标函数转换为运行时方法 Type t = rmi.DeclaringType; //获取运行时声明函数 result.Append((int)MemberTypes.Method); //添加成员属性为方法 result.Append(separator); //添加换行符 result.Append(rmi.Name); //添加运行时方法名称 result.Append(separator); //添加换行符 result.Append(rmi.Module.Assembly.FullName); //添加程序集信息 result.Append(separator); //添加换行符 if (t != null) { result.Append(t.FullName); //添加方法全称 result.Append(separator); //添加换行符 } result.Append(rmi.ToString()); //添加运行时方法信息 } return(result.ToString()); }
private string GetExceptionMethodString() { MethodBase targetSiteInternal = this.GetTargetSiteInternal(); if (targetSiteInternal == null) { return(null); } if (targetSiteInternal is DynamicMethod.RTDynamicMethod) { return(null); } char value = '\n'; StringBuilder stringBuilder = new StringBuilder(); if (targetSiteInternal is ConstructorInfo) { RuntimeConstructorInfo runtimeConstructorInfo = (RuntimeConstructorInfo)targetSiteInternal; Type reflectedType = runtimeConstructorInfo.ReflectedType; stringBuilder.Append(1); stringBuilder.Append(value); stringBuilder.Append(runtimeConstructorInfo.Name); if (reflectedType != null) { stringBuilder.Append(value); stringBuilder.Append(reflectedType.Assembly.FullName); stringBuilder.Append(value); stringBuilder.Append(reflectedType.FullName); } stringBuilder.Append(value); stringBuilder.Append(runtimeConstructorInfo.ToString()); } else { RuntimeMethodInfo runtimeMethodInfo = (RuntimeMethodInfo)targetSiteInternal; Type declaringType = runtimeMethodInfo.DeclaringType; stringBuilder.Append(8); stringBuilder.Append(value); stringBuilder.Append(runtimeMethodInfo.Name); stringBuilder.Append(value); stringBuilder.Append(runtimeMethodInfo.Module.Assembly.FullName); stringBuilder.Append(value); if (declaringType != null) { stringBuilder.Append(declaringType.FullName); stringBuilder.Append(value); } stringBuilder.Append(runtimeMethodInfo.ToString()); } return(stringBuilder.ToString()); }
private String GetExceptionMethodString() { MethodBase methBase = this.TargetSite; if (methBase == null) { return(null); } char separator = '\0'; StringBuilder result = new StringBuilder(); if (methBase is ConstructorInfo) { RuntimeConstructorInfo rci = (RuntimeConstructorInfo)methBase; Type t = rci.InternalReflectedClass(false); result.Append((int)MemberTypes.Constructor); result.Append(separator); result.Append(rci.Name); result.Append(separator); result.Append(t.Assembly.FullName); result.Append(separator); result.Append(t.FullName); result.Append(separator); result.Append(rci.ToString()); } else { BCLDebug.Assert(methBase is MethodInfo, "[Exception.GetExceptionMethodString]methBase is MethodInfo"); RuntimeMethodInfo rmi = (RuntimeMethodInfo)methBase; Type t = rmi.InternalReflectedClass(false); result.Append((int)MemberTypes.Method); result.Append(separator); result.Append(rmi.Name); result.Append(separator); result.Append(t.Assembly.FullName); result.Append(separator); result.Append(t.FullName); result.Append(separator); result.Append(rmi.ToString()); } return(result.ToString()); }