Beispiel #1
0
        private static IEvolutionLogic GetApplication(IDatabaseAuthenticationOptions dbAuthOptions)
        {
            PopulateMissingConfigValues(ref dbAuthOptions);
            var context        = DbContextFactory.CreateContext(dbAuthOptions);
            var repo           = new EvolutionRepo(context);
            var fileSystem     = new FileContext();
            var fileSystemRepo = new FileRepo(fileSystem);

            return(new EvolutionLogic(repo, fileSystemRepo));
        }
 public static IEvolutionLogic GetApplication(IDatabaseAuthenticationOptions dbAuthOptions)
 {
     return(new ServiceCollection()
            .AddTransient((ctx) => new DbContextFactory().CreateContext(dbAuthOptions))
            .AddTransient <IEvolutionRepo, EvolutionRepo>()
            .AddTransient <IFileContext, FileContext>()
            .AddTransient <IFileRepo, FileRepo>()
            .AddTransient <IEvolutionLogic, EvolutionLogic>()
            .BuildServiceProvider()
            .GetService <IEvolutionLogic>());
 }
        public IEvolutionContext CreateContext(IDatabaseAuthenticationOptions dbAuthOptions)
        {
            if (dbAuthOptions.Type == DatabaseTypes.Oracle)
            {
                var connectionStringBuilder = new OracleConnectionBuilder()
                {
                    UserName = dbAuthOptions.User,
                    Password = dbAuthOptions.Password,
                    Server   = dbAuthOptions.Server,
                    Instance = dbAuthOptions.Instance,
                    Port     = dbAuthOptions.Port
                };

                return(new OracleEvolutionContext(connectionStringBuilder.CreateConnectionString()));
            }
            else
            {
                throw new NotSupportedException("The type of database provided is not supported");
            }
        }