当前位置: 首页>>代码示例>>C#>>正文


C# Assembly.GetModules方法代码示例

本文整理汇总了C#中System.Reflection.Assembly.GetModules方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetModules方法的具体用法?C# Assembly.GetModules怎么用?C# Assembly.GetModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Assembly的用法示例。


在下文中一共展示了Assembly.GetModules方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAsseblyMetadata

        private static MetadataTables[] GetAsseblyMetadata(Assembly assembly)
        {
            if (_metadataCache == null) {
                _metadataCache = new Dictionary<Assembly, MetadataTables[]>();
            }

            lock (_metadataCache) {
                MetadataTables[] metadata;
                if (!_metadataCache.TryGetValue(assembly, out metadata)) {
                    var modules = assembly.GetModules(false);
                    metadata = new MetadataTables[modules.Length];
                    int i = 1;
                    foreach (var module in modules) {
                        var tables = MetadataTables.OpenModule(module);
                        if (tables.AssemblyDef.Record.IsNull) {
                            metadata[i++] = MetadataTables.OpenModule(module);
                        } else {
                            metadata[0] = tables;
                        }
                    }

                    _metadataCache.Add(assembly, metadata);
                }
                return metadata;
            }
        }
开发者ID:TerabyteX,项目名称:main,代码行数:26,代码来源:MetadataServices.cs

示例2: OnAssemblyLoaded

 internal void OnAssemblyLoaded(Assembly assembly)
 {
     foreach (var module in assembly.GetModules()) {
         NamespaceTree tree = new NamespaceTree();
         tree.Add(module.GetMetadataTables());
         ObjectModule.AddClrModules(tree.Root);
     }
 }
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:RubyModules.cs

示例3: ImportAssembly

 public void ImportAssembly(Assembly assembly)
 {
     var module = assembly.GetModules();
     foreach (var m in module)
     {
         ImportModule(m);
     }
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:8,代码来源:CilImport.cs

示例4: RegisterAssembly

 public static void RegisterAssembly(Assembly assembly)
 {
     if (assembly == null)
         throw new ArgumentNullException("assembly");
     foreach (Module module in assembly.GetModules())
     {
         RegisterModule(module);
     }
 }
开发者ID:VenoMpie,项目名称:DoomSharp,代码行数:9,代码来源:Registrar.cs

示例5: LoadInstallInfosFromAssembly

 /// <summary>
 /// 加载服务安装信息
 /// </summary>
 /// <param name="assembly"></param>
 /// <returns></returns>
 public ServiceInstallInfoListModel LoadInstallInfosFromAssembly(Assembly assembly)
 {
     ServiceInstallInfoListModel retVal = new ServiceInstallInfoListModel();
     List<Module> moduleList = new List<Module>(assembly.GetModules());
     List<ServiceInstaller> serviceInstallerList;
     List<ServiceProcessInstaller> serviceProcessInstallerList;
     this.LoadInstallInfosFromModuleList(moduleList, out serviceInstallerList, out serviceProcessInstallerList);
     List<ServiceInstallInfo> installInfoList = this.GetInstallInfoList(assembly, serviceInstallerList, serviceProcessInstallerList);
     retVal.ServiceInstallInfos = installInfoList.ToArray();
     return retVal;
 }
开发者ID:aaasoft,项目名称:Quick.OwinMVC,代码行数:16,代码来源:DotNetServiceInstaller.cs

示例6: LoadCommands

        private static IEnumerable<ICommand> LoadCommands(Assembly assembly)
        {
            List<ICommand> retVal = new List<ICommand>(5);

            Module[] modules = assembly.GetModules(false);
            foreach (Module module in modules)
            {
                retVal.AddRange(HandleModule(module));
            }

            return retVal;
        }
开发者ID:SneWs,项目名称:Commander,代码行数:12,代码来源:CommandLoader.cs

示例7: CheckAssembly

        private static void CheckAssembly(Assembly asm)
        {
            _checkedAssemblies.Add(asm.FullName);

            if (_isVerbose)
            {
                WriteLine(ConsoleColor.Cyan, "Checking assembly: " + asm.FullName);
            }

            try
            {
                foreach (var module in asm.GetModules())
                {
                    if (_isVerbose)
                    {
                        Console.WriteLine("\t" + module.ToString());
                    }

                    foreach (var type in module.GetTypes())
                    {
                        if (_isVerbose)
                        {
                            Console.WriteLine("\t\t" + type.ToString());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                WriteException(asm.FullName, exception);
                throw;
            }

            foreach (var name in asm.GetReferencedAssemblies())
            {
                if (!_checkedAssemblies.Contains(name.FullName))
                {
                    Assembly assembly = null;
                    try
                    {
                        assembly = Assembly.Load(name.FullName);
                    }
                    catch (Exception exception2)
                    {
                        WriteException((assembly == null) ? name.FullName : assembly.FullName, exception2);
                        throw;
                    }
                    CheckAssembly(assembly);
                }
            }
        }
开发者ID:diegofrata,项目名称:asmchecker,代码行数:51,代码来源:Program.cs

示例8: GetStaticExecuteMethod

        /// <summary>
        /// 得到所给汇编中所有具有<see cref="ExecuteAttribute"/>特性的静态方法
        /// </summary>
        public static List<MethodInfo> GetStaticExecuteMethod(Assembly assembly)
        {
            var ret = new List<MethodInfo>();

            foreach (Module module in assembly.GetModules())
            {
                foreach (Type type in module.GetTypes())
                {
                    ret.AddRange(GetStaticExecuteMethod(type));
                }
            }

            return ret;
        }
开发者ID:hitomi333,项目名称:eddyserver,代码行数:17,代码来源:ExecuteAttribute.cs

示例9: RegisterCommands

 public static void RegisterCommands(Assembly assembly)
 {
     lock(commands_)
     {
         foreach(Module module in assembly.GetModules())
         {
             foreach(Type command in module.FindTypes(TpmCommandFilter, null))
             {
                 TPMCommandsAttribute pattr = (TPMCommandsAttribute)Attribute.GetCustomAttribute(command, typeof(TPMCommandsAttribute));
                 if(!commands_.Keys.Contains(pattr.CommandName))
                     commands_.Add(pattr.CommandName, command);
             }
         }
     }
 }
开发者ID:deveck,项目名称:doTSS,代码行数:15,代码来源:TPMCommandFactory.cs

示例10: AnalyzeAssembly

 public static void AnalyzeAssembly(Assembly assembly)
 {
     Console.WriteLine("程序集名称:" + assembly.FullName);
     Console.WriteLine("程序集位置:" + assembly.Location);
     Console.WriteLine("程序集是否在GAC中:" + assembly.GlobalAssemblyCache.ToString());
     Console.WriteLine("包含程序集的模块名" +
         assembly.ManifestModule.Name);
     Console.WriteLine("运行程序集需要的CLR版本:" +
         assembly.ImageRuntimeVersion);
     Console.WriteLine("现在开始分析程序集中的模块");
     Module[] modules = assembly.GetModules();
     foreach (Module module in modules)
     {
         AnalyzeModule(module);
     }
 }
开发者ID:Iamnvincible,项目名称:csharppractice,代码行数:16,代码来源:AnalyseHelper.cs

示例11: ExploreAssembly

 private static void ExploreAssembly(Assembly assembly)
 {
     Console.WriteLine("Modules in the assembly:");
     foreach (Module module in assembly.GetModules())
     {
         Console.WriteLine("{0}", module);
         foreach (Type type in module.GetTypes())
         {
             Console.WriteLine("t{0}", type.Name);
             foreach (MethodInfo info in type.GetMethods())
             {
                 Console.WriteLine("tt{0}", info.Name);
             }
         }
     }
 }
开发者ID:JimmieOverby,项目名称:IndexViewer,代码行数:16,代码来源:Compiler.cs

示例12: AddAssemblyToView

 private void AddAssemblyToView(Assembly a)
 {
     if (a != null)
     {
         PlugTemplateDumper.Dump(a);
         try
         {
             TreeNode nd = new AssemblyTreeNode(a);
             treeView1.Nodes.Add(nd);
             foreach (Module md in a.GetModules())
             {
                 LoadModule(nd, md);
             }
             treeView1.Sort();
         }
         catch {}
     }
 }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:18,代码来源:MainForm.cs

示例13: ResolveModule

        public static Module ResolveModule(Assembly assembly, int metadataToken)
        {
            Assumes.NotNull(assembly);
            Assumes.IsTrue(metadataToken != 0);

            // TODO: This likely cause all modules in the assembly to be loaded
            // perhaps we should load via file name (how will that work on SL)?
            foreach (Module module in assembly.GetModules())
            {
                if (module.MetadataToken == metadataToken)
                {
                    return module;
                }
            }

            Assumes.Fail("");
            return null;
        }
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:18,代码来源:ReflectionResolver.cs

示例14: Reflect

        /// <summary>
        /// Reflect informormation about assembly
        /// </summary>
        /// <param name="asm">Current assembly</param>
        /// <returns>Information about current assembly</returns>
        public static string Reflect(Assembly asm)
        {
            string res = "";
            foreach (Module m in asm.GetModules())
            {
                res += String.Format("{0}:\n", m.Name);
                foreach (Type t in m.GetTypes())
                {
                    string mods = "";
                    if (t.IsPublic) mods += "public ";
                    else if (t.IsNotPublic) mods += "private ";
                    else mods += "internal ";
                    if (t.IsSealed) mods += "sealed ";
                    if (t.IsAbstract && !t.IsInterface) mods += "abstract ";
                    if (t.IsClass) mods += "class ";
                    if (t.IsEnum) mods += "enum ";
                    if (t.IsInterface) mods += "interface ";
                    res += String.Format("\n{0}{1}\n", mods, t.Name);

                    bool hasMethods = false;
                    foreach (MethodInfo mi in t.GetMethods())
                        if (mi.DeclaringType == t)
                        {
                            hasMethods = true;
                            string n = mi.Name;
                            string mmods = "";
                            if (mi.IsPublic) mmods += "public ";
                            if (mi.IsPrivate) mmods += "private ";
                            if (mi.IsConstructor) mmods += "constructor ";
                            if (mi.IsGenericMethod) n += "<>";
                            if (mi.IsStatic) mmods += "static ";
                            if (mi.IsVirtual) mmods += "virtual ";
                            List<string> prms = new List<string>();
                            foreach (ParameterInfo pi in mi.GetParameters())
                                prms.Add(pi.ParameterType.Name);
                            res += String.Format("\t{0}{1} {2}({3})\n", mmods, mi.ReturnType.Name, n, string.Join(", ", prms));
                        }
                    if (hasMethods)
                        res += "\n";
                }
            }
            res += "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
            return res;
        }
开发者ID:alexssource,项目名称:Labs,代码行数:49,代码来源:Reflection.cs

示例15: LoadAssembly

 static public void LoadAssembly()
 {
     try
     {
         if (asm == null)
         {
             try
             {
                 asm = Assembly.LoadWithPartialName("Npgsql");
                 Module[] mods = asm.GetModules(false);
                 mod = mods[0];
             }
             catch
             {
                 throw new Exception("Make sure the Npgsql.dll is registered in the Gac or is located in the MyGeneration folder.");
             }
         }
     }
     catch { }
 }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:20,代码来源:Databases.cs


注:本文中的System.Reflection.Assembly.GetModules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。