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


C# Assembly.GetTypes方法代码示例

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


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

示例1: DumpAsm

    static void DumpAsm(Assembly asm)
    {
        Dictionary<string,Namespace> nss = new Dictionary<string,Namespace>();

        Console.WriteLine("using System;");
        Console.WriteLine("using System.Collections;");
        Console.WriteLine("using System.Collections.Generic;");
        Console.WriteLine("");

        foreach(var t in asm.GetTypes())
        {
            if(!t.IsVisible || t.IsNested)
            {
                continue;
            }

            if(!nss.ContainsKey(t.Namespace))
            {
                nss[t.Namespace] = new Namespace(t.Namespace);
            }
            nss[t.Namespace].Add(t);
        }

        foreach(Namespace ns in nss.Values)
        {
            ns.Dump();
        }
    }
开发者ID:makiuchi-d,项目名称:mono-dump,代码行数:28,代码来源:Main.cs

示例2: ExecuteInstanceMethod

 /// <summary>
 /// Execute a public method_name(args) in compiled_assembly
 /// </summary>
 /// <param name="compiled_assembly">compiled assembly</param>
 /// <param name="methode_name">method to execute</param>
 /// <param name="args">method arguments</param>
 /// <returns>method execution result</returns>
 public static object ExecuteInstanceMethod(Assembly compiled_assembly, string methode_name, object[] args)
 {
     if (compiled_assembly != null)
     {
         foreach (Type type in compiled_assembly.GetTypes())
         {
             foreach (MethodInfo method in type.GetMethods())
             {
                 if (method.Name == methode_name)
                 {
                     if ((method != null) && (method.IsPublic))
                     {
                         object obj = Activator.CreateInstance(type, null);
                         return method.Invoke(obj, args);
                     }
                     else
                     {
                         throw new Exception("Cannot invoke method :" + methode_name);
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:ATouhou,项目名称:QuranCode,代码行数:32,代码来源:ScriptRunner.cs

示例3: ProcessAssembly

    private static void ProcessAssembly(TreeIter parent, Assembly asm)
    {
        string asm_name = asm.GetName ().Name;

        foreach (System.Type t in asm.GetTypes ()) {
            UpdateDialog ("Loading from {0}:\n{1}", asm_name, t.ToString ());
            TreeIter iter = store.AppendValues (parent, t.Name, t.ToString ());
            ProcessType (iter, t);
        }
    }
开发者ID:numerodix,项目名称:nametrans,代码行数:10,代码来源:TreeViewDemo.cs

示例4: GetTypes

 static Type[] GetTypes(Assembly assembly)
 {
     try
     {
         return assembly.GetTypes();
     }
     catch (ReflectionTypeLoadException ex)
     {
         return ex.Types;
     }
 }
开发者ID:kobake,项目名称:unity-index,代码行数:11,代码来源:Program.cs

示例5: GetClassesForPredicate

 /// <summary>
 /// Returns all types in the given assembly satisfying the given predicate,
 /// </summary>
 private static List<Type> GetClassesForPredicate(Assembly assembly, Predicate<Type> predicate)
 {
     List<Type> result = new List<Type>();
     foreach (Type t in assembly.GetTypes())
     {
         if (predicate.Invoke(t))
         {
             result.Add(t);
         }
     }
     return result;
 }
开发者ID:nickgirardo,项目名称:KADAPT,代码行数:15,代码来源:ReflectionUtil.cs

示例6: GetTypesFromAssembly

	Type[] GetTypesFromAssembly(Assembly Asm)
	{
		Type[] AllTypesWeCanGet;
		try
		{
			AllTypesWeCanGet = Asm.GetTypes();
		}
		catch(ReflectionTypeLoadException Exc)
		{
			AllTypesWeCanGet = Exc.Types;
		}
		return AllTypesWeCanGet;
	}
开发者ID:unrealengine47,项目名称:UnrealEngine4,代码行数:13,代码来源:LegacyBranchSetup.cs

示例7: DisplayInfo

    private static void DisplayInfo(Assembly a)
    {
        Console.WriteLine("****** Info about Assembly ******");
        Console.WriteLine("Loaded from GAC? {0}", a.GlobalAssemblyCache);
        Console.WriteLine("Asm Name: {0}", a.GetName().Name);
        Console.WriteLine("Asm Version: {0}", a.GetName().Version);
        Console.WriteLine("Asm Culture: {0}", a.GetName().CultureInfo.DisplayName);
        Console.WriteLine("\nHere are the public enums:");

        // use LINQ to find public enums
        Type[] types = a.GetTypes();
        var publicEnums = from pe in types where pe.IsEnum &&
                               pe.IsPublic select pe;

        foreach (var pe in publicEnums) {
            Console.WriteLine(pe);
        }
    }
开发者ID:walrus7521,项目名称:code,代码行数:18,代码来源:SharedAsmReflector.cs

示例8: GetTypes

	static int GetTypes (Assembly a)
	{
		try {
			Type[] ts = a.GetTypes ();
			Console.WriteLine ("*1* Can get all types from assembly '{0}' loaded. {1} types present.", filename, ts.Length);
			return 1;
		}
		catch (ReflectionTypeLoadException rtle) {
			Console.WriteLine ("*0* Expected ReflectionTypeLoadException\n{0}", rtle);
			Console.WriteLine ("Types ({0}):", rtle.Types.Length);
			for (int i=0; i < rtle.Types.Length; i++) {
				Console.WriteLine ("\t{0}", rtle.Types [i]);
			}
			Console.WriteLine ("LoaderExceptions ({0}):", rtle.LoaderExceptions.Length);
			for (int i=0; i < rtle.LoaderExceptions.Length; i++) {
				Console.WriteLine ("\t{0}", rtle.LoaderExceptions [i]);
			}
			return 0;
		}
	}
开发者ID:nobled,项目名称:mono,代码行数:20,代码来源:reftype3.cs

示例9: GetSpecificationTypes

        private static IEnumerable<Type> GetSpecificationTypes(Assembly assembly, string example, out bool foundType)
        {
            var exampleTypes = from exampleText in example.SomeStringOrNone()
                               from assemblyValue in assembly.SomeOrNone()
                               from exampleType in assemblyValue.GetType(exampleText).SomeOrNone()
                               where exampleType.IsSubclassOf(typeof (Specification))
                               select exampleType;
            foreach (var exampleType in exampleTypes)
            {
                foundType = true;
                return new[] {exampleType};
            }

            foundType = false;

            try {
                return from type in assembly.GetTypes() where type.IsSubclassOf(typeof(Specification)) select type;
            } catch {
                return Enumerable.Empty<Type>();
            }
        }
开发者ID:alexfalkowski,项目名称:System.Spec,代码行数:21,代码来源:DefaultSpecificationFinder.cs

示例10: GetTypes

	static int GetTypes (Assembly a)
	{
		Type[] ts = a.GetTypes ();
		Console.WriteLine ("*0* Can get all types from assembly '{0}' loaded. {1} types present.", filename, ts.Length);
		return 0;
	}
开发者ID:nobled,项目名称:mono,代码行数:6,代码来源:reftype4.cs

示例11: AssemblyGen

	static void AssemblyGen (Assembly a)
	{
		Type[] types = a.GetTypes ();
		Hashtable ns_types = new Hashtable ();

		foreach (Type t in types) {
			if (t.IsNotPublic) {
				//Console.WriteLine ("Ignoring non-public type: " + t.Name);
				//warnings_ignored++;
				continue;
			}

			if (!t.IsClass && !t.IsInterface && !t.IsEnum) {
				//Console.WriteLine ("Ignoring unrecognised type: " + t.Name);
				warnings_ignored++;
				continue;
			}

			RegisterType (t);

			if (t.IsEnum)
				RegisterByVal (t);

			string tns = t.Namespace == null ? String.Empty : t.Namespace;

			if (!ns_types.Contains (tns))
				ns_types[tns] = new ArrayList ();

			((ArrayList) ns_types[tns]).Add (t);
		}

		namespaces = (string[]) (new ArrayList (ns_types.Keys)).ToArray (typeof (string));

		foreach (DictionaryEntry de in ns_types)
			NamespaceGen ((string) de.Key, (Type[]) ((ArrayList) de.Value).ToArray (typeof (Type)));
	}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:36,代码来源:cilc.cs

示例12: OutputAllTypesInAssembly

    public static void OutputAllTypesInAssembly(Assembly asm)
    {
        var alltypes = asm.GetTypes();
        var writer = new StreamWriter(tempFile, false, Encoding.UTF8);

        writer.WriteLine("// enum");
        writer.WriteLine("");
        for (int i = 0; i < alltypes.Length; i++)
        {
            if (!alltypes[i].IsPublic && !alltypes[i].IsNestedPublic)
                continue;

            if (alltypes[i].IsEnum)
                writer.WriteLine(alltypes[i].ToString());
        }

        writer.WriteLine("");
        writer.WriteLine("// interface");
        writer.WriteLine("");

        for (int i = 0; i < alltypes.Length; i++)
        {
            if (!alltypes[i].IsPublic && !alltypes[i].IsNestedPublic)
                continue;

            if (alltypes[i].IsInterface)
                writer.WriteLine(alltypes[i].ToString());
        }

        writer.WriteLine("");
        writer.WriteLine("// class");
        writer.WriteLine("");

        for (int i = 0; i < alltypes.Length; i++)
        {
            if (!alltypes[i].IsPublic && !alltypes[i].IsNestedPublic)
                continue;

            if ((!alltypes[i].IsEnum && !alltypes[i].IsInterface) &&
                alltypes[i].IsClass)
            {
                string s = alltypes[i].GetConstructors().Length.ToString()
                    + "/" +
                    alltypes[i].GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Length.ToString();

                writer.WriteLine(alltypes[i].ToString() + " " + s);
            }
        }

        writer.WriteLine("");
        writer.WriteLine("// ValueType");
        writer.WriteLine("");

        for (int i = 0; i < alltypes.Length; i++)
        {
            if (!alltypes[i].IsPublic && !alltypes[i].IsNestedPublic)
                continue;

            if ((!alltypes[i].IsEnum && !alltypes[i].IsInterface) &&
                !alltypes[i].IsClass && alltypes[i].IsValueType)
                writer.WriteLine(alltypes[i].ToString());
        }

        writer.Close();

        Debug.Log("Output All Types in UnityEngine finish, file: " + tempFile);
        return;
    }
开发者ID:shuidong,项目名称:qjsbunitynew,代码行数:68,代码来源:CSGenerator.cs

示例13: ListAssemblyInfo

 // private void ListAssemblyInfo(Assembly assembly) {{{2
 private void ListAssemblyInfo(Assembly assembly)
 {
     Info.AppendFormat("Assembly: {0}\n", assembly.FullName); // Assembly name
     // Various statistics about the assembly
     if (OAAssemblyStats || OTAll) {
         Info.AppendFormat("\tLoaded from GAC: {0}\n", assembly.GlobalAssemblyCache);
         Info.AppendFormat("\tAsm Name: {0}\n", assembly.GetName().Name);
         Info.AppendFormat("\tAsm Version: {0}\n", assembly.GetName().Version);
         Info.AppendFormat("\tAsm Culture: {0}\n", assembly.GetName().CultureInfo.DisplayName);
     }
     if (OAListTypes) {
         Type[] types = assembly.GetTypes();
         foreach (Type type in types)
             ListTypeInfo(type);
     }
 }
开发者ID:viaa,项目名称:ObjectBrowser,代码行数:17,代码来源:ObjectBrowser.cs

示例14: GetTypes

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

示例15: PrintAssembly

 private static void PrintAssembly(Assembly ass)
 {
     Type[] types = ass.GetTypes();
     outfile.WriteLine("# This file has been autogenerated by query.exe -- DO NOT EDIT");
     outfile.WriteLine("from pypy.translator.cli.query import ClassDesc");
     outfile.WriteLine("types = {}");
     foreach(Type t in types) {
         if (IgnoreType(t))
             continue;
         PrintType(t);
         outfile.WriteLine("types['{0}'] = desc", t.FullName);
         outfile.WriteLine("del desc");
     }
 }
开发者ID:harisasank,项目名称:pypy,代码行数:14,代码来源:query.cs


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