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


C# IScanner.ScanTypes方法代码示例

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


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

示例1: ScanAndRegisterHandlers

        void ScanAndRegisterHandlers(IBinder binder, IScanner scanner) 
        {
            var handlerTups = scanner.ScanTypes(typeof(Registrar).Assembly)
                                        .Where(t => !t.IsAbstract)
                                        .Select(t => new {
                                            ImplType = t,
                                            IntType = t.GetInterfaces()
                                                            .SingleOrDefault(i => i.IsGenericType
                                                                                && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>))
                                        })
                                        .Where(tup => tup.IntType != null);

            foreach(var tup in handlerTups) {
                binder.Bind(tup.IntType, tup.ImplType);
            }
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:16,代码来源:Registrar.cs

示例2: Register


//.........这里部分代码省略.........
            x.Bind<IPluginFinder, BrigitaPluginFinder>();

            x.Bind<ILogger, NullLogger>();


            x.BindGeneric(typeof(IRepo<>), typeof(Repo<>));
                        
            x.Bind<ILinkProvider, LinkProvider>();

            x.Bind<IMediator, Mediator>();

            x.Bind<IPicSource, PicSource>();
            x.Bind<IPictureService, PictureService>();

            x.Bind<ILocaleContext, LocaleContext>();
            x.Bind<ILocaleCodeProvider, LocaleCodeProvider>();
            
            x.BindGeneric(typeof(ILocalizer<>), typeof(Localizer<>));
            x.BindGeneric(typeof(IStringLocalizer<>), typeof(StringLocalizer<>));
            x.BindGeneric(typeof(ICurrencyLocalizer<>), typeof(CurrencyLocalizer<>));


            x.Bind<IWorkContext, BrigitaWorkContext>();




            x.Bind<IPageHelper, PageHelper>();
            x.Bind<ILinkHelper, LinkHelper>();

            //!!!!!!!! JUST FOR TESTING... !!!!!!!!!
            x.Bind(new StoreInformationSettings());
            x.Bind(new TaxSettings());
            x.Bind(new CurrencySettings());
            x.Bind(new LocalizationSettings());
            x.Bind(new CustomerSettings());
            x.Bind(new CommonSettings());
            x.Bind(new CatalogSettings());
            x.Bind(new SeoSettings());
            x.Bind(new MediaSettings());
            x.Bind<ISettingService, SettingService>();

            x.Bind<IUserAgentHelper, UserAgentHelper>();
            x.Bind<IWebHelper, WebHelper>();

            /*x.Bind<IWorkContext, WebWorkContext>();*/
            x.Bind<IStoreContext, WebStoreContext>();

            x.Bind<ICategories, BrigitaCategories>();
            x.Bind<IScopedCategories, ScopedCategories>();

            x.Bind<IProducts, BrigitaProducts>();


            x.Bind<ICustomerService, CustomerService>();
            x.Bind<IVendorService, VendorService>();
            x.Bind<IStoreService, BrigitaStores>();
            x.Bind<IAuthenticationService, FormsAuthenticationService>();
            x.Bind<ILanguageService, LanguageService>();
            x.Bind<ICurrencyService, CurrencyService>();
            x.Bind<IStoreMappingService, StoreMappingService>();

            x.Bind<IPageHeadBuilder, PageHeadBuilder>();


            //data layer
            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();
            x.Bind<DataSettings>(c => dataSettingsManager.LoadSettings());

            x.BindTransient<BaseDataProviderManager, EfDataProviderManager>();
            x.BindTransient<IDataProvider>(c => c.Resolve<BaseDataProviderManager>().LoadDataProvider());

            if(dataProviderSettings != null && dataProviderSettings.IsValid()) {
                var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
                var dataProvider = efDataProviderManager.LoadDataProvider();
                dataProvider.InitConnectionFactory();

                x.Bind<IDbContext>(c => new NopObjectContext(dataProviderSettings.DataConnectionString, false, false));
            }
            else {
                x.Bind<IDbContext>(c => new NopObjectContext(dataSettingsManager.LoadSettings().DataConnectionString, false, false));
            }

            x.BindGeneric(typeof(IRepository<>), typeof(EfRepository<>));



            //all entities taken from the db should be auto cached, 


            var controllerTypes = scanner.ScanTypes(typeof(Registrar).Assembly)
                                            .Where(t => !t.IsAbstract
                                                        && typeof(IController).IsAssignableFrom(t));

            foreach(var type in controllerTypes) {
                x.Bind(type, type);
            }

        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:101,代码来源:Registrar.cs


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