private void UnityInitialization(IModuleRegistrar registrar) { registrar.RegisterInstance(this, new PerThreadLifetimeManager()); var token = new RegisterToken(registrar); this.RegisterCommands(token); _commands = token.GetCurrentCommands().ToList(); }
/// <summary>Used to register concrete implemtations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { //You can register as many types as you want into the Container registrar.RegisterTypeAsSingelton <IExternalProductService, BESTBUYProductService>("BestBuy"); registrar.RegisterTypeAsSingelton <IExternalProductService, BESTBUYProductService>(); }
/// <summary>Used to register concrete implementations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { Contract.Requires(registrar != null); registrar.RegisterType <IDAL, DAL>(); registrar.RegisterType <PersonContext, PersonContext>(); }
/// <summary>Used to register concrete implemtations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { //You can register as many types as you want into the Container //registrar.RegisterType<ITest, Test>(); //registrar.RegisterTypeAsSingelton<ITest, Test>(); }
/// <summary>Used to register concrete implemtations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { //You can register as many types as you want into the Container registrar.RegisterTypeAsSingelton <IExternalProductService, WALMARTProductService>("Walmart"); registrar.RegisterTypeAsSingelton <IExternalProductService, WALMARTProductService>(); }
protected CompositionRootBase() { Container = new Container(); Container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); ModuleRegistrar = new ModuleRegistrar(Container); Modules = new List <IModule>(); }
public void Configure(ContainerBuilder builder, IEnumerable <PackageCarrier> packages) { //https://github.com/autofac/Autofac/blob/41044d7d1a4fa277c628021537d5a12016137c3b/src/Autofac/ModuleRegistrationExtensions.cs#L156 var moduleFinder = new ContainerBuilder(); moduleFinder.RegisterInstance(_configurationProvider.ConfigurationRoot); moduleFinder.RegisterAssemblyTypes(packages.Select(x => x.Assembly).ToArray()) .Where(t => typeof(IModule).IsAssignableFrom(t)).As <IModule>(); IModuleRegistrar registrar = null; using (var moduleContainer = moduleFinder.Build()) { foreach (var module in moduleContainer.Resolve <IEnumerable <IModule> >()) { if (registrar == null) { registrar = builder.RegisterModule(module); } else { registrar.RegisterModule(module); } } } }
/// <summary> /// Registers modules found in an assembly. /// </summary> /// <param name="registrar">The module registrar that will make the registrations into the container.</param> /// <param name="moduleType">The <see cref="Type"/> of the module to add.</param> /// <param name="assemblies">The assemblies from which to register modules.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="registrar"/> or <paramref name="moduleType"/> is <see langword="null"/>. /// </exception> /// <returns> /// The <see cref="IModuleRegistrar"/> to allow /// additional chained module registrations. /// </returns> public static IModuleRegistrar RegisterAssemblyModules(this IModuleRegistrar registrar, Type moduleType, params Assembly[] assemblies) { if (registrar == null) { throw new ArgumentNullException(nameof(registrar)); } if (moduleType == null) { throw new ArgumentNullException(nameof(moduleType)); } var moduleFinder = new ContainerBuilder(); moduleFinder.RegisterAssemblyTypes(assemblies) .Where(t => moduleType.IsAssignableFrom(t)) .As <IModule>(); using (var moduleContainer = moduleFinder.Build()) { foreach (var module in moduleContainer.Resolve <IEnumerable <IModule> >()) { registrar.RegisterModule(module); } } return(registrar); }
public void Initialize(IModuleRegistrar registrar) { //registrar.RegisterType<INewsLetterService, NewsLetterService>(); //registrar.RegisterType<ILocalizationService, LocalizationService>(); //registrar.RegisterType<IUserNewsLetterService, UserNewsLetterService>(); registrar.RegisterType(typeof(IUserStore <IdentityUserViewModel, long>), typeof(CustomUserStore)); }
/// <summary>Used to register concrete implementations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { Contract.Requires(registrar != null); registrar.RegisterTypeAsSingelton <ICipher, RijndaelManagedCipher>(); registrar.RegisterTypeAsSingelton <ISecurity, SecurityService>(); }
/// <summary>uses MEF to load all the IModule implementations to the Registrar</summary> /// <param name="registrar">IModuleRegistrar</param> /// <param name="rootPath">path to the root directory of the project</param> /// <param name="assemblies">retlative path to the dll to load.</param> public static void LoadModulesFromAssemblies(IModuleRegistrar registrar, string rootPath, string[] assemblies) { Uri baseUri = new Uri(rootPath); List <string> assembliesPath = assemblies.Select(ass => new Uri(baseUri, ass).LocalPath).ToList(); string badPath = assembliesPath.FirstOrDefault(ap => !File.Exists(ap)); if (badPath != null) { throw new Exception($"Could not load {badPath}. Current EXE Dir: {rootPath}. Current BaseUri {baseUri}"); } try { //Creating a single catalog from all the DLL's using (AggregateCatalog catalog = new AggregateCatalog(assembliesPath.Select(ap => new AssemblyCatalog(ap)))) using (CompositionContainer compositionContainer = new CompositionContainer(catalog)) { //Get all the modules and register them foreach (IModule module in compositionContainer.GetExports <IModule>().Select(e => e.Value)) { module.Initialize(registrar); } } } catch (ReflectionTypeLoadException rtle) { throw new Exception(String.Join(Environment.NewLine, rtle.LoaderExceptions.Select(e => e.ToString()))); } }
/// <summary>Used to register concrete implementations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { Contract.Requires(registrar != null); registrar.RegisterTypeAsSingelton <DbContextOptions <GenericContext>, DbContextOptions <GenericContext> >(SettingsManager.DBOptions); registrar.RegisterType <GenericContext, GenericContext>(); registrar.RegisterType <IGenericRepo, GenericRepo>(); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType <ISearchBookService, SearchBookService>(); registrar.RegisterType <IUserDemandService, UserDemandService>(); registrar.RegisterType(typeof(IUserStore <IdentityUserViewModel, ObjectId>), typeof(CustomUserStore)); registrar.RegisterType(typeof(IRoleStore <IdentityRoleViewModel, ObjectId>), typeof(CustomRoleStore)); registrar.RegisterType <IRefreshTokenService, RefreshTokenService>(); }
/// <summary> /// Registers modules found in an assembly. /// </summary> /// <param name="registrar">The module registrar that will make the registrations into the container.</param> /// <param name="assemblies">The assemblies from which to register modules.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="registrar"/> is <see langword="null"/>. /// </exception> /// <returns> /// The <see cref="IModuleRegistrar"/> to allow /// additional chained module registrations. /// </returns> public static IModuleRegistrar RegisterAssemblyModules(this IModuleRegistrar registrar, params Assembly[] assemblies) { if (registrar == null) { throw new ArgumentNullException(nameof(registrar)); } return(registrar.RegisterAssemblyModules <IModule>(assemblies)); }
public void Initialize(IModuleRegistrar registrar) { registrar.Register <ISqlConnectionFactory>(() => new SqlConnectionFactory(_connectionString), Lifetime.Scoped); registrar.Register <IUserDatabaseQueries, UserDatabaseQueries>(Lifetime.Scoped); registrar.Register <IUsersCounter, UsersCounter>(Lifetime.Scoped); registrar.Register <IInboxMessageDatabaseQueries, InboxMessageDatabaseQueries>(Lifetime.Scoped); registrar.Register <IInternalCommandDatabaseQueries, InternalCommandDatabaseQueries>(Lifetime.Scoped); registrar.Register <IOutboxDatabaseQueries, OutboxDatabaseQueries>(Lifetime.Scoped); }
/// <summary> /// Add a module to the container. /// </summary> /// <param name="registrar">The module registrar that will make the registration into the container.</param> /// <typeparam name="TModule">The module to add.</typeparam> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="registrar"/> is <see langword="null"/>. /// </exception> /// <returns> /// The <see cref="IModuleRegistrar"/> to allow /// additional chained module registrations. /// </returns> public static IModuleRegistrar RegisterModule <TModule>(this IModuleRegistrar registrar) where TModule : IModule, new() { if (registrar == null) { throw new ArgumentNullException(nameof(registrar)); } return(registrar.RegisterModule(new TModule())); }
public void Initialize(IModuleRegistrar registrar) { //from dll //registrar.RegisterType<IAppointmentService, AppointmentService>(); //api registrar.RegisterType <IAppointmentService, AppointmentServiceClient>(new InjectionConstructor("http://localhost/aPointerAPI/api/Apt/")); //registrar.RegisterType<IAppointmentService, AppointmentServiceClient>(new InjectionConstructor("http://localhost:5977/api/Apt/")); registrar.RegisterType <IAppointmentService, AppointmentServiceClient>(); }
public void Initialize(IModuleRegistrar registrar) { //registrar.RegisterType<IUnitOfWork, UnitOfWork>(); //registrar.RegisterType<IUserRepository, UserRepository>(); //registrar.RegisterType<IKeyGroupRepository, KeyGroupRepository>(); //registrar.RegisterType<ILocalizationKeyRepository, LocalizationKeyRepository>(); //registrar.RegisterType<IUserNewsLetterRepository, UserNewsLetterRepository>(); //registrar.RegisterType<INewsLetterRepository, NewsLetterRepository>(); registrar.RegisterType(typeof(IBaseRepository <>), typeof(BaseRepository <>)); }
/// <summary> /// Registers modules found in an assembly. /// </summary> /// <param name="registrar">The module registrar that will make the registrations into the container.</param> /// <param name="assemblies">The assemblies from which to register modules.</param> /// <typeparam name="TModule">The type of the module to add.</typeparam> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="registrar"/> is <see langword="null"/>. /// </exception> /// <returns> /// The <see cref="Autofac.Core.Registration.IModuleRegistrar"/> to allow /// additional chained module registrations. /// </returns> public static IModuleRegistrar RegisterAssemblyModules <TModule>(this IModuleRegistrar registrar, params Assembly[] assemblies) where TModule : IModule { if (registrar == null) { throw new ArgumentNullException("registrar"); } return(registrar.RegisterAssemblyModules(typeof(TModule), assemblies)); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType <IEmailQueueService, EmailQueueService>(); registrar.RegisterType <IPdfQueueService, PdfQueueService>(); registrar.RegisterType <IRequestQueueService, RequestQueueService>(); registrar.RegisterType(typeof(IUserStore <IdentityUserViewModel, ObjectId>), typeof(CustomUserStore)); registrar.RegisterType(typeof(IRoleStore <IdentityRoleViewModel, ObjectId>), typeof(CustomRoleStore)); registrar.RegisterType <IClientService, ClientService>(); registrar.RegisterType <IRefreshTokenService, RefreshTokenService>(); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType<IContactUsService, ContactUsService>(); registrar.RegisterType<ITeamMemberService, TeamMemberService>(); registrar.RegisterType<ICustomerService, CustomerService>(); registrar.RegisterType<ICompanyService, CompanyService>(); registrar.RegisterType<IProductService, ProductService>(); registrar.RegisterType<IOrderDemoService, OrderDemoService>(); registrar.RegisterType<IUserService, UserService>(); registrar.RegisterType<IFeaturesService, FeatureService>(); }
/// <summary>Used to register concrete implementations to the DI container</summary> /// <param name="registrar">add implementation to the DI container using this registrar</param> public void Initialize(IModuleRegistrar registrar) { Contract.Requires(registrar != null); //You can register as many types as you want into the Container //registrar.RegisterType<ITest, Test>(); //registrar.RegisterTypeAsSingelton<ITest, Test>(); registrar.RegisterTypeAsSingelton <ICaptcha, GoogleRecaptcha>(); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterTypeWithPerRequestLife<IUnitOfWork, EFContext>(); //registrar.RegisterType<IContext, EFContext>(); registrar.RegisterType<IGenericRepository<Task>, GenericRepository<Task>>(); registrar.RegisterType<IGenericRepository<Process>, GenericRepository<Process>>(); registrar.RegisterType<IGenericRepository<Transition>, GenericRepository<Transition>>(); registrar.RegisterType<IGenericRepository<State>, GenericRepository<State>>(); registrar.RegisterType<IGenericRepository<StateType>, GenericRepository<StateType>>(); registrar.RegisterType<IGenericRepository<Action>, GenericRepository<Action>>(); registrar.RegisterType<IGenericRepository<ActionType>, GenericRepository<ActionType>>(); }
private static IModuleRegistrar RegisterModules( this ContainerBuilder builder, Assembly assembly) { IModuleRegistrar result = default(IModuleRegistrar); GetAbstractModules(assembly).ForEach(p => { result = builder.RegisterModule(p); }); return(result); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType <IBookRepository, BookRepository>(); registrar.RegisterType <IUserDemandRepository, UserDemandRepository>(); registrar.RegisterType <IUnitOfWork, UnitOfWork>(); registrar.RegisterType <IUserRepository, UserRepository>(); registrar.RegisterType <IRoleRepository, RoleRepository>(); registrar.RegisterType <IRefreshTokenRepository, RefreshTokenRepository>(); registrar.RegisterType(typeof(IBaseRepository <>), typeof(BaseRepository <>)); registrar.RegisterType <IMongoClient, MongoClient>(ConfigurationManager.ConnectionStrings["MongoDbConnection"].ConnectionString); registrar.RegisterInstanceSingleton(typeof(IMongoDatabase), DataSeeder.GetDataBase()); }
public void Initialize(IModuleRegistrar registrar) { //********* un-comment only usable repositories ********* //with MicroORM (Dapper) registrar.RegisterType <ICommonRepository <Appointee>, AppointeeRepository>(); registrar.RegisterType <ICommonRepository <Appointer>, AppointerRepository>(); //with Entity Framework //registrar.RegisterType<IDbContext, AptDbContext>(new InjectionConstructor("server=FORD\\sqlExpress;database=AppointDB;Trusted_Connection=True;")); //registrar.RegisterType<ICommonRepository<Appointee>, CommonRepositoryEF<Appointee>>(); //registrar.RegisterType<ICommonRepository<Appointer>, CommonRepositoryEF<Appointer>>(); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterTypeWithContainerControlledLife<IDatabaseFactory, DatabaseFactory>(); registrar.RegisterTypeWithContainerControlledLife<IUnitOfWork, UnitOfWork>(); registrar.RegisterTypeWithContainerControlledLife<IContactUsRepository, ContactUsRepository>(); registrar.RegisterTypeWithContainerControlledLife<ITeamMemberRepository, TeamMemberRepository>(); registrar.RegisterTypeWithContainerControlledLife<ICustomerRepository, CustomerRepository>(); registrar.RegisterTypeWithContainerControlledLife<ICompanyRepository, CompanyRepository>(); registrar.RegisterTypeWithContainerControlledLife<IProductRepository, ProductRepository>(); registrar.RegisterTypeWithContainerControlledLife<IOrderDemoRepository, OrderDemoRepository>(); registrar.RegisterType<IUserRepository, UserRepository>(); registrar.RegisterType<IFeaturesRepository, FeaturesRepository>(); }
public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (registrar == null) { throw new ArgumentNullException("registrar"); } registrar.RegisterType<IFileWordsService, FileWordsService>(); }
public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (registrar == null) { throw new ArgumentNullException("registrar"); } registrar.RegisterType <IFileWordsService, FileWordsService>(); }
public static IModuleRegistrar RegisterEventstreamModule( this IModuleRegistrar builder, IConfiguration configuration) { var connectionString = configuration.GetConnectionString("Events"); if (string.IsNullOrWhiteSpace(connectionString)) { throw new ApplicationException("Missing 'Events' connectionstring."); } return(builder .RegisterModule(new SqlStreamStoreModule(connectionString, Schema.Default)) .RegisterModule(new TraceSqlStreamStoreModule(configuration["DataDog:ServiceName"]))); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationRegistrar"/> class. /// </summary> /// <param name="componentRegistrar"> /// The <see cref="IComponentRegistrar"/> that will be used to parse /// configuration values into component registrations. /// </param> /// <param name="moduleRegistrar"> /// The <see cref="IModuleRegistrar"/> that will be used to parse /// configuration values into module registrations. /// </param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="componentRegistrar" /> or <paramref name="moduleRegistrar" /> is <see langword="null" />. /// </exception> public ConfigurationRegistrar(IComponentRegistrar componentRegistrar, IModuleRegistrar moduleRegistrar) { if (componentRegistrar == null) { throw new ArgumentNullException("componentRegistrar"); } if (moduleRegistrar == null) { throw new ArgumentNullException("moduleRegistrar"); } this.ComponentRegistrar = componentRegistrar; this.ModuleRegistrar = moduleRegistrar; }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType<IQueryHandler<TasksByStatusQuery, TasksByStatusQueryResult>, TasksByStatusQueryHandler>(); registrar.RegisterType<IQueryHandler<ByIdQuery, ProcessByIdQueryResult>, ProcessByIdQueryHandler>(); registrar.RegisterType<IQueryHandler<ByIdQuery, TransitionByIdQueryResult>, TransitionByIdQueryHandler>(); registrar.RegisterType<IQueryHandler<EmptyQuery, ProcessesAllQueryResult>, ProcessesAllQueryHandler>(); registrar.RegisterType<IQueryHandler<EmptyQuery, StateTypesAllQueryResult>, StateTypesAllQueryHandler>(); registrar.RegisterType<IQueryHandler<EmptyQuery, ActionTypesAllQueryResult>, ActionTypesAllQueryHandler>(); registrar.RegisterType<ICommandHandler<SaveProcessCommand>, SaveProcessCommandHandler>(); registrar.RegisterType<ICommandHandler<SaveStateCommand>, SaveStateCommandHandler>(); registrar.RegisterType<ICommandHandler<SaveStateCoordinatesCommand>, SaveStateCoordinatesCommandHandler>(); registrar.RegisterType<ICommandHandler<SaveTransitionCommand>, SaveTransitionCommandHandler>(); registrar.RegisterType<ICommandHandler<SaveActionCommand>, SaveActionCommandHandler>(); }
private static void ConfigureContainer <TRoot>(ContainerBuilder builder) { Log.Debug("Container configuration called"); builder.RegisterType(typeof(TRoot)); builder.RegisterType(typeof(Log4NetConfigurator)); builder.RegisterType <LogImpl>().As <ILog>(); builder.RegisterType <ContainerBuilderFacade>().As <IContainerBuilderFacade>(); Log.Info("Loading Modules..."); _moduleRegistrar = LoadModules(builder); Log.Info("Modules Loaded"); Container = builder.Build(); noOfContainerBuilds++; Log.Debug($"Container built ({noOfContainerBuilds}) times, with ({Container.ComponentRegistry.Registrations.Count()}) number of types."); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType <IEmailQueueRepository, EmailQueueRepository>(); registrar.RegisterType <IPdfQueueRepository, PdfQueueRepository>(); registrar.RegisterType <IRequestQueueRepository, RequestQueueRepository>(); registrar.RegisterType <IUnitOfWork, UnitOfWork>(); registrar.RegisterType <IUserRepository, UserRepository>(); registrar.RegisterType <IRoleRepository, RoleRepository>(); registrar.RegisterType <IExternalLoginRepository, ExternalLoginRepository>(); registrar.RegisterType <IRefreshTokenRepository, RefreshTokenRepository>(); registrar.RegisterType <IClientRepository, ClientRepository>(); registrar.RegisterType(typeof(IBaseRepository <>), typeof(BaseRepository <>)); registrar.RegisterType <IMongoClient, MongoClient>(ConfigurationManager.ConnectionStrings["MongoDbConnection"].ConnectionString); registrar.RegisterInstanceSingleton(typeof(IMongoDatabase), DataSeeder.GetDataBase()); }
public DynamicConsole( string prompt, IOutput output, IModuleRegistrar registrar, ConsoleActionCallback<IConsoleCommand> foundCommand, ConsoleActionCallback unknownCommand) { this.Output = output; this.Prompt = prompt; this.FoundCommand = foundCommand; this.UnknownCommand = unknownCommand; _commands = new List<IConsoleCommand>(); UnityInitialization(registrar); }
public DynamicConsole( string prompt, IOutput output, IModuleRegistrar registrar, ConsoleActionCallback <IConsoleCommand> foundCommand, ConsoleActionCallback unknownCommand) { this.Output = output; this.Prompt = prompt; this.FoundCommand = foundCommand; this.UnknownCommand = unknownCommand; _commands = new List <IConsoleCommand>(); UnityInitialization(registrar); }
public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (registrar == null) { throw new ArgumentNullException("registrar"); } if (!parameters.AutoApplyDbMigrations) { Database.SetInitializer<FileWordsDataflowDbContext>(null); } else { Database.SetInitializer(new FileWordsDataflowDbContextInitializer()); } registrar.RegisterType<IRepository, Repository>(); }
public void Initialize(IModuleRegistrar registrar) { // registrar.RegisterTypeUsingSetter<GlobalSetupHelper>("CompanyService"); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType<IGenericService<Process>, GenericService<Process>>(); registrar.RegisterType<IProcessService, ProcessService>(); }
public void Initialize(IModuleRegistrar registrar) { registrar.RegisterType<IGenericRepository<Process>, GenericRepository<Process>>(); }