本文整理汇总了C#中SimpleInjector.Container.InterceptWith方法的典型用法代码示例。如果您正苦于以下问题:C# Container.InterceptWith方法的具体用法?C# Container.InterceptWith怎么用?C# Container.InterceptWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleInjector.Container
的用法示例。
在下文中一共展示了Container.InterceptWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitContanier
private static Container InitContanier()
{
var container = new Container();
container.Register<ILogger, ConsoleLogger>();
container.Register<ICredit, Credit>();
//container.Register<IInterceptor,PerformanceLoggingInterceptor>();
container.InterceptWith<PerformanceLoggingInterceptor>(type => type== typeof(ICredit));
return container;
}
示例2: Prepare
public override void Prepare()
{
this.container = new SimpleInjector.Container();
this.container.RegisterSingle<ISingleton, Singleton>();
this.container.Register<ITransient, Transient>();
this.container.Register<ICombined, Combined>();
this.container.Register<ICalculator, Calculator>();
container.InterceptWith<SimpleInjectorInterceptionLogger>(type => type == typeof(ICalculator));
this.container.Verify();
}
示例3: InitializeContainer
private static void InitializeContainer(Container container)
{
// Infrastructure
container.Register<IApiConfigurationProvider, AzureApiConfigurationProvider>();
container.Register<IMappingEngine, MappingEngine>(Lifestyle.Singleton);
container.Register<IMapper, PortalMapper>(Lifestyle.Singleton);
container.Register<IConfigurationProvider, ConfigurationProvider>();
container.Register<IPortalSettings, PortalSettings>();
// DAL Infrastructure
container.Register(() => new MongoUrl(container.GetInstance<IApiConfigurationProvider>().MongoConnectionString));
container.RegisterSingle<ITrackingUrlIdGenerator, TrackingUrlIdGenerator>();
// DAL
container.Register<IRepositoryFactory, RepositoryFactory>();
container.Register<ITrackingUrlRepository, TrackingUrlRepository>();
container.Register<ITrackingStatRepository, TrackingStatRepository>();
container.Register<IBalanceHistoryRepository, BalanceHistoryRepository>();
container.Register<ICompanyRepository, CompanyRepository>();
// BLL Infrastructure
container.Register<IUrlShortenerService, UrlShortenerService>(Lifestyle.Singleton);
container.Register<IProjectUriProvider>(() => new ProjectUriProvider(
container.GetInstance<IApiConfigurationProvider>().ProjectBaseUri), Lifestyle.Singleton);
// Email
container.Register(() => container.GetInstance<IPortalSettings>().MailSettings);
container.Register<IEmailInitializer, EmailInitializer>();
container.Register<IEmailFactory, SmtpEmailFactory>();
container.Register<IMailerRepository, MailerRepository>();
container.Register<IStringEncryptor, StringEncryptor>();
container.Register<IEmailSenderService, EmailSenderService>();
// BLL
container.Register<IBalanceService, BalanceService>();
container.Register<IUrlTrackingService, UrlTrackingService>();
container.Register<IUrlTrackingStatService, UrlTrackingStatService>();
container.Register<ICompanyService, CompanyService>();
container.Register<ISubscriptionService, SubscriptionService>();
// BLL Billing
container.Register<IBillingCardService>(
() =>
new StripeBillingCardService(container.GetInstance<IApiConfigurationProvider>().StripeApiKey,
container.GetInstance<IMapper>()));
container.Register<IBillingChargeService>(
() =>
new StripeBillingChargeService(container.GetInstance<IApiConfigurationProvider>().StripeApiKey,
container.GetInstance<IMapper>()));
container.Register<IBillingCustomerService>(
() =>
new StripeBillingCustomerService(container.GetInstance<IApiConfigurationProvider>().StripeApiKey,
container.GetInstance<IMapper>()));
container.Register<IBillingEventService>(
() =>
new StripeBillingEventService(container.GetInstance<IApiConfigurationProvider>().StripeApiKey,
container.GetInstance<IMapper>()));
// Interceptions
container.InterceptWith<UrlTrackingServiceStatInterceptor>(type => type == typeof (IUrlTrackingService));
container.RegisterSingle<UrlTrackingServiceStatInterceptor>();
}