本文整理汇总了C#中ITypeFinder类的典型用法代码示例。如果您正苦于以下问题:C# ITypeFinder类的具体用法?C# ITypeFinder怎么用?C# ITypeFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeFinder类属于命名空间,在下文中一共展示了ITypeFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//controllers
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//data access
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
//todo:暂时把连接字符串写死,测试时使用
//dataProviderSettings.DataConnectionString = @"Data Source=(localdb)\ProjectsV12;Initial Catalog=FzrainFramework;attachdbfilename=E:\MyFramework\Fzrain.Framework\Fzrain.Web\App_Data\FzrainFramework.mdf;Integrated Security=True;Persist Security Info=False;";
//dataProviderSettings.DataProvider = "sqlserver";
builder.Register(c => dataProviderSettings).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(dataProviderSettings);
var dataProvider = efDataProviderManager.LoadDataProvider();
dataProvider.InitConnectionFactory();
builder.Register<IDbContext>(c => new FzrainContext(dataProviderSettings.DataConnectionString)).InstancePerLifetimeScope();
}
else
{
builder.Register<IDbContext>(c => new FzrainContext(dataSettingsManager.LoadSettings().DataConnectionString)).InstancePerLifetimeScope();
}
//repository
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
//service
builder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
builder.RegisterType<LolService>().As<ILolService>().InstancePerLifetimeScope();
builder.RegisterType<SettingService>().As<ISettingService>().InstancePerLifetimeScope();
}
示例2: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//webworkcontenxt 上下文注入
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
//bll 注入
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//用户身份认证
builder.RegisterType<AuthenticationService>().As<IAuthenticationService>().InstancePerHttpRequest();
//验证码管理器
builder.RegisterType<DefaultCaptchaManager>().As<ICaptchaManager>().SingleInstance();
//缓存注册
//builder.Register(c => new DefaultCacheService(new RuntimeMemoryCache(), 1.0f))
// .As<ICacheService>()
// .SingleInstance();
//cachemanager注入
//系统日志注入
builder.RegisterType<Log4NetLoggerFactoryAdapter>().As<ILoggerFactoryAdapter>().SingleInstance();
builder.RegisterType<CacheManagerFactoryAdapter>().As<ICacheManagerFactoryAdapter>().SingleInstance();
//所有的controllers 注入
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//数据层注入
var configstrategy = new ConfigStrategy();
var RDBSConfigInfo = configstrategy.GetRDBSConfigInfo();
builder.Register<IDbContext>(
c => new ShepherdsFrameworkDbContext(RDBSConfigInfo.RDBSConnectionString))
.InstancePerLifetimeScope();
//泛型注入
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
}
示例3: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, bool isActiveModule)
{
if (isActiveModule)
{
builder.RegisterType<PayPalExpressCheckoutFilter>().AsActionFilterFor<CheckoutController>(x => x.PaymentMethod()).InstancePerRequest();
}
}
示例4: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//所有的controllers 注入
}
示例5: 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);
}
示例6: ControllerMapper
public ControllerMapper(ITypeFinder typeFinder, IContentTypeManager definitionManager, IKernel kernel)
{
IList<ControlsAttribute> controllerDefinitions = FindControllers(typeFinder);
foreach (ContentType id in definitionManager.GetContentTypes())
{
IAdapterDescriptor controllerDefinition = GetControllerFor(id.ItemType, controllerDefinitions);
if (controllerDefinition != null)
{
string controllerName = GetControllerName(controllerDefinition.AdapterType, controllerDefinition.AreaName);
ControllerMap[id.ItemType] = controllerDefinition.ControllerName;
AreaMap[id.ItemType] = controllerDefinition.AreaName;
if (!kernel.GetBindings(typeof(IController)).Any(b => b.Metadata.Name == controllerName))
kernel.Bind<IController>().To(controllerDefinition.AdapterType)
.InTransientScope()
.Named(controllerName);
IList<IPathFinder> finders = PathDictionary.GetFinders(id.ItemType);
if (0 == finders.Where(f => f is ActionResolver).Count())
{
// TODO: Get the list of methods from a list of actions retrieved from somewhere within MVC
var methods = controllerDefinition.AdapterType.GetMethods().Select(m => m.Name).ToArray();
var actionResolver = new ActionResolver(this, methods);
PathDictionary.PrependFinder(id.ItemType, actionResolver);
}
}
}
}
示例7: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
builder.Register<IDbContext>(c => new MmDataContext(ConfigurationManager.ConnectionStrings["MmDataContext"].ConnectionString)).InstancePerHttpRequest();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)).InstancePerHttpRequest();
builder.Register(c => new HttpContextWrapper(HttpContext.Current) 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();
//services
builder.RegisterType<FormAuthenticationService>().As<IAuthenticationService>().InstancePerHttpRequest();
builder.RegisterType<UserService>().As<IUserService>().InstancePerHttpRequest();
builder.RegisterType<EmailSender>().As<IEmailSender>().InstancePerHttpRequest();
builder.RegisterType<ArticleService>().As<IArticleService>().InstancePerHttpRequest();
builder.RegisterType<FormatService>().As<IFormatService>().InstancePerHttpRequest();
builder.RegisterType<MaterialService>().As<IMaterialService>().InstancePerHttpRequest();
builder.RegisterType<TagService>().As<ITagService>().InstancePerHttpRequest();
builder.RegisterType<ThingService>().As<IThingService>().InstancePerHttpRequest();
builder.RegisterType<StateService>().As<IStateService>().InstancePerHttpRequest();
}
示例8: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//we cache presentation models between requests
//installation localization service
builder.RegisterType<InstallationLocalizationService>().As<IInstallationLocalizationService>().InstancePerLifetimeScope();
}
示例9: AppObjectReader
public AppObjectReader(IReadObjectsCache readObjects, IApplicationObjectsRepository appObjectRepository,
ITypeFinder typeFinder)
{
this.readObjects = readObjects;
this.appObjectRepository = appObjectRepository;
this.typeFinder = typeFinder;
}
示例10: SetUp
protected override void SetUp()
{
typeFinder = NewMock<ITypeFinder>();
memberReader = NewMock<IMemberReader>();
reader = new ValueTypeReader(memberReader, typeFinder);
}
示例11: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//data layer
builder.Register(x => new EfDataProviderManager(x.Resolve<DataSettings>())).As<BaseDataProviderManager>().InstancePerDependency();
builder.RegisterType(SqlServerDataProvider).As<IDataProvider>().InstancePerDependency();
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
var dataProvider = efDataProviderManager.LoadDataProvider();
dataProvider.InitConnectionFactory();
builder.Register<IDbContext>(c => new NopObjectContext(dataProviderSettings.DataConnectionString)).InstancePerHttpRequest();
}
else
{
builder.Register<IDbContext>(c => new NopObjectContext(dataSettingsManager.LoadSettings().DataConnectionString)).InstancePerHttpRequest();
}
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerHttpRequest();
////builder.RegisterType<ContentService>().As<IContentService>().InstancePerHttpRequest();
////builder.RegisterType<NodeService>().As<INodeService>().InstancePerHttpRequest();
}
示例12: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, HeliosConfig config)
{
builder.RegisterType<PerRequestCacheManager>()
.As<ICacheManager>()
.Named<ICacheManager>("helios_cache_per_request")
.InstancePerLifetimeScope();
}
示例13: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
// we need to set up the cryptography internal services
builder.RegisterType<HashService>().As<IHashService>().InstancePerDependency();
builder.RegisterType<AESService>().As<IAESService>().InstancePerDependency();
builder.RegisterType<RijndaelEnhancedService>().As<IRijndaelEnhancedService>().InstancePerDependency();
}
示例14: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
{
var asm = AppDomain.CurrentDomain.GetAssemblies();
builder.RegisterGeneric(typeof(BaseEntityService<>)).As(typeof(IBaseEntityService<>)).InstancePerLifetimeScope();
builder.RegisterGeneric(typeof(BaseEntityWithPictureService<,>)).As(typeof(IBaseEntityWithPictureService<,>)).InstancePerLifetimeScope();
builder.RegisterType<MobPageHeadBuilder>().As<MobPageHeadBuilder>().InstancePerRequest();
//register all the implemented services in various mob plugins
builder.RegisterAssemblyTypes(asm).AsClosedTypesOf(typeof(BaseEntityService<>))
.AsImplementedInterfaces()
.InstancePerDependency();
builder.RegisterAssemblyTypes(asm).AsClosedTypesOf(typeof(BaseEntityWithPictureService<,>))
.AsImplementedInterfaces()
.InstancePerDependency();
//register all the repositories
builder.RegisterGeneric(typeof(MobRepository<>)).As(typeof(IMobRepository<>))
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(ContextName))
.InstancePerLifetimeScope();
}
示例15: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<PromoUtilities>().As<IPromoUtilities>().InstancePerLifetimeScope();
builder.RegisterType<AttributeValueService>().As<IAttributeValueService>().InstancePerLifetimeScope();
builder.RegisterType<ProductMappingService>().As<IProductMappingService>().InstancePerLifetimeScope();
builder.RegisterType<PromoDetailService>().As<IPromoDetailService>().InstancePerLifetimeScope();
builder.RegisterType<ProductPromoMappingService>().As<IProductPromoMappingService>().InstancePerLifetimeScope();
builder.RegisterType<PromoPictureService>().As<IPromoPictureService>().InstancePerLifetimeScope();
builder.RegisterType<PromoBannerService>().As<IPromoBannerService>().InstancePerLifetimeScope();
builder.RegisterType<EfRepository<ProductMappingItem>>()
.As<IRepository<ProductMappingItem>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<AttributeValueMappingItem>>()
.As<IRepository<AttributeValueMappingItem>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<ProductAttributeConfigItem>>()
.As<IRepository<ProductAttributeConfigItem>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PromoDetail>>()
.As<IRepository<PromoDetail>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<ProductPromotionMapping>>()
.As<IRepository<ProductPromotionMapping>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PromoPicture>>()
.As<IRepository<PromoPicture>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PromoBanner>>()
.As<IRepository<PromoBanner>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PromoBannerPicture>>()
.As<IRepository<PromoBannerPicture>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<PromoBannerWidgetZone>>()
.As<IRepository<PromoBannerWidgetZone>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<IssuedCoupon>>()
.As<IRepository<IssuedCoupon>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_promo"))
.InstancePerLifetimeScope();
}