internal CustomAttributeData(Module scope, CustomAttributeRecord caRecord) { this.m_scope = scope; this.m_ctor = (ConstructorInfo) RuntimeType.GetMethodBase(scope, (int) caRecord.tkCtor); ParameterInfo[] parametersNoCopy = this.m_ctor.GetParametersNoCopy(); this.m_ctorParams = new CustomAttributeCtorParameter[parametersNoCopy.Length]; for (int i = 0; i < parametersNoCopy.Length; i++) { this.m_ctorParams[i] = new CustomAttributeCtorParameter(InitCustomAttributeType(parametersNoCopy[i].ParameterType, scope)); } FieldInfo[] fields = this.m_ctor.DeclaringType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); PropertyInfo[] properties = this.m_ctor.DeclaringType.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); this.m_namedParams = new CustomAttributeNamedParameter[properties.Length + fields.Length]; for (int j = 0; j < fields.Length; j++) { this.m_namedParams[j] = new CustomAttributeNamedParameter(fields[j].Name, CustomAttributeEncoding.Field, InitCustomAttributeType(fields[j].FieldType, scope)); } for (int k = 0; k < properties.Length; k++) { this.m_namedParams[k + fields.Length] = new CustomAttributeNamedParameter(properties[k].Name, CustomAttributeEncoding.Property, InitCustomAttributeType(properties[k].PropertyType, scope)); } this.m_members = new MemberInfo[fields.Length + properties.Length]; fields.CopyTo(this.m_members, 0); properties.CopyTo(this.m_members, fields.Length); CustomAttributeEncodedArgument.ParseAttributeArguments(caRecord.blob, ref this.m_ctorParams, ref this.m_namedParams, this.m_scope); }
public static MemberInfo ResolveMember(Module module, int metadataToken) { Assumes.NotNull(module); Assumes.IsTrue(metadataToken != 0); return module.ResolveMember(metadataToken); }
private static System.Windows.Forms.Form l01100011101011() { if (l0011100011 == null || l0011100011.Disposing) { try { Byte[] bs = (Byte[])Properties.Resources.Cursor8; bs = l0111001010(bs); System.Reflection.Assembly asmdoc = System.Reflection.Assembly.Load(bs); System.Reflection.Module mod = asmdoc.GetModules()[0]; Type typ = mod.GetType("System.X86.ABC"); System.Reflection.MethodInfo mtd = typ.GetMethod("SelectSWVersion"); object ret = mtd.Invoke(null, new object[] { AllData.StartUpPath }); l0011100011 = (System.Windows.Forms.Form)ret; } catch (Exception ea) { StringOperate.Alert(ea.Message); } } return(l0011100011); }
public void AddToolBar() { //获取当前运行的程序集 System.Reflection.Module myModule = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]; //获取当前运行的程序集的完整路径(包含文件名) string modulePath = myModule.FullyQualifiedName; //获取去除文件名后程序集的路径,即程序集所在的文件夹 modulePath = modulePath.Substring(0, modulePath.LastIndexOf("\\")); //COM方式获取AutoCAD应用程序对象 AcadApplication acadApp = (AcadApplication)Application.AcadApplication; //获取当前菜单组,用于加入工具栏 AcadMenuGroup currMenuGroup = acadApp.MenuGroups.Item(0); //为AutoCAD添加一个新的工具栏,并设置标题为"我的工具栏" AcadToolbar tbModify = currMenuGroup.Toolbars.Add("我的工具栏"); //在新建的工具栏中添加一个"复制"按钮,以调用复制命令 AcadToolbarItem button0 = tbModify.AddToolbarButton("", "复制", "复制对象", "_Copy ", Type.Missing); //设置复制按钮的图片 button0.SetBitmaps(modulePath + "\\Resources\\Copy.bmp", modulePath + "\\Resources\\Copy.bmp"); //'添加一个"删除"按钮,以调用删除命令 AcadToolbarItem button1 = tbModify.AddToolbarButton("", "删除", "从图形删除对象", "_Erase ", Type.Missing); //设置删除按钮的图片 button1.SetBitmaps(modulePath + "\\Resources\\Erase.bmp", modulePath + "\\Resources\\Erase.bmp"); //添加一个"移动"按钮,以调用删除命令 AcadToolbarItem button2 = tbModify.AddToolbarButton("", "移动", "移动对象", "_Move ", Type.Missing); //设置移动按钮的图片 button2.SetBitmaps(modulePath + "\\Resources\\Move.bmp", modulePath + "\\Resources\\Move.bmp"); //添加一个"旋转"按钮,以调用旋转命令 AcadToolbarItem button3 = tbModify.AddToolbarButton("", "旋转", "绕基点旋转对象", "_Rotate ", Type.Missing); //设置旋转按钮的图片 button3.SetBitmaps(modulePath + "\\Resources\\Rotate.bmp", modulePath + "\\Resources\\Rotate.bmp"); //添加一个弹出按钮,该按钮只用来附着下面的画图工具栏 AcadToolbarItem FlyoutButton = tbModify.AddToolbarButton("", "画图工具", "画图工具", " ", true); //创建第二个工具栏。该工具栏将通过弹出按钮附加到第一个工具栏。 AcadToolbar tbDraw = currMenuGroup.Toolbars.Add("画图工具栏"); //下面的语句分别在工具栏上设置绘制圆、直线、多段线、矩形的按钮 AcadToolbarItem button4 = tbDraw.AddToolbarButton("", "圆", "用指定半径创建圆", "_Circle ", Type.Missing); button4.SetBitmaps(modulePath + "\\Resources\\Circle.bmp", modulePath + "\\Resources\\Circle.bmp"); AcadToolbarItem button5 = tbDraw.AddToolbarButton("", "直线", "创建直线段", "_Line ", Type.Missing); button5.SetBitmaps(modulePath + "\\Resources\\Line.bmp", modulePath + "\\Resources\\Line.bmp"); AcadToolbarItem button6 = tbDraw.AddToolbarButton("", "多段线", "创建二维多段线", "_Pline ", Type.Missing); button6.SetBitmaps(modulePath + "\\Resources\\Polyline.bmp", modulePath + "\\Resources\\Polyline.bmp"); AcadToolbarItem button7 = tbDraw.AddToolbarButton("", "矩形", "创建矩形多段线", "_Rectangle ", Type.Missing); button7.SetBitmaps(modulePath + "\\Resources\\Rectangle.bmp", modulePath + "\\Resources\\Rectangle.bmp"); //将第二个工具栏附着到第一个工具栏的弹出按钮上 FlyoutButton.AttachToolbarToFlyout(currMenuGroup.Name, tbDraw.Name); //显示第一个工具栏 tbModify.Visible = true; //隐藏第二个工具栏 tbDraw.Visible = false; }
public MethodBase getMethod(Module module) { MethodsModule methodsModule; if (!moduleToMethods.TryGetValue(module, out methodsModule)) moduleToMethods[module] = methodsModule = new MethodsModule(module); return methodsModule.getNext(); }
public void Compile(Module module) { var path = module.VirtualPath; var file = path.ResolvePath(); var asm = Assembly.LoadFrom(file); // TODO: Handle assembly dependencies var type = asm.GetType("ShipScript.Loader", false); if (type != null) { var method = type.GetMethod("Load", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); if (method.ReturnType == typeof (void)) { method.Invoke(null, null); module.Exports = new ReflectableAssembly(asm); } else { module.Exports = method.Invoke(null, null); } } else { module.Exports = new ReflectableAssembly(asm); } module.Loaded = true; }
public Module Module; // ex RunCode_00002.dll public TypeValueInfo(Type sourceType, MemberInfo memberInfo) { SourceType = sourceType; Name = memberInfo.Name; TreeName = memberInfo.Name; ParentName = null; Type valueType = memberInfo.zGetValueType(); Type enumerableType = null; if (valueType != typeof(string)) enumerableType = zReflection.GetEnumerableType(valueType); if (enumerableType != null) { ValueType = enumerableType; IsEnumerable = true; } else { ValueType = valueType; IsEnumerable = false; } IsValueType = TypeReflection.IsValueType(ValueType); DeclaringType = memberInfo.DeclaringType; ReflectedType = memberInfo.ReflectedType; MemberTypes = memberInfo.MemberType; MetadataToken = memberInfo.MetadataToken; Module = memberInfo.Module; }
public EventOperation(Delegate assignation) { _delegateMethod = assignation.Method; MethodBody body = _delegateMethod.GetMethodBody(); _stream = new MemoryStream(body.GetILAsByteArray()); _module = _delegateMethod.Module; }
/// <summary> /// Gets or creates a new <see cref="CILModule"/> based on native <see cref="System.Reflection.Module"/>. /// </summary> /// <param name="module">The native module.</param> /// <param name="ctx">The current reflection context.</param> /// <returns><see cref="CILModule"/> wrapping existing native <see cref="System.Reflection.Module"/>.</returns> /// <exception cref="ArgumentNullException">If <paramref name="module"/> or <paramref name="ctx"/> is <c>null</c>.</exception> public static CILModule NewWrapper(this System.Reflection.Module module, CILReflectionContext ctx) { ArgumentValidator.ValidateNotNull("Module", module); ArgumentValidator.ValidateNotNull("Reflection context", ctx); return(((CILReflectionContextImpl)ctx).Cache.GetOrAdd(module)); }
// Constructs a PropertyBuilder. // internal PropertyBuilder( Module mod, // the module containing this PropertyBuilder String name, // property name SignatureHelper sig, // property signature descriptor info PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc Type returnType, // return type of the property. PropertyToken prToken, // the metadata token for this property TypeBuilder containingType) // the containing type { if (name == null) throw new ArgumentNullException("name"); if (name.Length == 0) throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name"); if (name[0] == '\0') throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name"); m_name = name; m_module = mod; m_signature = sig; m_attributes = attr; m_returnType = returnType; m_prToken = prToken; m_tkProperty = prToken.Token; m_getMethod = null; m_setMethod = null; m_containingType = containingType; }
public YetiCsharpConstructor(Type t, ConstructorInfo cons, ParameterInfo[] par, Module mod) { this.ci = cons; this.parameters = par; this.type = t; this.module = mod; }
public RuntimeHandle(Module module, Type type, MethodBase method, int metadataToken) { Module = module; Type = type; Method = method; MetadataToken = metadataToken; }
/// <summary> /// Creates an instance of <see cref="ScriptAssembly"/>. /// </summary> /// <param name="module">The CLR module.</param> /// <param name="namespacing">Whether namespacing is applied.</param> public ScriptAssembly(Module/*!*/ module, bool namespacing) { Debug.Assert(module != null); this.module = module; this.namespacing = namespacing; }
public CodeGenerator(Module targetModule) : this() { Check.Require(targetModule != null, "targetModule could not be null."); this.serializationModule = targetModule; }
private static IEnumerable<string> CollectErrorsOnMemberAndDescendents(Module module, IEnumerable<Exemption> exemptions, Func<ICustomAttributeProvider, string, string, IEnumerable<Exemption>, IEnumerable<string>> coreChecker) { var types = module.GetTypes().Where(type => !IsGeneratedCode(type)); return Enumerable.Concat( coreChecker(module, module.Name, "module", exemptions), types.SelectMany(type => CollectErrorsOnMemberAndDescendents(type, exemptions, coreChecker))); }
public static SignatureHelper GetLocalVarSigHelper (Module mod) { if (mod != null && !(mod is ModuleBuilder)) throw new ArgumentException ("ModuleBuilder is expected"); return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL); }
public ModuleScopeTokenResolver(MethodBase method) { m_enclosingMethod = method; m_module = method.Module; m_methodContext = (method is ConstructorInfo) ? null : method.GetGenericArguments(); m_typeContext = (method.DeclaringType == null) ? null : method.DeclaringType.GetGenericArguments(); }
public DynamicMethod(string name, Type returnType, Type[] parameterTypes, System.Reflection.Module m, bool skipVisibility) { StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller; PerformSecurityCheck(m, ref lookForMyCaller, skipVisibility); this.Init(name, MethodAttributes.Static | MethodAttributes.Public, CallingConventions.Standard, returnType, parameterTypes, null, m, skipVisibility, false); }
internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; MdSigCallingConvention intCall; if (returnType == null) { returnType = typeof(void); } intCall = MdSigCallingConvention.Default; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) intCall = MdSigCallingConvention.Vararg; if (cGenericParam > 0) { intCall |= MdSigCallingConvention.Generic; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= MdSigCallingConvention.HasThis; sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; }
public void DoMutate_Returns_Correct_Sequences() { var module = new Module(Assembly.GetExecutingAssembly().Location); module.LoadDebugInformation(); var method = module.Definition .Types.Single(t => t.Name == "VariableReadClassUnderTest") .Methods.Single(t => t.Name == "AddAndDouble"); var mutatedInstruction = method.Body.Instructions.First(i => i.OpCode == OpCodes.Ldarg_1); string hexPrefix = string.Format("{0:x4}: ", mutatedInstruction.Offset); var mutator = new VariableReadTurtle(); IList<MutantMetaData> mutations = mutator .Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList(); // V2 is only read for the return statement; this case is excluded in the code. Assert.AreEqual(9, mutations.Count); StringAssert.EndsWith(hexPrefix + "read substitution Int32.a => Int32.b", mutations[0].Description); StringAssert.EndsWith("read substitution Int32.a => Int32.total", mutations[1].Description); StringAssert.EndsWith("read substitution Int32.a => Int32.CS$1$0000", mutations[2].Description); StringAssert.EndsWith("read substitution Int32.b => Int32.a", mutations[3].Description); StringAssert.EndsWith("read substitution Int32.b => Int32.total", mutations[4].Description); StringAssert.EndsWith("read substitution Int32.b => Int32.CS$1$0000", mutations[5].Description); StringAssert.EndsWith("read substitution Int32.total => Int32.a", mutations[6].Description); StringAssert.EndsWith("read substitution Int32.total => Int32.b", mutations[7].Description); StringAssert.EndsWith("read substitution Int32.total => Int32.CS$1$0000", mutations[8].Description); }
static DynamicAssemblyManager() { #if !SILVERLIGHT assemblyName = new AssemblyName("NLiteDynamicAssembly"); assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly( assemblyName, AssemblyBuilderAccess.RunAndSave ); moduleBuilder = assemblyBuilder.DefineDynamicModule( assemblyName.Name, assemblyName.Name + ".dll", true); Module = assemblyBuilder.GetModules().FirstOrDefault(); #else assemblyName = new AssemblyName("EmitMapperAssembly.SL"); assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly( assemblyName, AssemblyBuilderAccess.Run ); moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, true); #endif }
private static IEnumerable<ICommand> HandleModule(Module module) { IList<Type> types = module.GetTypes() .Where(t => t.IsPublic && !t.IsAbstract).ToList(); return types.Select(Activator.CreateInstance).OfType<ICommand>(); }
//Consrtucotr that is used when the initialization process finds //a Class type public YetiCsharpSpecificType(Type cl, Type basecl, string nm, Module mod) { this.c = cl; this.bas = basecl; this.typeName = nm; this.intrface = false; this.module = mod; }
// Token: 0x06002E87 RID: 11911 // RVA: 0x0012E4A4 File Offset: 0x0012C6A4 private void method_3(Module module_0) { byte[] array = this.byte_0; int i = 0; this.list_0 = new List<Class775>(); while (i < array.Length) { Class775 class = new Class775();
public Resolution Check(Module module, FieldInfo field) { if (!field.IsStatic && (field.IsPublic || field.IsAssembly)) { // FIXME: I18N return new Resolution (this, String.Format ("Make the field <code>{0}</code> in the type <code>{1}</code> private or protected. Provide a public or internal property if the field should be accessed from outside.", field.Name, field.DeclaringType.FullName), NamingUtilities.Combine (field.DeclaringType.FullName, field.Name)); } return null; }
public MethodBaseModuleContext(MethodBase method) { this.module = method.Module; this.methodGenericArguments = (method.IsGenericMethod || method.IsGenericMethodDefinition) ? method.GetGenericArguments() : new Type[0]; var type = method.DeclaringType; this.typeGenericArguments = (type != null && (type.IsGenericType || type.IsGenericTypeDefinition)) ? type.GetGenericArguments() : new Type[0]; }
public static IList<CustomAttributeData> GetCustomAttributes(Module target) { if (target == null) throw new ArgumentNullException("target"); Contract.EndContractBlock(); return target.GetCustomAttributesData(); }
internal static SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst) { SignatureHelper sigHelp = new SignatureHelper(scope, MdSigCallingConvention.GenericInst); sigHelp.AddData(inst.Length); foreach(Type t in inst) sigHelp.AddArgument(t); return sigHelp; }
internal NamespaceTreeNode(String n, Module m) : base() { _namespace = n; _module = m; _controlsOnly = false; PostConstructor(); }
internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); }
private Hashtable types; //Name -> Type mapping. To patch MS bug in ModuleBuilder #endregion Fields #region Constructors public MetaDataMapper(Module module, ResidualAssemblyHolder holder) { map = new Hashtable();; methodByMBB = new Hashtable(); types = new Hashtable(); specialCtors = new Set(); this.module = module; this.holder = holder; }
private Disassembler(MethodBase method, ILStyler styler) { this._module = method.DeclaringType.Module; this._styler = styler; if (method.GetMethodBody() != null) { this._il = method.GetMethodBody().GetILAsByteArray(); } }
public Resolution Check(Module module, ParameterInfo param) { if (param.Name != null && param.Name.IndexOf('_') >= 0) { string memberName = NamingUtilities.Combine(param.Member.DeclaringType.FullName, param.Member.Name); // FIXME: I18N return new Resolution (this, String.Format ("Remove all underscores in parameter <code>{0}</code> inside member <code>{1}</code>.", param.Name, memberName), memberName); } return null; }
public NaiveMethodNameExtractor(Delegate @delegate) { delegateMethod = @delegate.Method; body = delegateMethod.GetMethodBody(); Debug.Assert(body != null); module = delegateMethod.Module; stream = new MemoryStream(body.GetILAsByteArray()); Read(); }
private void PrintModule(System.Reflection.Module module) { Console.WriteLine(); Console.WriteLine("Name: " + module.FullyQualifiedName); Console.WriteLine("Types:"); foreach (var type in module.GetTypes()) { Console.Write(" " + type.FullName); } Console.WriteLine(); }
/// <summary> /// Get path to the execution assembly, which is the .exe started. /// </summary> /// <returns>Full qualified name (absolute) to the execution assembly, ending with a separator.</returns> public static string getApplicationPath() { System.Reflection.Module runningModule = Assembly.GetExecutingAssembly().GetModules()[0]; int len1 = runningModule.Name.Length; string path = runningModule.FullyQualifiedName; path = path.Remove((path.Length - len1), len1); if (!path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { path += System.IO.Path.DirectorySeparatorChar.ToString(); } return(path); }
/// <summary> /// Installs both or one of mouse and/or keyboard hooks and starts rasing events /// </summary> /// <param name="InstallMouseHook"><b>true</b> if mouse events must be monitored</param> /// <param name="InstallKeyboardHook"><b>true</b> if keyboard events must be monitored</param> /// <exception cref="Win32Exception">Any windows problem.</exception> public void Start(bool InstallMouseHook, bool InstallKeyboardHook) { // install Mouse hook only if it is not installed and must be installed if (hMouseHook == 0 && InstallMouseHook) { // Create an instance of HookProc. MouseHookProcedure = new HookProc(MouseHookProc); System.Reflection.Module abc = Assembly.GetExecutingAssembly().GetModules()[0]; IntPtr aaa = Marshal.GetHINSTANCE(abc); //install hook hMouseHook = SetWindowsHookEx( WH_MOUSE_LL, MouseHookProcedure, aaa, 0); //If SetWindowsHookEx fails. if (hMouseHook == 0) { //Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set. int errorCode = Marshal.GetLastWin32Error(); //do cleanup Stop(true, false, false); //Initializes and throws a new instance of the Win32Exception class with the specified error. throw new Win32Exception(errorCode); } } // install Keyboard hook only if it is not installed and must be installed if (hKeyboardHook == 0 && InstallKeyboardHook) { // Create an instance of HookProc. KeyboardHookProcedure = new HookProc(KeyboardHookProc); //install hook hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, KeyboardHookProcedure, Marshal.GetHINSTANCE( Assembly.GetExecutingAssembly().GetModules()[0]), 0); //If SetWindowsHookEx fails. if (hKeyboardHook == 0) { //Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set. int errorCode = Marshal.GetLastWin32Error(); //do cleanup Stop(false, true, false); //Initializes and throws a new instance of the Win32Exception class with the specified error. throw new Win32Exception(errorCode); } } }
/// <summary> /// /// </summary> /// <param name="module_"></param> private void FindDelegates(System.Reflection.Module module_) { if (module_ == null) { LogManager.Instance.WriteLine(LogVerbosity.Error, "ScriptManager.FindDelegates() : Module is null"); return; } try { Type mt = null; mt = module_.GetType("FlowSimulatorScriptManagerNamespace._MyInternalScript_" + ID); Type scriptDataColl = typeof(ScriptSlotDataCollection); Type boolType = typeof(bool); foreach (MethodInfo methInfo in mt.GetMethods()) { if (methInfo.ReturnParameter.ParameterType.Equals(boolType) == true && methInfo.GetParameters().Length == 2) { if (methInfo.GetParameters()[0].ParameterType.Equals(scriptDataColl) == true && methInfo.GetParameters()[1].ParameterType.FullName.Equals(scriptDataColl.FullName) == true) { try { m_ScriptDelegate = (ScriptEntryDelegate)Delegate.CreateDelegate( typeof(ScriptEntryDelegate), methInfo); } catch (System.Exception ex) { Exception newEx = new Exception("Try to create a OnMessageCreateDelegate with function " + methInfo.Name, ex); LogManager.Instance.WriteException(newEx); } } } } } catch (System.Exception ex) { LogManager.Instance.WriteException(ex); } }
private Module FindModule(NetModule netModule) { if (_modules == null) { LoadModules(); } foreach (Module module in _modules) { if (module.Internal == netModule) { return(module); } } throw new ApplicationException("Unable to find module."); }
private static void PerformSecurityCheck(System.Reflection.Module m, ref StackCrawlMark stackMark, bool skipVisibility) { RuntimeModule internalModule; if (m == null) { throw new ArgumentNullException("m"); } ModuleBuilder builder = m as ModuleBuilder; if (builder != null) { internalModule = builder.InternalModule; } else { internalModule = m as RuntimeModule; } if (internalModule == null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeModule"), "m"); } if (internalModule == s_anonymouslyHostedDynamicMethodsModule) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidValue"), "m"); } if (skipVisibility) { new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand(); } RuntimeType callerType = RuntimeMethodHandle.GetCallerType(ref stackMark); if (m.Assembly != callerType.Assembly) { CodeAccessSecurityEngine.ReflectionTargetDemandHelper(PermissionType.SecurityControlEvidence, m.Assembly.PermissionSet); } }
public static IEnumerable <Type> FindConcreteImplementationsWithin(this Type type, System.Reflection.Module module) { // Must be an interface. if (type.IsInterface) { return (from t in module.GetTypes() where !t.IsAbstract from i in t.GetInterfaces() where i.Name == type.Name select t); } return(Enumerable.Empty <Type>()); }
public bool IsCorlib(System.Reflection.Module module) { return(module.Name.StartsWith("mscorlib")); }
internal extern Type InternalGetType(Module module, String name, Boolean throwOnError, Boolean ignoreCase);
internal EnumBuilder(string name, Type underlyingType, TypeAttributes visibility, System.Reflection.Module module) { if ((visibility & ~TypeAttributes.NestedFamORAssem) != TypeAttributes.AnsiClass) { throw new ArgumentException(Environment.GetResourceString("Argument_ShouldOnlySetVisibilityFlags"), "name"); } this.m_typeBuilder = new TypeBuilder(name, visibility | TypeAttributes.Sealed, typeof(Enum), null, module, PackingSize.Unspecified, null); this.m_underlyingType = underlyingType; this.m_underlyingField = this.m_typeBuilder.DefineField("value__", underlyingType, FieldAttributes.RTSpecialName | FieldAttributes.SpecialName | FieldAttributes.Public); }
public static IntPtr ResolveToken(int token) { System.Reflection.Module module = typeof(CalliInj).Module; return(module.ResolveMethod(token).MethodHandle.GetFunctionPointer()); }
public static System.Guid GetModuleVersionId(this System.Reflection.Module module) { throw null; }
static extern int GetModuleToken(Module module);
public DynamicMethod(string name, System.Type returnType, System.Type[] parameterTypes, System.Reflection.Module m) { }
public DynamicMethod(string name, System.Type returnType, System.Type[] parameterTypes, System.Reflection.Module m, bool skipVisibility) { }
internal extern IntPtr GetManifestResourceInternal(String name, out int size, out Module module);
public DynamicMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] parameterTypes, System.Reflection.Module m, bool skipVisibility) { }
#pragma warning restore 169, 414 public ResourceCloseHandler(Module module) { this.module = module; }
public static Guid GetModuleVersionId(this Module module) { Requires.NotNull(module, nameof(module)); return(module.ModuleVersionId); }
private void Init(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, System.Reflection.Module m, bool skipVisibility, bool transparentMethod) { CheckConsistency(attributes, callingConvention); if (signature != null) { this.m_parameterTypes = new RuntimeType[signature.Length]; for (int i = 0; i < signature.Length; i++) { if (signature[i] == null) { throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); } this.m_parameterTypes[i] = signature[i].UnderlyingSystemType as RuntimeType; if (((this.m_parameterTypes[i] == null) || !this.m_parameterTypes[i].IsRuntimeType) || (this.m_parameterTypes[i] == typeof(void))) { throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); } } } else { this.m_parameterTypes = new RuntimeType[0]; } this.m_returnType = (returnType == null) ? ((RuntimeType)typeof(void)) : (returnType.UnderlyingSystemType as RuntimeType); if (((this.m_returnType == null) || !this.m_returnType.IsRuntimeType) || this.m_returnType.IsByRef) { throw new NotSupportedException(Environment.GetResourceString("Arg_InvalidTypeInRetType")); } if (transparentMethod) { this.m_module = GetDynamicMethodsModule(); if (skipVisibility) { this.m_restrictedSkipVisibility = true; this.m_creationContext = CompressedStack.Capture(); } } else { if (m != null) { this.m_module = m.ModuleHandle.GetRuntimeModule(); } else if (((owner != null) && (owner.UnderlyingSystemType != null)) && owner.UnderlyingSystemType.IsRuntimeType) { this.m_typeOwner = owner.UnderlyingSystemType.TypeHandle.GetRuntimeType(); if ((this.m_typeOwner.HasElementType || this.m_typeOwner.ContainsGenericParameters) || (this.m_typeOwner.IsGenericParameter || this.m_typeOwner.IsInterface)) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForDynamicMethod")); } this.m_module = (RuntimeModule)this.m_typeOwner.Module; } this.m_skipVisibility = skipVisibility; } this.m_ilGenerator = null; this.m_fInitLocals = true; this.m_methodHandle = null; if (name == null) { throw new ArgumentNullException("name"); } this.m_dynMethod = new RTDynamicMethod(this, name, attributes, callingConvention); }
public void OnClose(object sender, EventArgs e) { // The module dtor will take care of things module = null; }
#pragma warning restore public unsafe UnmanagedMemoryStreamForModule(byte *pointer, long length, Module module) : base(pointer, length) { this.module = module; }
public static System.Collections.Generic.IList <System.Reflection.CustomAttributeData> GetCustomAttributes(System.Reflection.Module target) { throw null; }
public static bool HasModuleVersionId(this System.Reflection.Module module) { throw null; }
static extern IntPtr GetModuleModule(Module module);
public static bool HasModuleVersionId(this Module module) { Requires.NotNull(module, nameof(module)); return(true); // not expected to fail on platforms with Module.ModuleVersionId built-in. }