本文整理汇总了C#中Autofac.ContainerBuilder.RegisterDecorator方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.RegisterDecorator方法的具体用法?C# ContainerBuilder.RegisterDecorator怎么用?C# ContainerBuilder.RegisterDecorator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autofac.ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder.RegisterDecorator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
protected override void Load(ContainerBuilder builder)
{
//TvTamer.Core Types
builder.Register(c => ConfigurationManager.GetSection("episodeProcessorSettings") as EpisodeProcessorSettings);
builder.Register(c => ConfigurationManager.GetSection("scheduleSettings") as ScheduleSettings);
builder.Register(c => ConfigurationManager.GetSection("torrentSearchSettings") as TorrentSearchSettings);
builder.RegisterType<TvDbSearchService>().As<ITvSearchService>();
builder.RegisterType<DatabaseUpdater>().As<IDatabaseUpdater>();
builder.RegisterType<EpisodeDownloader>().As<IEpisodeDownloader>();
builder.RegisterType<WebClient>().As<IWebClient>();
builder.RegisterType<TvContext>().As<ITvContext>();
builder.RegisterType<TvService>().As<ITvService>();
builder.RegisterType<FileSystem>().As<IFileSystem>();
builder.RegisterType<AnalyticsService>().As<IAnalyticsService>();
builder.RegisterType<EpisodeProcessor>().As<IEpisodeProcessor>();
//Search Provider Registration
builder.RegisterType<NullSearchProvider>().Named<ISearchProvider>("searchProvider");
builder.RegisterDecorator<ISearchProvider>((c, inner) => new KickassSearchProvider(inner, c.Resolve<IWebClient>(), c.Resolve<IAnalyticsService>()),
fromKey: "searchProvider");
builder.RegisterType<TvTamerService>();
}
示例2: Load
protected override void Load(ContainerBuilder moduleBuilder)
{
base.Load(moduleBuilder);
moduleBuilder
.Register<ProxyImplementation>(c => new ProxyImplementation(
c.Resolve<InterfaceType.Factory>(),
c.Resolve<Zetbox.API.Client.ZetboxService.IZetboxService>(),
c.Resolve<IPerfCounter>(),
c.Resolve<ZetboxStreamReader.Factory>(),
c.Resolve<ZetboxStreamWriter.Factory>()
))
.Named<IProxy>("implementor")
.InstancePerDependency(); // No singleton!
moduleBuilder
.RegisterDecorator<IProxy>(
(c, inner) => new InfoLoggingProxyDecorator(inner),
"implementor");
moduleBuilder
.Register<ClientDeploymentRestrictor>(c => new ClientDeploymentRestrictor())
.As<IDeploymentRestrictor>()
.SingleInstance();
moduleBuilder
.RegisterModule<Log4NetAppender.Module>();
moduleBuilder
.RegisterType<PerfCounterDispatcher>()
.As<IPerfCounter>()
.OnActivated(args => args.Instance.Initialize(args.Context.Resolve<IFrozenContext>()))
.OnRelease(obj => obj.Dump())
.SingleInstance();
}
示例3: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<TaskService>().Named<ITaskService>("taskService");
builder.RegisterDecorator<ITaskService>(inner => new LoggingTaskService(inner), fromKey: "taskService");
builder.RegisterControllers(typeof(CompositionModule).Assembly);
}
示例4: RegisterModel
private static void RegisterModel(ContainerBuilder builder)
{
builder
.RegisterDecorator<ITransferStatisticsFactory>((c, f) => new ObservableErrorsTransferStatisticsFactory(f))
.As<ITransferStatisticsFactory>();
builder
.RegisterType<DataAdapterConfigurationProvidersCollection>()
.As<IDataAdapterConfigurationProvidersCollection>()
.InstancePerLifetimeScope();
builder
.RegisterType<CommandLineProvider>()
.As<ICommandLineProvider>()
.SingleInstance();
builder
.RegisterType<DataTransferModel>()
.As<IDataTransferModel>()
.InstancePerLifetimeScope();
builder
.RegisterType<NavigationService>()
.As<INavigationService>()
.InstancePerLifetimeScope();
builder
.RegisterType<ErrorHandler>()
.As<IErrorHandler>()
.SingleInstance();
}
示例5: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<FixItQueueManager>().As<IFixItQueueManager>();
builder.RegisterType<PhotoService>().As<IPhotoService>();
builder.RegisterType<MyFixItContext>().AsSelf();
builder.RegisterType<FixItTaskRepository>().Named<IFixItTaskRepository>("fixitRepo");
builder.RegisterDecorator<IFixItTaskRepository>((c, inner) => new LoggingFixtItRepository(inner, c.Resolve<ILogger>()), fromKey: "fixitRepo");
}
示例6: Load
protected override void Load(ContainerBuilder builder)
{
MessageQueue.EnableConnectionCache = true;
// Register the specified message bus infrastructure.
switch (MessageBusType)
{
case MessageBusType.Inline:
builder.RegisterType<DirectMessageSender<EventEnvelope>>().AsSelf().As<ISendMessages<EventEnvelope>>().SingleInstance().AutoActivate();
break;
case MessageBusType.Optimistic:
builder.RegisterType<OptimisticMessageSender<EventEnvelope>>().AsSelf().As<ISendMessages<EventEnvelope>>().SingleInstance();
break;
case MessageBusType.MicrosoftMessageQueuing:
PurgeMessageQueue("processing", "poison");
builder.Register(resolver => new MessageSender<EventEnvelope>(MessageQueuePath, resolver.Resolve<ISerializeObjects>())).AsSelf().As<ISendMessages<EventEnvelope>>().SingleInstance().AutoActivate();
builder.Register(resolver => new MessageReceiver<EventEnvelope>(MessageQueuePath, resolver.Resolve<ISerializeObjects>(), resolver.Resolve<IProcessMessages<EventEnvelope>>())).AsSelf().SingleInstance().AutoActivate();
break;
default:
throw new NotSupportedException();
}
// Register common eventing infrastructure.
builder.RegisterType<TimeoutDispatcher>().As<PipelineHook>().SingleInstance();
builder.RegisterType<EventHandlerRegistry>().As<IRetrieveEventHandlers>().SingleInstance();
builder.RegisterType<EventPublisher>().Named<IPublishEvents>("EventPublisher").SingleInstance();
builder.RegisterType<EventProcessor>().Named<IProcessMessages<EventEnvelope>>("EventProcessor").SingleInstance();
// Register all event handlers.
builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()).Where(type => type.GetCustomAttribute<EventHandlerAttribute>() != null);
// Register data store infrastructure.
builder.RegisterType<SqlSagaStoreDialect>().AsSelf().As<ISagaStoreDialect>().SingleInstance();
builder.RegisterType<SqlSagaStore>().AsSelf().Named<IStoreSagas>("SagaStore").SingleInstance();
// Register decorators.
builder.RegisterDecorator<IStoreSagas>((context, sagaStore) => new BenchmarkedSagaStore(sagaStore, context.Resolve<Statistics>()), "SagaStore").Named<IStoreSagas>("BenchmarkedSagaStore").SingleInstance();
builder.RegisterDecorator<IStoreSagas>((context, sagaStore) => new CachedSagaStore(sagaStore), "BenchmarkedSagaStore").Named<IStoreSagas>("CachedSagaStore").SingleInstance();
builder.RegisterDecorator<IStoreSagas>((context, sagaStore) => new HookableSagaStore(sagaStore, context.Resolve<IEnumerable<PipelineHook>>()), "CachedSagaStore").As<IStoreSagas>().SingleInstance();
builder.RegisterDecorator<IPublishEvents>((context, eventPublisher) => new EventPublisherWrapper(eventPublisher, context.Resolve<Statistics>()), "EventPublisher").As<IPublishEvents>().SingleInstance();
builder.RegisterDecorator<IProcessMessages<EventEnvelope>>((context, eventProcessor) => new EventProcessorWrapper(eventProcessor, context.Resolve<Statistics>()), "EventProcessor").As<IProcessMessages<EventEnvelope>>().SingleInstance();
}
示例7: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<SerilogWrapper>()
.As<ILogger>()
.InstancePerLifetimeScope();
builder.Register(CreateLogger)
.Named<Serilog.ILogger>("Logger")
.SingleInstance();
builder.RegisterDecorator<Serilog.ILogger>((c, l) => l.ForContext("scope", new { Type = "global" }), "Logger")
.InstancePerLifetimeScope();
}
示例8: Load
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterDecorator<ITask>(
(c, t) => new TransactedTask(t, c.Resolve<ITransactionContext>()),
fromKey: null,
toKey: TransactedTaskServiceName);
builder.Register(c => new TaskRunner(
c.ResolveNamed<IEnumerable<Meta<TaskFactory,ITaskMetadata>>>(TransactedTaskServiceName),
c.Resolve<ILog<TaskRunner>>()))
.As<ITaskRunner>();
}
示例9: RegisterEventHandlers
private void RegisterEventHandlers(ContainerBuilder builder)
{
foreach (EventElement eventElement in this.settings.Events)
{
builder.RegisterType<BuildCompletedEventHandler>()
.Keyed<IEventHandler>(eventElement.Id + "_1")
.WithMetadata("id", eventElement.Id)
.WithMetadata("event", eventElement.Name)
.WithMetadata("filter", eventElement.Filter); //"\\" + buildCompletedEventElement.TeamProject + "\\" + buildCompletedEventElement.BuildDefinition
builder.RegisterDecorator<IEventHandler>(i => new ExecuteScript(i), fromKey: eventElement.Id + "_1", toKey: eventElement.Id + "_2");
builder.RegisterDecorator<IEventHandler>((c, i) => new EventLogger(i, c.Resolve<ILog>()), fromKey: eventElement.Id + "_2");
//if (eventElement is BuildCompletedEventElement)
//{
// var buildCompletedEventElement = eventElement as BuildCompletedEventElement;
//}
}
//var eventHandlersMetadata = LoadEventHandlersMetadata();
//foreach (var metadata in eventHandlersMetadata)
//{
// if (true)
// {
// builder.RegisterDecorator<IEventHandler>(i => new ExecuteScript(i), fromKey: metadata.Id + "_1", toKey: metadata.Id + "_2");
// }
// if (true)
// {
// builder.RegisterDecorator<IEventHandler>((c, i) => new EventLogger(i, c.Resolve<ILog>()), fromKey: metadata.Id + "_2");
// }
//}
}
示例10: RegisterApiServices
private static void RegisterApiServices(IConfigurationService configService, ContainerBuilder builder)
{
var usersApiUri = configService.GetSetting<string>("UsersApiUri", null);
var identityServerUri = configService.GetSetting<string>("IdentityServerUri", null);
builder.RegisterType<UsersApiUserService>().As<IUserService>()
.WithParameter("usersApiUri", usersApiUri)
.WithParameter("identityServerUri", identityServerUri);
builder.RegisterType<X509SignedTokenProvider>()
.WithParameter("cert", Cert.Load(typeof(IOwinBootstrapper).Assembly, "Cert", "idsrv3test.pfx", "idsrv3test"))
.Named<ITokenProvider>("tokenProvider");
builder.RegisterDecorator<ITokenProvider>(p => new CachingTokenProvider(p), "tokenProvider");
builder.RegisterType<UsersApiIdentityManagerService>().As<IIdentityManagerService>()
.WithParameter("usersApiUri", usersApiUri)
.WithParameter("identityServerUri", identityServerUri);
}
示例11: Load
/// <summary>
/// Adds DAL module components registrations.
/// </summary>
/// <param name="builder">The container builder.</param>
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<WeatherNsuRuTemperatureProvider>()
.FindConstructorsWith(AnyConstructorFinder.Instance)
.Named<ITemperatureProvider>("DataOrigin")
.As<ITemperatureDataSource>();
builder.RegisterType<WeatherNsuRuTemperatureParser>().AsImplementedInterfaces()
.FindConstructorsWith(AnyConstructorFinder.Instance);
builder.RegisterDecorator<ITemperatureProvider>(
(ctx, p) => new CachedTemperatureProvider(ctx.Resolve<ITemperatureHistoryRepository>(), p),
"DataOrigin");
builder.RegisterType<TemperatureHistoryRepository>().AsImplementedInterfaces();
builder.RegisterType<TemperatureSyncService>().FindConstructorsWith(AnyConstructorFinder.Instance)
.AsImplementedInterfaces();
}
示例12: EventProjections
private static void EventProjections(ContainerBuilder cb)
{
cb.RegisterType<InMemoryEventStore>()
.Named<IEventStore>("implementor")
.SingleInstance();
cb.RegisterDecorator<IEventStore>(
(c, inner) => new DelegatingEventStore(inner, c.Resolve<IEnumerable<IEventListner>>()),
fromKey: "implementor");
cb.RegisterType<GameDetailsProjection>()
.AsSelf()
.AsImplementedInterfaces()
.SingleInstance();
cb.RegisterType<OpenGamesProjection>()
.AsSelf()
.AsImplementedInterfaces()
.SingleInstance();
}
示例13: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<LocalizationService>().As<ILocalizationService>().SingleInstance();
builder.RegisterType<ResourceStringProvider>().As<IResourceStringProvider>().SingleInstance();
builder.RegisterType<DatabaseInsertLanguageService>().As<IDatabaseInsertService>().SingleInstance();
builder.RegisterType<LocaleResourceKeyGetAllQueryHandler>().As<IQueryHandler<LocaleResourceKeyGetAllQuery, IEnumerable<LocaleResourceKey>>>().SingleInstance();
builder.RegisterType<UpdateLocaleResourceCommandHandler>().As<ICommandHandler<UpdateLocaleResourceCommand>>().SingleInstance();
builder.RegisterType<LocaleResourceGetByKeyQueryHandler>().As<IQueryHandler<LocaleResourceGetByKeyQuery, LocaleResource>>().SingleInstance();
builder.RegisterType<LanguageGetByKeyQueryHandler>().As<IQueryHandler<LanguageGetByKeyQuery, Language>>().SingleInstance();
builder.RegisterType<LocaleResourceRowProcessor>().As<IRowProcessor<LocaleResourceRow>>().SingleInstance();
builder.RegisterType<LanguageService>().As<ILanguageService>().SingleInstance();
builder.RegisterType<LocalizationsDatabaseStore>().Named<ILocalizationsDatabaseStore>(LocalizationsStore);
builder.RegisterDecorator<ILocalizationsDatabaseStore>(
(c, inner) => new LocalizationsFromDatabaseStoreCached(new Lazy<ILocalizationsDatabaseStore>(() => inner),
c.Resolve<ICacheWrapper>(),
c.Resolve<ILocalizationCacheParameters>()), LocalizationsStore);
base.Load(builder);
}
示例14: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<NHibernateApplicationRepository>()
.As<IApplicationRepository>();
builder.Register(
c =>
new NHibernateConfiguration(ConfigurationManager.ConnectionStrings["ConfigCentral"].ConnectionString))
.SingleInstance();
builder.Register(c => c.Resolve<NHibernateConfiguration>()
.Configure())
.SingleInstance();
builder.Register(c => c.Resolve<Configuration>()
.BuildSessionFactory())
.As<ISessionFactory>()
.SingleInstance();
builder.Register(c => c.Resolve<ISessionFactory>()
.OpenSession())
.Named<ISession>("default")
.OnActivated(args => { args.Instance.FlushMode = FlushMode.Commit; })
.InstancePerLifetimeScope();
builder.Register(c => new NHibernateUnitOfWork(c.ResolveNamed<ISession>("default")))
.Named<NHibernateUnitOfWork>("default")
.InstancePerLifetimeScope();
builder.RegisterDecorator<NHibernateUnitOfWork>(
(c, inner) => new SqlServerCe40ExceptionTranslatingDecorator(inner),
fromKey: "default")
.As<NHibernateUnitOfWork>()
.As<IUnitOfWork>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<NHibernateUnitOfWork>().Session)
.As<ISession>()
.ExternallyOwned()
.InstancePerLifetimeScope();
}
示例15: Load
protected override void Load(ContainerBuilder builder)
{
MessageQueue.EnableConnectionCache = true;
// Register the specified message bus infrastructure.
switch (MessageBusType)
{
case MessageBusType.Inline:
builder.RegisterType<DirectMessageSender<CommandEnvelope>>().AsSelf().As<ISendMessages<CommandEnvelope>>().SingleInstance().AutoActivate();
break;
case MessageBusType.Optimistic:
builder.RegisterType<OptimisticMessageSender<CommandEnvelope>>().AsSelf().As<ISendMessages<CommandEnvelope>>().SingleInstance();
break;
case MessageBusType.MicrosoftMessageQueuing:
PurgeMessageQueue("processing", "poison");
builder.Register(resolver => new MessageSender<CommandEnvelope>(MessageQueuePath, resolver.Resolve<ISerializeObjects>())).AsSelf().As<ISendMessages<CommandEnvelope>>().SingleInstance().AutoActivate();
builder.Register(resolver => new MessageReceiver<CommandEnvelope>(MessageQueuePath, resolver.Resolve<ISerializeObjects>(), resolver.Resolve<IProcessMessages<CommandEnvelope>>())).AsSelf().SingleInstance().AutoActivate();
break;
default:
throw new NotSupportedException();
}
// Register common commanding infrastructure.
builder.RegisterType<CommandHandlerRegistry>().As<IRetrieveCommandHandlers>().SingleInstance();
builder.RegisterType<CommandPublisher>().Named<IPublishCommands>("CommandPublisher").SingleInstance();
builder.RegisterType<CommandProcessor>().Named<IProcessMessages<CommandEnvelope>>("CommandProcessor").SingleInstance();
// Register data store infrastructure.
builder.RegisterType<SqlEventStoreDialect>().AsSelf().As<IEventStoreDialect>().SingleInstance();
builder.RegisterType<SqlEventStore>().AsSelf().Named<IStoreEvents>("EventStore").SingleInstance();
builder.RegisterType<SqlSnapshotStoreDialect>().AsSelf().As<ISnapshotStoreDialect>().SingleInstance();
builder.RegisterType<SqlSnapshotStore>().AsSelf().Named<IStoreSnapshots>("SnapshotStore").SingleInstance();
builder.RegisterType<AggregateUpdater>().AsSelf().As<IApplyEvents>().SingleInstance();
builder.RegisterType<AggregateStore>().AsSelf().Named<IStoreAggregates>("AggregateStore").SingleInstance();
// Register decorators.
builder.RegisterType<CommandHook>().AsSelf().As<PipelineHook>().SingleInstance();
builder.RegisterType<EventDispatcher>().AsSelf().As<PipelineHook>().SingleInstance();
builder.RegisterDecorator<IStoreAggregates>((context, aggregateStore) => new CachedAggregateStore(aggregateStore), "AggregateStore").Named<IStoreAggregates>("CachedAggregateStore").SingleInstance();
builder.RegisterDecorator<IStoreAggregates>((context, aggregateStore) => new HookableAggregateStore(aggregateStore, context.Resolve<IEnumerable<PipelineHook>>()), "CachedAggregateStore").As<IRetrieveAggregates>().As<IStoreAggregates>().SingleInstance();
builder.RegisterDecorator<IStoreSnapshots>((context, snapshotStore) => new BenchmarkedSnapshotStore(snapshotStore, context.Resolve<Statistics>()), "SnapshotStore").As<IStoreSnapshots>().SingleInstance();
builder.RegisterDecorator<IStoreEvents>((context, eventStore) => new BenchmarkedEventStore(eventStore, context.Resolve<Statistics>()), "EventStore").As<IStoreEvents>().SingleInstance();
builder.RegisterDecorator<IPublishCommands>((context, commandPublisher) => new CommandPublisherWrapper(commandPublisher, context.Resolve<Statistics>()), "CommandPublisher").As<IPublishCommands>().SingleInstance();
builder.RegisterDecorator<IProcessMessages<CommandEnvelope>>((context, commandProcessor) => new CommandProcessorWrapper(commandProcessor, context.Resolve<Statistics>()), "CommandProcessor").As<IProcessMessages<CommandEnvelope>>().SingleInstance();
}