/// <summary> /// Composes services by adding services to the <paramref name="serviceRegistry"/>. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register <IColumnSelector, ColumnSelector>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IColumnSelector), typeof(CachedColumnSelector)); serviceRegistry.Register <IConstructorSelector, ConstructorSelector>(new SingletonLifetime()); serviceRegistry.Decorate(typeof(IConstructorSelector), typeof(CachedConstructorSelector)); serviceRegistry.Register(typeof(IDataReaderMapper <>), typeof(DataReaderMapper <>)); serviceRegistry.Register(typeof(IDataRecordMapper <>), typeof(DataRecordMapper <>), new PerGraphLifetime()); serviceRegistry.Register <IKeyDelegateBuilder, KeyDelegateBuilder>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IKeyDelegateBuilder), typeof(CachedKeyDelegateBuilder)); serviceRegistry.Register(typeof(IInstanceDelegateBuilder <>), typeof(InstanceDelegateBuilder <>), new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IInstanceDelegateBuilder <>), typeof(CachedInstanceDelegateBuilder <>)); serviceRegistry.Register <IOrdinalSelector, OrdinalSelector>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IOrdinalSelector), typeof(CachedOrdinalSelector)); serviceRegistry.Register(typeof(IRelationDelegateBuilder <>), typeof(ManyToOneDelegateBuilder <>), "ManyToOneDelegateBuilder", new PerGraphLifetime()); serviceRegistry.Register(typeof(IRelationDelegateBuilder <>), typeof(OneToManyDelegateBuilder <>), "OneToManyDelegateBuilder", new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IRelationDelegateBuilder <>), typeof(CachedRelationDelegateBuilder <>)); serviceRegistry.Register(typeof(IInstanceExpressionBuilder <>), typeof(InstanceExpressionBuilder <>)); serviceRegistry.Register(typeof(IMapperDelegateBuilder <>), typeof(ConstructorMapperDelegateBuilder <>), "ConstructorMapperDelegateBuilder", new SingletonLifetime()); serviceRegistry.Register(typeof(IMapperDelegateBuilder <>), typeof(PropertyMapperDelegateBuilder <>), "PropertyMapperDelegateBuilder", new SingletonLifetime()); serviceRegistry.Register(typeof(IMethodSkeleton <>), typeof(DynamicMethodSkeleton <>)); serviceRegistry.Register <IMethodSelector, MethodSelector>(new SingletonLifetime()); serviceRegistry.Decorate(typeof(IMethodSelector), typeof(CachedMethodSelector)); serviceRegistry.Register(typeof(IManyToOneDelegateBuilder <>), typeof(ManyToOneDelegateBuilder <>)); serviceRegistry.Register <Interfaces.IPropertySelector, Implementation.PropertySelector>(new SingletonLifetime()); serviceRegistry.Register <Interfaces.IPropertySelector, ComplexPropertySelector>("ComplexPropertySelector", new SingletonLifetime()); serviceRegistry.Register <Interfaces.IPropertySelector, CollectionPropertySelector>("CollectionPropertySelector", new SingletonLifetime()); serviceRegistry.Decorate(typeof(Interfaces.IPropertySelector), typeof(CachedPropertySelector)); serviceRegistry.Register <IPropertyMapper, PropertyMapper>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IPropertyMapper), typeof(CachedPropertyMapper)); serviceRegistry.Register <IMapperDelegateBuilder <IStructuralEquatable>, ConstructorMapperDelegateBuilder <IStructuralEquatable> >("keyInstanceEmitter"); serviceRegistry.Register <IOneToManyExpressionBuilder>( factory => new OneToManyExpressionBuilder( factory.GetInstance <IPropertyMapper>(), factory.GetInstance <Interfaces.IPropertySelector>("CollectionPropertySelector"), type => factory.GetInstance(type))); serviceRegistry.Register <IManyToOneExpressionBuilder>( factory => new ManyToOneExpressionBuilder( factory.GetInstance <IPropertyMapper>(), factory.GetInstance <Interfaces.IPropertySelector>("ComplexPropertySelector"), type => factory.GetInstance(type))); serviceRegistry.Decorate(typeof(IMapperDelegateBuilder <>), typeof(CachedMapperDelegateBuilder <>)); }
/// <summary> /// Composes services by adding services to the <paramref name="serviceRegistry"/>. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register<IColumnSelector, ColumnSelector>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IColumnSelector), typeof(CachedColumnSelector)); serviceRegistry.Register<IConstructorSelector, ConstructorSelector>(new SingletonLifetime()); serviceRegistry.Decorate(typeof(IConstructorSelector), typeof(CachedConstructorSelector)); serviceRegistry.Register(typeof(IDataReaderMapper<>), typeof(DataReaderMapper<>)); serviceRegistry.Register(typeof(IDataRecordMapper<>), typeof(DataRecordMapper<>), new PerGraphLifetime()); serviceRegistry.Register<IKeyDelegateBuilder, KeyDelegateBuilder>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IKeyDelegateBuilder), typeof(CachedKeyDelegateBuilder)); serviceRegistry.Register(typeof(IInstanceDelegateBuilder<>), typeof(InstanceDelegateBuilder<>), new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IInstanceDelegateBuilder<>), typeof(CachedInstanceDelegateBuilder<>)); serviceRegistry.Register<IOrdinalSelector, OrdinalSelector>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IOrdinalSelector), typeof(CachedOrdinalSelector)); serviceRegistry.Register(typeof(IRelationDelegateBuilder<>), typeof(ManyToOneDelegateBuilder<>), "ManyToOneDelegateBuilder", new PerGraphLifetime()); serviceRegistry.Register(typeof(IRelationDelegateBuilder<>), typeof(OneToManyDelegateBuilder<>), "OneToManyDelegateBuilder", new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IRelationDelegateBuilder<>), typeof(CachedRelationDelegateBuilder<>)); serviceRegistry.Register(typeof(IInstanceExpressionBuilder<>), typeof(InstanceExpressionBuilder<>)); serviceRegistry.Register(typeof(IMapperDelegateBuilder<>), typeof(ConstructorMapperDelegateBuilder<>), "ConstructorMapperDelegateBuilder", new SingletonLifetime()); serviceRegistry.Register(typeof(IMapperDelegateBuilder<>), typeof(PropertyMapperDelegateBuilder<>), "PropertyMapperDelegateBuilder", new SingletonLifetime()); serviceRegistry.Register(typeof(IMethodSkeleton<>), typeof(DynamicMethodSkeleton<>)); serviceRegistry.Register<IMethodSelector, MethodSelector>(new SingletonLifetime()); serviceRegistry.Decorate(typeof(IMethodSelector), typeof(CachedMethodSelector)); serviceRegistry.Register(typeof(IManyToOneDelegateBuilder<>), typeof(ManyToOneDelegateBuilder<>)); serviceRegistry.Register<Interfaces.IPropertySelector, Implementation.PropertySelector>(new SingletonLifetime()); serviceRegistry.Register<Interfaces.IPropertySelector, ComplexPropertySelector>("ComplexPropertySelector", new SingletonLifetime()); serviceRegistry.Register<Interfaces.IPropertySelector, CollectionPropertySelector>("CollectionPropertySelector", new SingletonLifetime()); serviceRegistry.Decorate(typeof(Interfaces.IPropertySelector), typeof(CachedPropertySelector)); serviceRegistry.Register<IPropertyMapper, PropertyMapper>(new PerGraphLifetime()); serviceRegistry.Decorate(typeof(IPropertyMapper), typeof(CachedPropertyMapper)); serviceRegistry.Register<IMapperDelegateBuilder<IStructuralEquatable>, ConstructorMapperDelegateBuilder<IStructuralEquatable>>("keyInstanceEmitter"); serviceRegistry.Register<IOneToManyExpressionBuilder>( factory => new OneToManyExpressionBuilder( factory.GetInstance<IPropertyMapper>(), factory.GetInstance<Interfaces.IPropertySelector>("CollectionPropertySelector"), type => factory.GetInstance(type))); serviceRegistry.Register<IManyToOneExpressionBuilder>( factory => new ManyToOneExpressionBuilder( factory.GetInstance<IPropertyMapper>(), factory.GetInstance<Interfaces.IPropertySelector>("ComplexPropertySelector"), type => factory.GetInstance(type))); serviceRegistry.Decorate(typeof(IMapperDelegateBuilder<>), typeof(CachedMapperDelegateBuilder<>)); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register <ITrelloFactory, TrelloFactory>(); serviceRegistry.Register <ITrelloAuthorizationWrapper, TrelloAuthorizationWrapper>(new PerContainerLifetime()); serviceRegistry.Register <IWebHookCaller, WebHookCaller>(); serviceRegistry.Register <IReadingListCache, ReadingListCache>(new PerContainerLifetime()); serviceRegistry.Register <IReadingListService, ReadingListService>(new PerContainerLifetime()); serviceRegistry.Register <IReadingListCollectionService, ReadingBoardService>(new PerContainerLifetime()); serviceRegistry.Register <ITrelloStatusService, TrelloStatusService>(); serviceRegistry.Decorate <IReadingListService, CachedReadingListService>(); serviceRegistry.Decorate <IReadingListService, ReadingListServiceProfiler>(); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.RegisterQueryHandlers(); serviceRegistry.Register <IQueryExecutor>(factory => new QueryExecutor(factory), new PerContainerLifetime()); serviceRegistry.Register <ICommandExecutor>(factory => new CommandExecutor(factory), new PerContainerLifetime()); serviceRegistry.Register <ICommandHandler <AddCustomerCommand>, AddCustomerCommandHandler>(); serviceRegistry.Decorate(typeof(ICommandHandler <>), typeof(TransactionalCommandHandler <>)); // We register the connection that it is disposed when the scope ends. // The scope here is per web request. serviceRegistry.Register(factory => CreateConnection(), new PerScopeLifetime()); serviceRegistry.Decorate <IDbConnection, ConnectionDecorator>(); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register <IProjectController, ProjectController>("ProjectController"); serviceRegistry.Register <ILogCreatorSettingsEditorController, LogCreatorSettingsEditorController>("AssemblyExporterSettingsController"); serviceRegistry.Register <IImportRomDialogController, ImportRomDialogController>("ImportRomDialogController"); serviceRegistry.Register <ILargeFilesReaderController, LargeFilesReader>("LargeFileReaderProgressController"); serviceRegistry.EnableAutoFactories(); serviceRegistry.RegisterAutoFactory <IControllerFactory>(); serviceRegistry.Register <IDizDocument, DizDocument>(); // sorry this is all a huge WIP mess, cleanup incoming soon. // serviceRegistry.Register<int, int, IReadOnlySnesRom, IMarkManyController>( // (factory, offset, whichIndex, data) => // { // // TODO: update this with updated controller from Diz 2.0 branch. // // I think that means kill 'whichIndex', use the new format that doesn't rely on it. // var view = factory.GetInstance<IMarkManyView>(); // var markManyController = new MarkManyController(offset, whichIndex, data, view); // markManyController.MarkManyView.Controller = markManyController; // return markManyController; // }); // TODO: might be able to make some of these register using // "open generics" to be more flexible. #if DIZ_3_BRANCH serviceRegistry.Register( typeof(IDataController), typeof(RomByteDataBindingController <IGridRow <ByteEntry> >) ); serviceRegistry.Register <IDataController, RomByteDataBindingGridController>(); serviceRegistry.Register( typeof(IBytesGridDataController <,>), typeof(RomByteDataBindingController <>) ); serviceRegistry.Register( typeof(IBytesGridDataController <IDataGridRow, ByteEntry>), typeof(RomByteDataBindingGridController) ); serviceRegistry.Register <IStartFormController, StartFormController>(); serviceRegistry.Register <IMainFormController, MainFormController>(); serviceRegistry.Register <IProjectLoader, ProjectFileLoader>(); serviceRegistry.Decorate( typeof(IProjectLoader), typeof(ProjectLoaderWithSampleDataDecorator)); serviceRegistry.Register <IProjectsManager, ProjectsManager>(); serviceRegistry.RegisterSingleton <ISampleProjectLoader, ProjectsManager>("SampleProjectLoader"); #endif }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.RegisterCommandHandlers(); serviceRegistry.RegisterQueryHandlers(); serviceRegistry.Decorate(typeof(IQueryHandler <,>), typeof(LoggedQueryHandler <,>)); serviceRegistry.Register <IFoo, Foo>(); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.RegisterFrom <CompositionRoot>(); serviceRegistry.RegisterApiControllers(); serviceRegistry.Register <Func <RequestContext> >(factory => (() => RequestContextMiddleware.CurrentRequest), new PerContainerLifetime()); serviceRegistry.Decorate <ILog, RequestLogDecorator>(); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.RegisterSingleton <IGitBookRecordCache, GitGitBookRecordCache>(); serviceRegistry.RegisterSingleton <IGithubBookRecordService, GithubBookRecordService>(); serviceRegistry.Decorate <IGithubBookRecordService, GithubBookRecordServiceProfiler>(); serviceRegistry.Register <IBookRecordRepository, ReadingListDataRepository>(); serviceRegistry.Register <IBookNotesService, BookNotesService>(); }
/// <summary> /// Registers an function-based `ICommandHandler{TCommand}` decorator used to intercept command handlers. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> /// <param name="implementation">A function representing the implementation of this handler.</param> /// <typeparam name="TCommand">The type of command being handeled.</typeparam> /// <typeparam name="TDependency">The dependency beging passed to the <paramref name="implementation"/> function.</typeparam> /// <returns><see cref="IServiceRegistry"/>.</returns> public static IServiceRegistry RegisterCommandInterceptor <TCommand, TDependency>(this IServiceRegistry serviceRegistry, Func <TCommand, ICommandHandler <TCommand>, TDependency, CancellationToken, Task> implementation) { if (!typeof(TDependency).IsAbstract) { serviceRegistry.Register <TDependency>(); } return(serviceRegistry.Decorate <ICommandHandler <TCommand> >((factory, handler) => new InterceptingCommandHandler <TCommand, TDependency>(handler, factory.GetInstance <TDependency>(), implementation))); }
/// <summary> /// Registers an function-based `IQueryHandler{TQuery, TResult}` decorator used to intercept query handlers. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> /// <param name="implementation">A function representing the implementation of this handler.</param> /// <typeparam name="TQuery">The type of query being handeled.</typeparam> /// <typeparam name="TResult">The type of result to be returned.</typeparam> /// <typeparam name="TDependency">The dependency beging passed to the <paramref name="implementation"/> function.</typeparam> /// <returns><see cref="IServiceRegistry"/>.</returns> public static IServiceRegistry RegisterQueryInterceptor <TQuery, TResult, TDependency>(this IServiceRegistry serviceRegistry, Func <TQuery, IQueryHandler <TQuery, TResult>, TDependency, CancellationToken, Task <TResult> > implementation) where TQuery : IQuery <TResult> { if (!typeof(TDependency).IsAbstract) { serviceRegistry.Register <TDependency>(); } return(serviceRegistry.Decorate <IQueryHandler <TQuery, TResult> >((factory, handler) => new InterceptingQueryHandler <TQuery, TResult, TDependency>(handler, factory.GetInstance <TDependency>(), implementation))); }
public static void Decorate <T>( this IServiceRegistry container) { container.Decorate <T>((ioc, instance) => { var decorated = DynamicProxyFactory <T> .Create(instance, info => Console.WriteLine($" BEFORE: {instance} {info.ImplementationName} [{info.ContractName}: {info.MethodName}]"), info => Console.WriteLine($@" AFTER ({info.Duration:g}): {info.ImplementationName} [{info.ContractName}: {info.MethodName}] ------------------------------"), info => Console.WriteLine($" ERROR: {info.ImplementationName} [{info.ContractName}: {info.MethodName}]\r\n{info.Error}")); return(decorated); }); }
/// <summary> /// Enables services to be resolved a WCF service proxies. /// </summary> /// <param name="serviceRegistery">The target <see cref="IServiceRegistry"/>.</param> /// <param name="uriProvider">The <see cref="IUriProvider"/> that is responsible /// for providing an <see cref="Uri"/> that represents the service endpoint address.</param> internal static void EnableWcfClient(this IServiceRegistry serviceRegistery, IUriProvider uriProvider) { serviceRegistery.RegisterFallback( (serviceType, serviceName) => serviceType.IsDefined(typeof(ServiceContractAttribute), true), CreateWcfProxy); serviceRegistery.Register <IBindingProvider, BindingProvider>(new PerContainerLifetime()); serviceRegistery.RegisterInstance(uriProvider); serviceRegistery.Register <IChannelProvider, ChannelProvider>(new PerContainerLifetime()); serviceRegistery.Register <IChannelFactoryProvider, ChannelFactoryProvider>(new PerContainerLifetime()); serviceRegistery.Register <IServiceProxyFactory, ServiceProxyFactory>(new PerContainerLifetime()); serviceRegistery.Register <IServiceProxyTypeFactory, ServiceProxyTypeFactory>(new PerContainerLifetime()); serviceRegistery.Register <IServiceClient, ServiceClient>(); serviceRegistery.Decorate <IChannelFactoryProvider, ChannelFactoryProviderCacheDecorator>(); }
public void Compose(IServiceRegistry serviceRegistry) { // TODO: might be able to make some of these register using // "open generics" to be more flexible. serviceRegistry.Register( typeof(IDataController), typeof(RomByteDataBindingController <IGridRow <ByteEntry> >) ); serviceRegistry.Register <IDataController, RomByteDataBindingGridController>(); serviceRegistry.Register( typeof(IBytesGridDataController <,>), typeof(RomByteDataBindingController <>) ); serviceRegistry.Register( typeof(IBytesGridDataController <IDataGridRow, ByteEntry>), typeof(RomByteDataBindingGridController) ); serviceRegistry.Register <IStartFormController, StartFormController>(); serviceRegistry.Register <int, int, IReadOnlySnesRom, IMarkManyController>( (factory, offset, whichIndex, data) => { var view = factory.GetInstance <IMarkManyView>(); var markManyController = new MarkManyController(offset, whichIndex, data, view); markManyController.MarkManyView.Controller = markManyController; return(markManyController); }); serviceRegistry.Register <IMainFormController, MainFormController>(); serviceRegistry.Register <IProjectLoader, ProjectFileLoader>(); serviceRegistry.Decorate( typeof(IProjectLoader), typeof(ProjectLoaderWithSampleDataDecorator)); serviceRegistry.Register <IProjectsManager, ProjectsManager>(); serviceRegistry.RegisterSingleton <ISampleProjectLoader, ProjectsManager>("SampleProjectLoader"); }
public void Compose(IServiceRegistry serviceRegistry) { var dataStorage = ConfigurationManager.AppSettings["DataStorage"]; if (dataStorage.ToLower ().Equals ("cache")) { serviceRegistry.Register<IDataStorage, GameScoreBoardDataCache> (); } if (dataStorage.ToLower().Equals("database")) { var mysqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"]; serviceRegistry.Register<IConnectionFactory>(factory => new MySqlConnectionFactory(mysqlConnectionString)); serviceRegistry.Register<IDataStorage>(factory => new GameScoreBoardMysqlRepository(factory.GetInstance<IConnectionFactory>())); } serviceRegistry.Register<ICryptation, StringCipher> (); serviceRegistry.Register<ILogFactory, Log4NetLogFactory>(new PerContainerLifetime()); serviceRegistry.Register<Type, ILog>((factory, type) => factory.GetInstance<ILogFactory>().GetLogger(type)); serviceRegistry.RegisterConstructorDependency( (factory, info) => factory.GetInstance<Type, ILog>(info.Member.DeclaringType)); serviceRegistry.Decorate<IDataStorage, DataStorageProfiler> (); }
public void Compose(IServiceRegistry serviceRegistry) { var dataStorage = ConfigurationManager.AppSettings["DataStorage"]; if (dataStorage.ToLower().Equals("cache")) { serviceRegistry.Register <IDataStorage, GameScoreBoardDataCache> (); } if (dataStorage.ToLower().Equals("database")) { var mysqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"]; serviceRegistry.Register <IConnectionFactory>(factory => new MySqlConnectionFactory(mysqlConnectionString)); serviceRegistry.Register <IDataStorage>(factory => new GameScoreBoardMysqlRepository(factory.GetInstance <IConnectionFactory>())); } serviceRegistry.Register <ICryptation, StringCipher> (); serviceRegistry.Register <ILogFactory, Log4NetLogFactory>(new PerContainerLifetime()); serviceRegistry.Register <Type, ILog>((factory, type) => factory.GetInstance <ILogFactory>().GetLogger(type)); serviceRegistry.RegisterConstructorDependency( (factory, info) => factory.GetInstance <Type, ILog>(info.Member.DeclaringType)); serviceRegistry.Decorate <IDataStorage, DataStorageProfiler> (); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register <ILogFactory, Log4NetLogFactory>(new PerContainerLifetime()); serviceRegistry.RegisterFrom <HealthKitServer.Server.ServerCompositionRoot> (); var dataStorage = ConfigurationManager.AppSettings["DataStorage"]; var database = ConfigurationManager.AppSettings["Database"]; switch (dataStorage) { case "cache": serviceRegistry.Register <IHealthKitDataStorage>(factory => new HealthKitDataCache(), new PerContainerLifetime()); break; case "solr": var solrServerAddress = ConfigurationManager.AppSettings["SolrServerAddress"]; serviceRegistry.Register <IHealthKitDataStorage>(factory => new HealthKidDataSolrConnection(solrServerAddress), new PerContainerLifetime()); break; case "redis": var redisServerAddress = ConfigurationManager.AppSettings["RedisServerAddress"]; serviceRegistry.Register <IHealthKitDataStorage>(factory => new HealthKitDataRedisConnection(redisServerAddress), new PerContainerLifetime()); break; case "database": if (database.ToLower().Equals("mysql")) { var mysqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"]; serviceRegistry.Register <IHealthKitDataStorage>(factory => new HealthKitDataMysqlConnection(mysqlConnectionString), new PerContainerLifetime()); } if (database.ToLower().Equals("postgresql")) { var postgresqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"]; serviceRegistry.Register <IHealthKitDataStorage>(factory => new HealthKitDataPostgresConnection(postgresqlConnectionString), new PerContainerLifetime()); } break; } serviceRegistry.Decorate <IHealthKitDataStorage, HealthKitDataStorageProfiler> (); }
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Register <IAddRomDataCommand, AddRomDataCommand>(); // when we create a IData registration, add a SNES API component to it serviceRegistry.Decorate <IDataFactory, DataAddSnesApiDecorator>(); serviceRegistry.Register <ImportRomSettings, IProjectFactoryFromRomImportSettings>((factory, settings) => new SnesProjectFactoryFromRomImportSettings( factory.GetInstance <IProjectFactory>(), settings)); serviceRegistry.Register <IData, ISnesData>(CreateSnesApiWithData); serviceRegistry.Register <IProjectImportDefaultSettingsFactory, SnesDefaultSettingsFactory>(); serviceRegistry.Register <ISnesRomImportSettingsBuilder, SnesRomImportSettingsBuilder>(); serviceRegistry.Register <ISnesRomAnalyzer, SnesRomAnalyzer>(); serviceRegistry.Register <IVectorTableCache, CachedVectorTableEntries>(); RegisterMigrations(serviceRegistry); RegisterSampleDataServices(serviceRegistry); }
/// <summary> /// Registers an function-based `IQueryHandler{TQuery, TResult}` decorator used to intercept query handlers. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> /// <param name="implementation">A function representing the implementation of this handler.</param> /// <typeparam name="TQuery">The type of query being handeled.</typeparam> /// <typeparam name="TResult">The type of result to be returned.</typeparam> /// <returns><see cref="IServiceRegistry"/>.</returns> public static IServiceRegistry RegisterQueryInterceptor <TQuery, TResult>(this IServiceRegistry serviceRegistry, Func <TQuery, IQueryHandler <TQuery, TResult>, CancellationToken, Task <TResult> > implementation) where TQuery : IQuery <TResult> => serviceRegistry.Decorate <IQueryHandler <TQuery, TResult> >((factory, handler) => new InterceptingQueryHandler <TQuery, TResult>(handler, implementation));
/// <summary> /// Registers an function-based `ICommandHandler{TCommand}` decorator used to intercept command handlers. /// </summary> /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param> /// <param name="implementation">A function representing the implementation of this handler.</param> /// <typeparam name="TCommand">The type of command being handeled.</typeparam> /// <returns><see cref="IServiceRegistry"/>.</returns> public static IServiceRegistry RegisterCommandInterceptor <TCommand>(this IServiceRegistry serviceRegistry, Func <TCommand, ICommandHandler <TCommand>, CancellationToken, Task> implementation) => serviceRegistry.Decorate <ICommandHandler <TCommand> >((factory, handler) => new InterceptingCommandHandler <TCommand>(handler, implementation));
public static IServiceRegistry DecorateWithDependencies <TFrom, TTo>(this IServiceRegistry @this) where TTo : TFrom => @this.Decorate <TFrom, TTo>() .RegisterDependencies(typeof(TTo));
public void Compose(IServiceRegistry serviceRegistry) { serviceRegistry.Decorate <string>((factory, s) => $"Decorated: {s}"); }