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


C# Assembly.GetModules方法代码示例

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


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

示例1: AssemblyLoader

			internal AssemblyLoader(Assembly assembly)
			{
				this.assembly = assembly;
				modules = assembly.GetModules(false);
				isJavaModule = new bool[modules.Length];
				for (int i = 0; i < modules.Length; i++)
				{
					object[] attr = AttributeHelper.GetJavaModuleAttributes(modules[i]);
					if (attr.Length > 0)
					{
						isJavaModule[i] = true;
						foreach (JavaModuleAttribute jma in attr)
						{
							string[] map = jma.GetClassMap();
							if (map != null)
							{
								if (nameMap == null)
								{
									nameMap = new Dictionary<string, string>();
								}
								for (int j = 0; j < map.Length; j += 2)
								{
									string key = map[j];
									string val = map[j + 1];
									// TODO if there is a name clash between modules, this will throw.
									// Figure out how to handle that.
									nameMap.Add(key, val);
								}
							}
							string[] jars = jma.Jars;
							if (jars != null)
							{
								if (jarList == null)
								{
									jarList = jars;
								}
								else
								{
									string[] newList = new string[jarList.Length + jars.Length];
									Array.Copy(jarList, newList, jarList.Length);
									Array.Copy(jars, 0, newList, jarList.Length, jars.Length);
									jarList = newList;
								}
							}
						}
					}
					else
					{
						hasDotNetModule = true;
					}
				}
			}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:52,代码来源:AssemblyClassLoader.cs

示例2: AssemblyLoader

			internal AssemblyLoader(Assembly assembly)
			{
				this.assembly = assembly;
				modules = assembly.GetModules(false);
				isJavaModule = new bool[modules.Length];
				for (int i = 0; i < modules.Length; i++)
				{
					object[] attr;
					try
					{
						attr = AttributeHelper.GetJavaModuleAttributes(modules[i]);
					}
					catch (Exception x)
					{
						// HACK we handle exceptions here, because there is at least one obfuscator that produces
						// invalid assemblies that cause Module.GetCustomAttributes() to throw an exception
						JVM.CriticalFailure("Unexpected exception", x);
						throw null;
					}
					if (attr.Length > 0)
					{
						isJavaModule[i] = true;
						foreach (JavaModuleAttribute jma in attr)
						{
							string[] map = jma.GetClassMap();
							if (map != null)
							{
								if (nameMap == null)
								{
									nameMap = new Dictionary<string, string>();
								}
								for (int j = 0; j < map.Length; j += 2)
								{
									string key = map[j];
									string val = map[j + 1];
									// TODO if there is a name clash between modules, this will throw.
									// Figure out how to handle that.
									nameMap.Add(key, val);
								}
							}
						}
					}
					else
					{
						hasDotNetModule = true;
					}
				}
			}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:48,代码来源:AssemblyClassLoader.cs

示例3: Print

 static void Print(Assembly assembly)
 {
     Console.WriteLine("Assembly: "+assembly.FullName+"/"+assembly.GetName());
     foreach (string s in assembly.GetManifestResourceNames())
     {
         Console.WriteLine("Resource: "+s);
     }
     foreach (AssemblyName a in assembly.GetReferencedAssemblies())
     {
         Console.WriteLine("ReferencedAssembly: "+a.Name);
     }
     foreach (Module m in assembly.GetModules())
     {
         Console.WriteLine("Module: "+m);
         foreach (Type t in m.GetTypes())
         {
             Console.WriteLine("Type: "+t);
             foreach (MemberInfo mi in t.GetMembers())
             {
                 Console.WriteLine(String.Format("\t{0}: {1} ", mi.MemberType, mi.Name));
             }
         }
     }
 }
开发者ID:Diullei,项目名称:Storm,代码行数:24,代码来源:reflect.cs

示例4: GetModules

 public static Module[] GetModules(Assembly assembly)
 {
     Requires.NotNull(assembly, "assembly");
     return assembly.GetModules();
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例5: PrintAssembly

    void PrintAssembly(Assembly asm)
    {
        // assembly name
        AssemblyName[] asms = asm.GetReferencedAssemblies();

        // Pre-Load the referenced assemblies first
        // user can specify customerized reference through /asmpath option

        foreach (AssemblyName a in asms)
        {
            if (TryLoadAssembly(a) == null)
            {
                throw new ApplicationException("Fail to Find " + a.Name);
            }
        }
        Console.WriteLine("Loaded Assemblies");
        Assembly[] asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
        foreach (Assembly assembly in asmss)
            Console.WriteLine(assembly);

        Array.Sort(asms, sc);
        foreach (AssemblyName a in asms)
            PrintAssemblyName(null, a, true);
        PrintAssemblyName(asm, asm.GetName(), false);
        // module
        Module amod = asm.ManifestModule;
        Module[] mods = asm.GetModules(true);
        Array.Sort(mods, sc);
        foreach (Module mod in mods)
        {
            if (!mod.Name.Equals(amod.Name))
                sw.WriteLine(".module manifest " + mod.Name);
            else if (!mod.IsResource())
                sw.WriteLine(".module " + mod.Name);
            else sw.WriteLine(".resource " + mod.Name);
            PrintCustomAttributes(CustomAttributeData.GetCustomAttributes(mod));

        }
        // file
        FileStream[] files = asm.GetFiles();
        Array.Sort(files, sc);
        foreach (FileStream file in files)
            sw.WriteLine(".file " + Path.GetFileName(file.Name)); // TODO seems the file api has provided less than CLI such as hashcode
        // .subsystem (Console or UI)We cannot get it from reflection
        // .corflags ( 64, 32 or IL platforms)
        PortableExecutableKinds PEKind = (PortableExecutableKinds)0;
        ImageFileMachine Machine = (ImageFileMachine)0;
        asm.ManifestModule.GetPEKind(out PEKind, out Machine);
        sw.WriteLine(".pekind " + PEKind);
        sw.WriteLine(".imageMachine " + Machine);
        // .class
        Type[] ts = amod.GetTypes();
        Array.Sort(ts, sc);
        foreach (Type t in ts)
            PrintType(t, false);
        // .field and .method (only the manifest module ... )
        FieldInfo[] fis = amod.GetFields(bf);
        Array.Sort(fis, sc);
        foreach (FieldInfo fi in fis) // global fields
            PrintField(fi);
        MethodInfo[] mis = amod.GetMethods(bf);
        Array.Sort(mis, sc);
        foreach (MethodInfo mi in mis) // global methods
            PrintMethod(mi);

        Console.WriteLine("Loaded Assemblies");
        asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
        foreach (Assembly assembly in asmss)
            Console.WriteLine(assembly);
    }
开发者ID:dbremner,项目名称:clrinterop,代码行数:70,代码来源:AssemPrinter.cs


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