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


C# System.GetTypes方法代码示例

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


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

示例1: Execute

        public Type[] Execute(System.Reflection.Assembly assembly)
        {
            var targetNamespaces = new HashSet<string>();
            var resourceNames = assembly.GetManifestResourceNames().Where(n => n.EndsWith("VenusIoc.config"));
            foreach (var resourceName in resourceNames)
            {
                var xmlDoc = new XmlDocument();
                using (var sr = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
                {
                    xmlDoc.Load(sr);
                    foreach (var node in xmlDoc.DocumentElement.SelectNodes("components/assemblyScan/namespace"))
                    {
                        var name = ((XmlElement)node).GetAttribute("name");
                        if (!string.IsNullOrWhiteSpace(name))
                        {
                            targetNamespaces.Add(name.Trim());
                        }
                    }
                }
            }

            var types = new List<Type>();
            foreach (var type in assembly.GetTypes())
            {
                if (targetNamespaces.Contains(type.Namespace) && !type.IsAbstract && type.IsDefined(typeof(NamedAttribute), false))
                {
                    types.Add(type);
                }
            }

            return types.ToArray();
        }
开发者ID:felix-tien,项目名称:TechLab,代码行数:32,代码来源:NamedTypeExtractor.cs

示例2: FindTasksAndConditionsInAssembly

        internal static void FindTasksAndConditionsInAssembly(System.Reflection.Assembly assembly,
			Dictionary<string, Type> updateTasks, Dictionary<string, Type> updateConditions)
        {
            foreach (Type t in assembly.GetTypes())
            {
                if (typeof(IUpdateTask).IsAssignableFrom(t))
                {
                    updateTasks.Add(t.Name, t);
                    UpdateTaskAliasAttribute[] tasksAliases = (UpdateTaskAliasAttribute[])t.GetCustomAttributes(typeof(UpdateTaskAliasAttribute), false);
                    foreach (UpdateTaskAliasAttribute alias in tasksAliases)
                    {
                        updateTasks.Add(alias.Alias, t);
                    }
                }
                else if (typeof(IUpdateCondition).IsAssignableFrom(t))
                {
                    updateConditions.Add(t.Name, t);
                    UpdateConditionAliasAttribute[] tasksAliases = (UpdateConditionAliasAttribute[])t.GetCustomAttributes(typeof(UpdateConditionAliasAttribute), false);
                    foreach (UpdateConditionAliasAttribute alias in tasksAliases)
                    {
                        updateConditions.Add(alias.Alias, t);
                    }
                }
            }
        }
开发者ID:robinwassen,项目名称:NAppUpdate2,代码行数:25,代码来源:Reflection.cs

示例3: GetTypesAssignableFrom

 public static IEnumerable<Type> GetTypesAssignableFrom(System.Reflection.Assembly assemb, System.Type rootType)
 {
     foreach (var tp in assemb.GetTypes())
     {
         if (rootType.IsAssignableFrom(tp) && rootType != tp) yield return tp;
     }
 }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:7,代码来源:TypeUtil.cs

示例4: AddAssembly

        public void AddAssembly( System.Reflection.Assembly assembly )
        {
            Details details = new Details();

            details.Assembly = assembly;

            foreach( Type type in assembly.GetTypes() )
            {
                List<Type> types;

                if( details.TypeMap.ContainsKey( type.Name ) )
                {
                    types = details.TypeMap[type.Name];
                }
                else
                {
                    types = new List<Type>();
                    details.TypeMap[type.Name] = types;
                }

                types.Add( type );
            }

            _details.Add( details );
        }
开发者ID:CecleCW,项目名称:ProductMan,代码行数:25,代码来源:TypeIndex.cs

示例5: GetAllPlayerActions

        public static PlayerAction[] GetAllPlayerActions(System.Reflection.Assembly assembly)
        {
            var result = new List<PlayerAction>();

            foreach (Type innerType in assembly.GetTypes())
            {
                if (!innerType.IsClass)
                    continue;

                if (innerType.Namespace != "Strategies")
                    continue;

                System.Reflection.MethodInfo playerMethodInfo = innerType.GetMethod("Player", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                if (playerMethodInfo == null)
                    continue;

                if (playerMethodInfo.ContainsGenericParameters)
                    continue;

                if (playerMethodInfo.GetParameters().Length > 0)
                {
                    continue;
                }

                PlayerAction playerAction = playerMethodInfo.Invoke(null, new object[0]) as PlayerAction;
                if (playerAction == null)
                    continue;

                result.Add(playerAction);
            }

            return result.ToArray();
        }
开发者ID:NathanTeeuwen,项目名称:Dominulator,代码行数:33,代码来源:BuiltInStrategyLoader.cs

示例6: Start

        public bool Start(
            System.Reflection.Assembly DatabaseAssembly, 
            Action<String> Output)
        {
            GameInfo gameInfo = null;
            foreach (var type in DatabaseAssembly.GetTypes())
                if (type.IsSubclassOf(typeof(GameInfo)))
                    gameInfo = Activator.CreateInstance(type) as GameInfo;

            if (gameInfo == null) throw new InvalidOperationException("No GameInfo defined in game assembly.");

            var assemblies = new List<ModuleAssembly>();
            assemblies.Add(new ModuleAssembly(DatabaseAssembly, new ModuleInfo { BaseNameSpace = gameInfo.DatabaseNameSpace }));
            foreach (var module in gameInfo.Modules)
                assemblies.Add(new ModuleAssembly(module));

            if (RMUD.Core.Start(StartupFlags.Silent,
                new RMUD.SinglePlayer.CompiledDatabase(DatabaseAssembly, gameInfo.DatabaseNameSpace),
                assemblies.ToArray()))
            {
                Player = RMUD.MudObject.GetObject<RMUD.Player>(RMUD.Core.SettingsObject.PlayerBaseObject);
                Player.CommandHandler = RMUD.Core.ParserCommandHandler;
                Client = new DummyClient(Output);
                RMUD.Core.TiePlayerToClient(Client, Player);
                Player.Rank = 500;

                DetectAndAssignDriver(DatabaseAssembly);
                Core.GlobalRules.ConsiderPerformRule("singleplayer game started", Player);

                return true;
            }

            return false;
        }
开发者ID:Reddit-Mud,项目名称:RMUD,代码行数:34,代码来源:Driver.cs

示例7: buildTreeFromAssembly

        public void buildTreeFromAssembly(System.Reflection.Assembly CurrentAsm)
        {
            //code from Platt's example
            TreeNode BaseNode;
            BaseNode = treeViewAssembly.Nodes.Add("Assy:" + CurrentAsm.GetName().ToString());
            BaseNode.Tag = CurrentAsm;

            // Enumerate each type contained in the assembly

            foreach (System.Type ThisType in CurrentAsm.GetTypes())
            {
                TreeNode MyNode;
                MyNode = BaseNode.Nodes.Add(ThisType.ToString() + " : " + ThisType.BaseType.ToString());
                MyNode.Tag = ThisType;

                // Enumerate all the members of this type
                // Add each member to the tree

                foreach (System.Reflection.MemberInfo Member in
                    ThisType.GetMembers(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static))
                {
                    TreeNode typenode = MyNode.Nodes.Add(Member.MemberType.ToString() + " : " + Member.Name);
                    typenode.Tag = Member;
                }
            }
        }
开发者ID:dust2098,项目名称:e33-dispatcher-application,代码行数:26,代码来源:frmTreeAndTestCases.cs

示例8: AssemblyInfo

        public AssemblyInfo(System.Reflection.Assembly assembly, bool structure)
        {
            Classes = new List<TypeInfo>();
            Interfaces = new List<InterfaceInfo>();
            Enumerations = new List<EnumInfo>();
            Exceptions = new List<ExceptionInfo>();
            Attributes = new List<AttributeInfo>();
            Structures = new List<StructureInfo>();
            try
            {
                foreach (Type type in assembly.GetTypes())
                    if (type.IsSubclassOf(typeof(System.Exception)))
                        Exceptions.Add(new ExceptionInfo(type));
                    else if (type.IsSubclassOf(typeof(System.Attribute)))
                        Attributes.Add(new AttributeInfo(type));
                    else if (type.IsClass)
                        Classes.Add(new TypeInfo(type));
                    else if (type.IsInterface)
                        Interfaces.Add(new InterfaceInfo(type));
                    else if (type.IsEnum)
                        Enumerations.Add(new EnumInfo(type));
            }
            catch (Exception ex)
            {

            }

            if (!structure)
                return;

            Structure = NamespaceInfo.CreateStructureByAssembly(this);
        }
开发者ID:vybeonllc,项目名称:dat_framework,代码行数:32,代码来源:AssemblyInfo.cs

示例9: AddByAssembly

 internal void AddByAssembly(System.Reflection.Assembly assembly)
 {
     var commands = assembly.GetTypes().Where(t => typeof(ICommand) == t.BaseType);
     foreach (var type in commands)
     {
        // this.Add(type);
     }
 }
开发者ID:iraychen,项目名称:LCLFramework,代码行数:8,代码来源:CommandRepository.cs

示例10: Register

 public static void Register(System.Reflection.Assembly assembly)
 {
     foreach (Type type in assembly.GetTypes())
     {
         if(!type.IsAbstract && !type.IsInterface && type.GetCustomAttributes(typeof(ProtoContractAttribute),false).Length>0)
             mTables[type.Name]=type;
     }
 }
开发者ID:hdxhan,项目名称:IKendeLib,代码行数:8,代码来源:ProtoBufPackage.cs

示例11: ServerRepo

 public ServerRepo(string prefix, System.Reflection.Assembly typesAsm)
 {
     _subscriptions = new Dictionary<string, Subscription>();
     _types = new List<Type>(typesAsm.GetTypes());
     _server = new Server (this, prefix);
     _handlersByClientId = new Dictionary<string, ClientHandler> ();
     _queryInfos = new Dictionary<string, Dictionary<SqlQuery, QueryInfo>> ();
 }
开发者ID:briandonahue,项目名称:proactive-framework,代码行数:8,代码来源:DataServerRepo.cs

示例12: Register

 public static void Register(System.Reflection.Assembly assembly)
 {
     foreach (Type type in assembly.GetTypes())
     {
         if(!type.IsAbstract && !type.IsInterface)
             mTables[type.FullName]=type;
     }
 }
开发者ID:hdxhan,项目名称:IKendeLib,代码行数:8,代码来源:ProtoBufPackage.cs

示例13: DiscoverHardware

 static void DiscoverHardware(System.Reflection.Assembly Assembly)
 {
     foreach (var type in Assembly.GetTypes())
     {
         var attr = type.GetCustomAttributes(false).FirstOrDefault(a => a is HardwareAttribute) as HardwareAttribute;
         if (attr != null && !HardwareTypes.ContainsKey(attr.ID))
                 HardwareTypes.Add(attr.ID, type);
     }
 }
开发者ID:Blecki,项目名称:IN8,代码行数:9,代码来源:Program.cs

示例14: DiscoverClasses

        public static void DiscoverClasses(System.Reflection.Assembly assembly)
        {
            var collection = GetMarkedTypes(assembly.GetTypes().AsParallel(), typeof(ContextClassAttribute));

            foreach (var type in collection)
            {
                RegisterSystemType(type);
            }
        }
开发者ID:Shemetov,项目名称:OneScript,代码行数:9,代码来源:ContextDiscoverer.cs

示例15: GetTableClasses

 /// <summary>
 /// Get all the DTOs/classes that will be stored in our data storage
 /// </summary>
 /// <param name="assembly"></param>
 /// <returns></returns>
 public static IEnumerable<Type> GetTableClasses(System.Reflection.Assembly assembly)
 {
     foreach (Type type in assembly.GetTypes())
     {
         if (type.GetCustomAttributes(typeof(TableAttribute), true).Length > 0)
         {
             yield return type;
         }
     }
 }
开发者ID:jokecamp,项目名称:OpenFootballApi,代码行数:15,代码来源:TableAttribute.cs


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