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


C# ITypeFinder.FindClassesOfType方法代码示例

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


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

示例1: Register

        public void Register(Autofac.ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType<WorkflowEngine>().As<IWorkflowEngine>().InstancePerHttpRequest();
            builder.RegisterAssemblyTypes(typeFinder.GetAssemblies().ToArray())
               .AssignableTo<IAutoActivityHandler>()
               .AsImplementedInterfaces();

            Assembly[] assemblies = typeFinder.GetAssemblies().ToArray();
            builder.RegisterAssemblyTypes(assemblies)
               .AssignableTo<IAutoActivityHandler>()
               .AsImplementedInterfaces();

            //regisger  [UUID("ApplyQuota-2.0-Approve-ActivityExecutedEvent")]
            var handlers = typeFinder.FindClassesOfType(typeof(IAutoActivityHandler)).ToList();
            foreach (var handler in handlers)
            {
                object[] attrs = handler.GetCustomAttributes(typeof(UUIDAttribute), false);
                string uuid = string.Empty;
                if (attrs != null)
                {
                    foreach (UUIDAttribute attr in attrs)
                    {
                        uuid = attr.UUID;
                    }
                    builder.RegisterType(handler).As<IAutoActivityHandler>().Keyed<IAutoActivityHandler>(uuid)
                    .InstancePerHttpRequest();
                }
            }

            //regisger  [UUID("ApplyQuota-2.0-Approve-ActivityExecutedEvent")]
            var consumers = typeFinder.FindClassesOfType(typeof(IConsumer<>)).ToList();
            foreach (var consumer in consumers)
            {
                object[] attrs = consumer.GetCustomAttributes(typeof(UUIDAttribute), false);
                string uuid = string.Empty;
                if (attrs != null)
                {
                    foreach (UUIDAttribute attr in attrs)
                    {
                        uuid = attr.UUID;
                    }
                    var interfaceType = consumer.FindInterfaces((type, criteria) =>
                    {
                        var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
                        return isMatch;
                    }, typeof(IConsumer<>))[0];
                    builder.RegisterType(consumer).As(interfaceType)
                    .Keyed(uuid, interfaceType)
                    .InstancePerHttpRequest();
                }
            }
        }
开发者ID:AgileEAP,项目名称:WebStack,代码行数:52,代码来源:DependencyRegistrar.cs

示例2: Register

        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            Singleton<IDependencyResolver>.Instance = new DependencyResolver();

            string collectionString = "Data Source=.;Initial Catalog=demo;User ID=sa;Password=sa;Trusted_Connection=False;";
            builder.Register<IDbContext>(c => new WaterMoonContext(collectionString)).PerLifeStyle(ComponentLifeStyle.LifetimeScope);
            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).PerLifeStyle(ComponentLifeStyle.LifetimeScope);
            builder.RegisterGeneric(typeof(PagedList<>)).As(typeof(IPagedList<>)).PerLifeStyle(ComponentLifeStyle.LifetimeScope);

            builder.RegisterType<DefualtMapping>().As<IMapping>().SingleInstance();

            //注册所有实现IConsumer<>类型的对象
            var consumers = typeFinder.FindClassesOfType(typeof(IConsumer<>)).ToList();
            foreach (var consumer in consumers)
            {
                builder.RegisterType(consumer)
                    .As(consumer.FindInterfaces((type, criteria) =>
                    {
                        var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
                        return isMatch;
                    }, typeof(IConsumer<>)))
                    .PerLifeStyle(ComponentLifeStyle.LifetimeScope);
            }
            builder.RegisterType<EventPublisher>().As<IEventPublisher>().SingleInstance();
            builder.RegisterType<SubscriptionService>().As<ISubscriptionService>().SingleInstance();

            builder.RegisterType<DemoService>().As<IDemoService>().PerLifeStyle(ComponentLifeStyle.LifetimeScope);
        }
开发者ID:TelWang,项目名称:WatermoonFramework,代码行数:28,代码来源:DependencyRegistrar.cs

示例3: Register

    public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
    {
        //HTTP context and other related stuff
        builder.Register(c =>
            //register FakeHttpContext when HttpContext is not available
            HttpContext.Current != null ?
            (new HttpContextWrapper(HttpContext.Current) as HttpContextBase) :
            (new FakeHttpContext("~/") as HttpContextBase))
            .As<HttpContextBase>()
            .InstancePerHttpRequest();
        builder.Register(c => c.Resolve<HttpContextBase>().Request)
            .As<HttpRequestBase>()
            .InstancePerHttpRequest();
        builder.Register(c => c.Resolve<HttpContextBase>().Response)
            .As<HttpResponseBase>()
            .InstancePerHttpRequest();
        builder.Register(c => c.Resolve<HttpContextBase>().Server)
            .As<HttpServerUtilityBase>()
            .InstancePerHttpRequest();
        builder.Register(c => c.Resolve<HttpContextBase>().Session)
            .As<HttpSessionStateBase>()
            .InstancePerHttpRequest();

        builder.RegisterType<SqlServerProvider>().As<IDbProvider>();

        builder.RegisterType<MemoryProvider>().Named<ICache>("memory");

         var list = typeFinder.FindClassesOfType<ICache>().ToList();
        list.ForEach(s=>builder.RegisterType(s));
        //list.ForEach(s=>builder.RegisterType<s>());
    }
开发者ID:bluexray,项目名称:Left4Framework,代码行数:31,代码来源:DependencyRegistrar.cs

示例4: RegisterDependencies

 public void RegisterDependencies(ContainerBuilder builder, ITypeFinder typeFinder)
 {
     var consumers = typeFinder.FindClassesOfType<IExamineEventsConsumer>(true);
     foreach (var consumer in consumers)
     {
         builder.RegisterType(consumer).As<IExamineEventsConsumer>().SingleInstance();
     }
 }
开发者ID:bgadiel,项目名称:tt,代码行数:8,代码来源:ExamineEventsDependencyRegistrar.cs

示例5: RegisterDependencies

 public void RegisterDependencies(ContainerBuilder builder, ITypeFinder typeFinder)
 {
     var types = typeof(IConsumer<>);
     var consumers = typeFinder.FindClassesOfType(types);
     foreach (var consumer in consumers)
     {
         builder.RegisterType(consumer)
             .As(consumer.FindInterfaces((type, criteria) =>
                 type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition())
                 , typeof(IConsumer<>)))
             .InstancePerRequest();
     }
 }
开发者ID:bgadiel,项目名称:tt,代码行数:13,代码来源:EventConsumersRegistrar.cs

示例6: Register

        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            var contextList = typeFinder.FindClassesOfType<BaseDbContext>(true);
            foreach (var type in contextList)
            {
                var dbname = type.Name.Replace("Entities","");
                if (ConfigurationManager.ConnectionStrings[dbname] == null)
                {
                    continue;

                }
                RegisterDB(builder, type, typeFinder);
            }

            //cache manager
            builder.RegisterType<CacheManager>().As<ICacheManager>().Named<ICacheManager>("sdf_cache_static").SingleInstance();

            var services = typeFinder.FindClassesOfType<BaseService>().ToList();
            services.ForEach(s => builder.RegisterType(s).AsImplementedInterfaces().PropertiesAutowired());

            builder.RegisterType<AccountService>().As<IAccount>();
        }
开发者ID:sdf333,项目名称:MVCDEMO,代码行数:22,代码来源:WCFDependencyRegistrar.cs

示例7: RegisterDB

        private void RegisterDB(ContainerBuilder builder, Type type, ITypeFinder typeFinder)
        {
            var entityAssembly = Assembly.Load(type.Namespace);
            builder.RegisterType(type).Named<DbContext>(type.FullName);
            var a = new Assembly[] {entityAssembly};

            var typeList = typeFinder.FindClassesOfType<BaseEntity>(a,true);
            var tRepository = typeof(EfRepository<>);
            foreach (Type t in typeList)
            {
                var t2 = tRepository.MakeGenericType(t);
                builder.RegisterType(t2).AsImplementedInterfaces().WithParameter(ResolvedParameter.ForNamed<DbContext>(type.FullName));
            }
        }
开发者ID:sdf333,项目名称:MVCDEMO,代码行数:14,代码来源:WCFDependencyRegistrar.cs

示例8: CreateEngineInstance

 /// <summary>
 /// Creates a factory instance and adds a http application injecting facility.
 /// </summary>
 /// <returns>A new factory</returns>
 public static IEngine CreateEngineInstance(ITypeFinder typeFinder)
 {
     var engines = typeFinder.FindClassesOfType<IEngine>().ToArray();
     engines = engines.Where(it => it != typeof(MEF.MEFEngine)).ToArray();
     if (engines.Length > 0)
     {
         var defaultEngine = (IEngine)Activator.CreateInstance(engines[0], typeFinder);
         return defaultEngine;
     }
     else
     {
         return new MEF.MEFEngine(typeFinder);
     }
 }
开发者ID:Kooboo,项目名称:CommonLibraries,代码行数:18,代码来源:EngineContext.cs

示例9: MapGeneric

        protected void MapGeneric(ContainerBuilder builder, ITypeFinder typeFinder, Type mapperType,
            IEnumerable<Type> contentTypes, Type defaultMapperType)
        {
            var allConverterTypes = typeFinder.FindClassesOfType(mapperType).ToArray();
            foreach (var contentType in contentTypes)
            {
                var specificMapperType = allConverterTypes.FirstOrDefault(ct =>
                {
                    var t = ct.GetInterfaces().First(i => i.IsGenericType && i.GetGenericTypeDefinition() == mapperType);
                    return t.GenericTypeArguments[0] == contentType;
                });

                var concreteType = specificMapperType ?? defaultMapperType.MakeGenericType(contentType);

                var target = mapperType.MakeGenericType(contentType);

                builder.RegisterType(concreteType).As(target).InstancePerRequest();
            }
        }
开发者ID:bgadiel,项目名称:tt,代码行数:19,代码来源:BaseRegisrar.cs

示例10: Register


//.........这里部分代码省略.........
            builder.RegisterType<PictureService>().As<IPictureService>().InstancePerLifetimeScope();

            builder.RegisterType<MessageTemplateService>().As<IMessageTemplateService>().InstancePerLifetimeScope();
            builder.RegisterType<QueuedEmailService>().As<IQueuedEmailService>().InstancePerLifetimeScope();
            builder.RegisterType<NewsLetterSubscriptionService>().As<INewsLetterSubscriptionService>().InstancePerLifetimeScope();
            builder.RegisterType<CampaignService>().As<ICampaignService>().InstancePerLifetimeScope();
            builder.RegisterType<EmailAccountService>().As<IEmailAccountService>().InstancePerLifetimeScope();
            builder.RegisterType<WorkflowMessageService>().As<IWorkflowMessageService>().InstancePerLifetimeScope();
            builder.RegisterType<MessageTokenProvider>().As<IMessageTokenProvider>().InstancePerLifetimeScope();
            builder.RegisterType<Tokenizer>().As<ITokenizer>().InstancePerLifetimeScope();
            builder.RegisterType<EmailSender>().As<IEmailSender>().InstancePerLifetimeScope();

            builder.RegisterType<CheckoutAttributeFormatter>().As<ICheckoutAttributeFormatter>().InstancePerLifetimeScope();
            builder.RegisterType<CheckoutAttributeParser>().As<ICheckoutAttributeParser>().InstancePerLifetimeScope();
            builder.RegisterType<CheckoutAttributeService>().As<ICheckoutAttributeService>().InstancePerLifetimeScope();
            builder.RegisterType<GiftCardService>().As<IGiftCardService>().InstancePerLifetimeScope();
            builder.RegisterType<OrderService>().As<IOrderService>().InstancePerLifetimeScope();
            builder.RegisterType<OrderReportService>().As<IOrderReportService>().InstancePerLifetimeScope();
            builder.RegisterType<OrderProcessingService>().As<IOrderProcessingService>().InstancePerLifetimeScope();
            builder.RegisterType<OrderTotalCalculationService>().As<IOrderTotalCalculationService>().InstancePerLifetimeScope();
            builder.RegisterType<ShoppingCartService>().As<IShoppingCartService>().InstancePerLifetimeScope();

            builder.RegisterType<PaymentService>().As<IPaymentService>().InstancePerLifetimeScope();

            builder.RegisterType<EncryptionService>().As<IEncryptionService>().InstancePerLifetimeScope();
            builder.RegisterType<FormsAuthenticationService>().As<IAuthenticationService>().InstancePerLifetimeScope();

            //pass MemoryCacheManager as cacheManager (cache settings between requests)
            builder.RegisterType<UrlRecordService>().As<IUrlRecordService>()
                .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"))
                .InstancePerLifetimeScope();

            builder.RegisterType<ShipmentService>().As<IShipmentService>().InstancePerLifetimeScope();
            builder.RegisterType<ShippingService>().As<IShippingService>().InstancePerLifetimeScope();

            builder.RegisterType<TaxCategoryService>().As<ITaxCategoryService>().InstancePerLifetimeScope();
            builder.RegisterType<TaxService>().As<ITaxService>().InstancePerLifetimeScope();
            builder.RegisterType<TaxCategoryService>().As<ITaxCategoryService>().InstancePerLifetimeScope();

            //pass MemoryCacheManager as cacheManager (cache settings between requests)
            builder.RegisterType<CustomerActivityService>().As<ICustomerActivityService>()
                .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"))
                .InstancePerLifetimeScope();

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UseFastInstallationService"]) &&
                Convert.ToBoolean(ConfigurationManager.AppSettings["UseFastInstallationService"]))
            {
                builder.RegisterType<SqlFileInstallationService>().As<IInstallationService>().InstancePerLifetimeScope();
            }
            else
            {
                builder.RegisterType<CodeFirstInstallationService>().As<IInstallationService>().InstancePerLifetimeScope();
            }

            builder.RegisterType<ForumService>().As<IForumService>().InstancePerLifetimeScope();

            builder.RegisterType<PollService>().As<IPollService>().InstancePerLifetimeScope();
            builder.RegisterType<BlogService>().As<IBlogService>().InstancePerLifetimeScope();
            builder.RegisterType<WidgetService>().As<IWidgetService>().InstancePerLifetimeScope();
            builder.RegisterType<TopicService>().As<ITopicService>().InstancePerLifetimeScope();
            builder.RegisterType<NewsService>().As<INewsService>().InstancePerLifetimeScope();

            builder.RegisterType<DateTimeHelper>().As<IDateTimeHelper>().InstancePerLifetimeScope();
            builder.RegisterType<SitemapGenerator>().As<ISitemapGenerator>().InstancePerLifetimeScope();
            builder.RegisterType<PageHeadBuilder>().As<IPageHeadBuilder>().InstancePerLifetimeScope();

            builder.RegisterType<ScheduleTaskService>().As<IScheduleTaskService>().InstancePerLifetimeScope();

            builder.RegisterType<ExportManager>().As<IExportManager>().InstancePerLifetimeScope();
            builder.RegisterType<ImportManager>().As<IImportManager>().InstancePerLifetimeScope();
            builder.RegisterType<PdfService>().As<IPdfService>().InstancePerLifetimeScope();
            builder.RegisterType<ThemeProvider>().As<IThemeProvider>().InstancePerLifetimeScope();
            builder.RegisterType<ThemeContext>().As<IThemeContext>().InstancePerLifetimeScope();

            builder.RegisterType<ExternalAuthorizer>().As<IExternalAuthorizer>().InstancePerLifetimeScope();
            builder.RegisterType<OpenAuthenticationService>().As<IOpenAuthenticationService>().InstancePerLifetimeScope();

            builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().SingleInstance();

            //Register event consumers
            var consumers = typeFinder.FindClassesOfType(typeof(IConsumer<>)).ToList();
            foreach (var consumer in consumers)
            {
                builder.RegisterType(consumer)
                    .As(consumer.FindInterfaces((type, criteria) =>
                    {
                        var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
                        return isMatch;
                    }, typeof(IConsumer<>)))
                    .InstancePerLifetimeScope();
            }
            builder.RegisterType<EventPublisher>().As<IEventPublisher>().SingleInstance();
            builder.RegisterType<SubscriptionService>().As<ISubscriptionService>().SingleInstance();

            //Anko.Plugins.Admin.Uploader
            builder.RegisterType<ProductUploader>().As<IProductUploader>();
            builder.RegisterType<ProductValidator>().As<IProductValidator>();
            builder.RegisterType<ConsoleLogger>().As<ILogger>().InstancePerLifetimeScope();
            builder.RegisterType<ProductResolver>().As<IProductResolver>().InstancePerLifetimeScope();
        }
开发者ID:aleks279,项目名称:atrend-test,代码行数:101,代码来源:DependencyRegistrar.cs

示例11: Register

        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            //HTTP context and other related stuff
            builder.Register(c =>
                //register FakeHttpContext when HttpContext is not available
                HttpContext.Current != null ?
                (new HttpContextWrapper(HttpContext.Current) as HttpContextBase) :
                (new FakeHttpContext("~/") as HttpContextBase))
                .As<HttpContextBase>()
                .InstancePerLifetimeScope();
            builder.Register(c => c.Resolve<HttpContextBase>().Request)
                .As<HttpRequestBase>()
                .InstancePerLifetimeScope();
            builder.Register(c => c.Resolve<HttpContextBase>().Response)
                .As<HttpResponseBase>()
                .InstancePerLifetimeScope();
            builder.Register(c => c.Resolve<HttpContextBase>().Server)
                .As<HttpServerUtilityBase>()
                .InstancePerLifetimeScope();
            builder.Register(c => c.Resolve<HttpContextBase>().Session)
                .As<HttpSessionStateBase>()
                .InstancePerLifetimeScope();

            //web helper
            builder.RegisterType<WebHelper>().As<IWebHelper>().InstancePerLifetimeScope();

            //data layer
            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();
            builder.Register(c => dataSettingsManager.LoadSettings()).As<DataSettings>();
            builder.Register(x => new EfDataProviderManager(x.Resolve<DataSettings>())).As<BaseDataProviderManager>().InstancePerDependency();

            builder.Register(x => x.Resolve<BaseDataProviderManager>().LoadDataProvider()).As<IDataProvider>().InstancePerDependency();

            if (dataProviderSettings != null && dataProviderSettings.IsValid())
            {
                var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
                var dataProvider = efDataProviderManager.LoadDataProvider();
                dataProvider.InitConnectionFactory();
                var datacontext = new AFObjectContext(dataProviderSettings.DataConnectionString);
                datacontext.Database.Log = s => Debug.Print(s);
                Database.SetInitializer<AFObjectContext>(null);
                builder.Register<IDbContext>(c => datacontext)
                    .InstancePerLifetimeScope();
            }
            else
            {
                var datacontext = new AFObjectContext(dataSettingsManager.LoadSettings().DataConnectionString);
                datacontext.Database.Log = s => Debug.Print(s);
                Database.SetInitializer<AFObjectContext>(null);
                builder.Register<IDbContext>(
                    c => datacontext)
                    .InstancePerLifetimeScope();
            }

            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();

            //cache manager
            builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().Named<ICacheManager>("af_cache_static").SingleInstance();
            builder.RegisterType<PerRequestCacheManager>().As<ICacheManager>().Named<ICacheManager>("af_cache_per_request").InstancePerLifetimeScope();

            builder.RegisterType<CustomerService>().As<ICustomerService>().InstancePerLifetimeScope();

            builder.RegisterType<ScheduleTaskService>().As<IScheduleTaskService>().InstancePerLifetimeScope();

            builder.RegisterType<FormsAuthenticationService>().As<IAuthenticationService>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerRegistrationService>().As<ICustomerRegistrationService>().InstancePerLifetimeScope();
            builder.RegisterType<EncryptionService>().As<IEncryptionService>().InstancePerLifetimeScope();

            builder.RegisterType<GenericAttributeService>().As<IGenericAttributeService>().InstancePerLifetimeScope();
            builder.RegisterType<SettingService>().As<ISettingService>().InstancePerLifetimeScope();
            builder.RegisterType<DefaultLogger>().As<ILogger>().InstancePerLifetimeScope();

            builder.RegisterType<OrderProcessingService>().As<IOrderProcessingService>().InstancePerLifetimeScope();
            builder.RegisterType<OrderService>().As<IOrderService>().InstancePerLifetimeScope();

            //Register event consumers
            var consumers = typeFinder.FindClassesOfType(typeof(IConsumer<>)).ToList();
            foreach (var consumer in consumers)
            {
                builder.RegisterType(consumer)
                    .As(consumer.FindInterfaces((type, criteria) =>
                    {
                        var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
                        return isMatch;
                    }, typeof(IConsumer<>)))
                    .InstancePerLifetimeScope();
            }
            builder.RegisterType<EventPublisher>().As<IEventPublisher>().SingleInstance();
            builder.RegisterType<SubscriptionService>().As<ISubscriptionService>().SingleInstance();
        }
开发者ID:SeptemberWind,项目名称:AlvisFrameworkProject,代码行数:91,代码来源:DependencyRegistrar.cs


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