本文整理汇总了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);
}
}
示例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);
}
}