/// <inheritdoc />
 public MongoRepositoryInitializer(IMongoDBManager dbManager, IObjectMapper mapper,
                                   RepositoryConfigurations config = null)
 {
     _dbManager = dbManager;
     _mapper    = mapper;
     _config    = config;
 }
Ejemplo n.º 2
0
 public virtual void Initialize(ISQLiteDBManager dbManager, IRepositoryManager repositoryManager,
                                IObjectMapper mapper,
                                Type implementedInterface, RepositoryConfigurations config = null)
 {
     _dbManager = (SQLiteDBManager)dbManager;
     Initialize(repositoryManager, mapper, implementedInterface, config);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Configure the repository manager to use InMemory repositories
        /// </summary>
        /// <param name="builder">Application builder</param>
        /// <param name="filesLocation">The direction that the files are stored in.</param>
        /// <param name="repositoriesAssembly">The name of the assembly containing the repositories
        /// <remarks>The assembly name should not contain the extension.</remarks></param>
        /// <param name="config">The configuration object to be passed to the repositories</param>
        /// <returns>Application builder</returns>
        public static T UseFileRepositories <T>(this T builder, string filesLocation, string repositoriesAssembly,
                                                RepositoryConfigurations config = null) where T : IApplicationBuilder
        {
            builder.BuildActionsCoordinator.AddAction(DefaultBuildActions.InMemoryRepositoryBuildAction((container) =>
            {
                if (!container.IsRegistered <IRepositoryManager>())
                {
                    throw new ApplicationBuildException("RepositoryManager is not registered. call UseSingletonRepositoryManager or UseTransientRepositoryManager to configuration the repository manager.");
                }

                var repositoryManager = container.Resolve <IRepositoryManager>();

                repositoryManager.AddRepositoryInitializer(new FileRepositoryInitializer(filesLocation, container.Resolve <IObjectMapper>(), config));
                repositoryManager.RegisterRepositories(repositoriesAssembly);

                var logger = container.Resolve <ILogger>();
                container.RegisterInstance <IRepositoryManager>(repositoryManager);

                foreach (var repository in repositoryManager.GetRepositories())
                {
                    logger.Log(EventsSource,
                               $"Registering repository of type {repository.GetType().Name}",
                               LogRecordTypes.Debug);
                    container.RegisterInstance(repository.ImplementedInterface, repository);
                }
            }));
            return(builder);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Do any required initialization
 /// </summary>
 public virtual void Initialize(IMongoDBManager dbManager,
                                IRepositoryManager repositoryManager,
                                IObjectMapper mapper,
                                Type implementedInterface,
                                RepositoryConfigurations config = null)
 {
     _dbManager = dbManager;
     _database  = _dbManager.GetDatabase();
     Initialize(repositoryManager, mapper, implementedInterface, config);
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public RESTRepositoryInitializer(string apiBaseURL, Action unauthorizedRequestHandler, IObjectMapper mapper,
                                  RepositoryConfigurations config = null)
 {
     _unauthorizedRequestHandler = unauthorizedRequestHandler;
     _mapper = mapper;
     _config = config;
     _client = new HttpClient {
         BaseAddress = new Uri(apiBaseURL, UriKind.Absolute)
     };
 }
Ejemplo n.º 6
0
 /// <inheritdoc />
 public void Initialize(HttpClient httpClient,
                        Action unauthorizedRequestHandler,
                        IRepositoryManager repositoryManager,
                        IObjectMapper mapper,
                        Type implementedInterface,
                        RepositoryConfigurations config = null)
 {
     SetHttpClient(httpClient);
     _unauthorizedRequestHandler = unauthorizedRequestHandler;
     Initialize(repositoryManager, mapper, implementedInterface, config);
 }
Ejemplo n.º 7
0
        public override void Initialize(IMongoDBManager dbManager,
                                        IRepositoryManager repositoryManager,
                                        IObjectMapper mapper,
                                        Type implementedInterface,
                                        RepositoryConfigurations config = null)
        {
            base.Initialize(dbManager, repositoryManager, mapper, implementedInterface, config);

            BsonClassMap.RegisterClassMap <Employee>(c =>
            {
                ConfigureDetaultTableMappings(c, e => e.ID);
                c.UnmapProperty(e => e.StateName);
                c.UnmapProperty(e => e.CompanyName);
            });

            _companyCollection = _database.GetCollection <Company>(HRMongoCollections.Companies);
        }
Ejemplo n.º 8
0
 public static IRepository <T> GetRepository <T>(RepositoryConfigurations <T> configurations)
 {
     return(RepositoriesBuilders[typeof(T)](configurations) as IRepository <T>);
 }
Ejemplo n.º 9
0
 public Repository(RepositoryConfigurations <T> configurations)
 {
     storageAdapter = StorageAdapterBuilder.BuildAdapter <T>(configurations.StorageType, configurations);
 }
Ejemplo n.º 10
0
 /// <inheritdoc />
 public FileRepositoryInitializer(string filesLocation, IObjectMapper mapper, RepositoryConfigurations config)
 {
     _filesLocation = filesLocation;
     _mapper        = mapper;
     _config        = config;
 }
Ejemplo n.º 11
0
        private static void CreateRepositoryManager <TDBManager>(IContainer container, string connectionString, string repositoriesAssembly, RepositoryConfigurations config = null)
            where TDBManager : ILinqDBManager, new()
        {
            if (!container.IsRegistered <IRepositoryManager>())
            {
                throw new ApplicationBuildException("RepositoryManager is not registered. call UseSingletonRepositoryManager or UseTransientRepositoryManager to configuration the repository manager.");
            }

            var repositoryManager = container.Resolve <IRepositoryManager>();

            var dbManager = new TDBManager();

            container.RegisterInstance <ILinqDBManager>(dbManager);
            dbManager.Initialize(connectionString);

            repositoryManager.AddRepositoryInitializer(new LinqRepositoryInitializer(dbManager, container.Resolve <IObjectMapper>(), config));
            repositoryManager.RegisterRepositories(repositoriesAssembly);

            var logger = container.Resolve <ILogger>();

            container.RegisterInstance <IRepositoryManager>(repositoryManager);

            foreach (var repository in repositoryManager.GetRepositories())
            {
                logger.Log(EventsSource,
                           $"Registering repository of type {repository.GetType().Name}",
                           LogRecordTypes.Debug);
                container.RegisterInstance(repository.ImplementedInterface, repository);
            }
        }