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


C# Assembly.GetExportedTypes方法代码示例

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


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

示例1: FindMigrationsIn

        public IEnumerable<MigrationMetadata> FindMigrationsIn(Assembly assembly, string @namespace)
        {
            IEnumerable<Type> matchedTypes = assembly.GetExportedTypes().Where(t => Conventions.TypeIsMigration(t));

            if (!string.IsNullOrEmpty(@namespace))
                matchedTypes = assembly.GetExportedTypes().Where(t => t.Namespace == @namespace && Conventions.TypeIsMigration(t));

            foreach (Type type in matchedTypes)
                yield return Conventions.GetMetadataForMigration(type);
        }
开发者ID:shawng,项目名称:fluentmigrator,代码行数:10,代码来源:MigrationLoader.cs

示例2: ScanAssembly

        public void ScanAssembly(Assembly assembly)
        {
            assembly
                .GetExportedTypes()
                .Where(x => x.CanBeCastTo<StringToken>())
                .Each(ScanStringTokenType);

            assembly
                .GetExportedTypes()
                .Where(x => x.IsConcreteTypeOf<ILocalizedProperties>())
                .Each(type => ScanProperties(type.Create<ILocalizedProperties>()));
        }
开发者ID:RyanHauert,项目名称:fubumvc,代码行数:12,代码来源:AssemblyScanner.cs

示例3: RunScript

 static string RunScript(Assembly script)
 {
     string res = "Error";
     foreach (Type type in script.GetExportedTypes())
         foreach (Type iface in type.GetInterfaces())
             if (iface == typeof(IScript))
             {
                 ConstructorInfo constructor = type.GetConstructor(System.Type.EmptyTypes);
                 if (constructor != null && constructor.IsPublic)
                 {
                     IScript scriptObject = constructor.Invoke(null) as IScript;
                     if (scriptObject != null)
                     {
                         res = scriptObject.RunScript();
                     }
                     else
                     {
                     }
                 }
                 else
                 {
                 }
             }
     return res;
 }
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:25,代码来源:ScriptCompiler.cs

示例4: AddTypes

        /// <summary>
        /// Stellt sicher, dass der Serialisierer alle benötigten Datentypen kennt.
        /// </summary>
        /// <param name="assembly">Eine Erweiterungsbibliothek.</param>
        internal static void AddTypes( Assembly assembly )
        {
            // Nothing to do
            if (assembly == null)
                return;

            // Process all
            lock (m_ExtraTypes)
            {
                // Check for update
                bool mustUpdate = false;

                // Check all
                foreach (var type in assembly.GetExportedTypes())
                {
                    // Resolve to base
                    var genericBase = FindCustomActionBase( type );
                    if (genericBase != null)
                        if (m_ExtraTypes.Add( typeof( CustomActionRequest<,> ).MakeGenericType( genericBase.GetGenericArguments() ) ))
                            mustUpdate = true;
                }

                // Reload serializer
                if (mustUpdate)
                    CreateSerializer();
            }
        }
开发者ID:davinx,项目名称:DVB.NET---VCR.NET,代码行数:31,代码来源:Request.cs

示例5: AddTypes

 /// <summary>
 /// Adds all the exported (public) types in the given assembly to the scope of used types.
 /// </summary>
 public static void AddTypes(this IStringlyScope scope, Assembly assembly)
 {
     foreach (var type in assembly.GetExportedTypes())
     {
         scope.AddType(type);
     }
 }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:10,代码来源:StringlyScopeExtensions.cs

示例6: ExtensionInfoBuilder

        /// <summary>
        /// Initializes a new instance of the ExtensionInfoBuilder class for the given assembly.
        /// </summary>
        /// <param name="fileName">The file name and path to the assembly to check.</param>
        public ExtensionInfoBuilder(string fileName)
        {
            ExtensionInfo ei;
            Type[] types;
            resultExtensions = new ExtensionInfoCollection();
            Type ropt = typeof(Extension);

            sourceAssembly = Assembly.ReflectionOnlyLoadFrom(fileName);

            ropt = ReflectionOnlyTypeFromAssembly(sourceAssembly, ropt);
            try
            {
                types = sourceAssembly.GetExportedTypes();
                foreach (Type t in types)
                {
                    try
                    {
                        if (t.IsSubclassOf(ropt) && !t.IsAbstract)
                        {
                            ei = new ExtensionInfo(t);
                            resultExtensions.Add(ei);
                        }
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        ei = null;
                    }
                }
            }
            catch (ReflectionTypeLoadException)
            {
                return;
            }
        }
开发者ID:hapm,项目名称:IrcShark,代码行数:38,代码来源:ExtensionInfoBuilder.cs

示例7: Verify

        /// <summary>
        /// Calls <see cref="Verify(Type[])" /> for each public Type in
        /// <paramref name="assembly" />.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        public virtual void Verify(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException("assembly");

            this.Verify(assembly.GetExportedTypes());
        }
开发者ID:rajeshgupthar,项目名称:AutoFixture,代码行数:12,代码来源:IdiomaticAssertion.cs

示例8: GetLoadableTypes

 private static IEnumerable<Type> GetLoadableTypes(Assembly assembly)
 {
     if (assembly == null) throw new ArgumentNullException("assembly");
     try
     {
         return assembly.GetExportedTypes();
     }
     catch (TypeLoadException)
     {
         return new Type[0];
     }
     catch (FileNotFoundException)
     {
         return new Type[0];
     }
     catch (ReflectionTypeLoadException ex)
     {
         var types = ex.Types;
         IList<Type> list = new List<Type>(types.Length);
         foreach (var t in types)
             if (t != null && t.IsPublic)
                 list.Add(t);
         return list;
     }
 }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:25,代码来源:GeometryServiceProvider.cs

示例9: FindSpecificationSupplementsIn

 public IEnumerable<ISupplementSpecificationResults> FindSpecificationSupplementsIn(Assembly assembly)
 {
   return assembly.GetExportedTypes()
     .Where(x =>
            x.GetInterfaces().Contains(typeof(ISupplementSpecificationResults)))
     .Select(x => (ISupplementSpecificationResults) Activator.CreateInstance(x));
 }
开发者ID:jayhill,项目名称:machine.specifications,代码行数:7,代码来源:AssemblyExplorer.cs

示例10: FindAssemblyWideContextCleanupsIn

 public IEnumerable<ICleanupAfterEveryContextInAssembly> FindAssemblyWideContextCleanupsIn(Assembly assembly)
 {
   return assembly.GetExportedTypes()
     .Where(x =>
            x.GetInterfaces().Contains(typeof(ICleanupAfterEveryContextInAssembly)))
     .Select(x => (ICleanupAfterEveryContextInAssembly) Activator.CreateInstance(x));
 }
开发者ID:jayhill,项目名称:machine.specifications,代码行数:7,代码来源:AssemblyExplorer.cs

示例11: MapAttributeRoutesInAssembly

        public static void MapAttributeRoutesInAssembly(this RouteCollection routes, Assembly assembly, IInlineConstraintResolver constraintResolver, IDirectRouteProvider routeProvider)
        {
            var controllers = (assembly.GetExportedTypes()
                .Where(IsControllerType)).ToList();

            MapAttributeRoutesInControllers(routes, controllers, constraintResolver, routeProvider);
        }
开发者ID:chimpinano,项目名称:MvcRouteTester,代码行数:7,代码来源:WebRouteTestMapper.cs

示例12: EventTypeResolver

 public EventTypeResolver(Assembly assembly)
 {
     _typeMap = assembly
         .GetExportedTypes()
         .Where(x => x.Name.EndsWith("Event", StringComparison.OrdinalIgnoreCase))
         .ToDictionary(x => x.Name);
 }
开发者ID:AdaptiveConsulting,项目名称:ReactiveTraderCloud,代码行数:7,代码来源:EventTypeResolver.cs

示例13: RegisterViewModelsWithLocator

 private static void RegisterViewModelsWithLocator(Assembly assembly)
 {
     foreach (var viewModel in assembly.GetExportedTypes().Where(x => x.IsPublic && !x.IsInterface && x.Name.EndsWith("ViewModel")))
     {
         RegisterKnownViewModel(viewModel);
     }
 }
开发者ID:mikoskinen,项目名称:Caliburn.Micro.WP71.Recipes.ExternalModules,代码行数:7,代码来源:StaticViewModelLocator.cs

示例14: DiscoverTypes

		protected void DiscoverTypes( Assembly assembly )
		{
			Type[] types = null;

			try
			{
				types = assembly.GetExportedTypes();
			}
			catch(Exception)
			{
				// Ok, Dynamic assemblies don't support GetExportedTypes
				types = new Type[0];
			}
			
			foreach( Type type in types )
			{
				String nameSpace = type.Namespace;

				if (nameSpace == null)
				{
					continue;
				}
				
				Tree.DefineNamespace( nameSpace ).AddType( type );
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:26,代码来源:TypeManager.cs

示例15: MapMvcAttributeRoutes

        public static void MapMvcAttributeRoutes(
            this RouteCollection routeCollection,
            Assembly controllerAssembly,
            IInlineConstraintResolver constraintResolver = null)
        {
            var controllerTypes = (from type in controllerAssembly.GetExportedTypes()
                                   where
                                       type != null && type.IsPublic
                                       && type.Name.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)
                                       && !type.IsAbstract && typeof(IController).IsAssignableFrom(type)
                                   select type).ToList();
            routeCollection.MapMvcAttributeRoutes();
            var attributeRoutingAssembly = typeof(RouteCollectionAttributeRoutingExtensions).Assembly;
            var attributeRoutingMapperType =
                attributeRoutingAssembly.GetType("System.Web.Mvc.Routing.AttributeRoutingMapper");

            var mapAttributeRoutesMethod = attributeRoutingMapperType.GetMethod(
                "MapAttributeRoutes",
                BindingFlags.Public | BindingFlags.Static,
                null,
                new[] { typeof(RouteCollection), typeof(IEnumerable<Type>), typeof(IInlineConstraintResolver) },
                null);

            constraintResolver = constraintResolver ?? new DefaultInlineConstraintResolver();
            mapAttributeRoutesMethod.Invoke(null, new object[] { routeCollection, controllerTypes, constraintResolver });
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:26,代码来源:RouteCollectionTestExtensions.cs


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