protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            // Autofac & AdaptiveClient
            List <IEndPointConfiguration> endPoints   = EndPointUtilities.LoadEndPoints(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "appsettings.json")).ToList();
            IEndPointConfiguration        backOffice  = endPoints.FirstOrDefault(x => x.API_Name == API_Name.BackOffice && x.ProviderName == DataBaseProviderName.MySQL);
            IEndPointConfiguration        frontOffice = endPoints.FirstOrDefault(x => x.API_Name == API_Name.StoreFront && x.ProviderName == DataBaseProviderName.MySQL);

            if (backOffice != null)
            {
                backOffice.ConnectionString = ConnectionstringUtility.BuildConnectionString(backOffice.ConnectionString);
            }

            if (frontOffice != null)
            {
                frontOffice.ConnectionString = ConnectionstringUtility.BuildConnectionString(frontOffice.ConnectionString);
            }

            builder.RegisterModule(new LeaderAnalytics.AdaptiveClient.EntityFrameworkCore.AutofacModule());
            builder.RegisterInstance(endPoints).SingleInstance();
            RegistrationHelper registrationHelper = new RegistrationHelper(builder);

            registrationHelper
            .RegisterEndPoints(endPoints)
            .RegisterModule(new Zamagon.Services.Common.AdaptiveClientModule())
            .RegisterModule(new Zamagon.Services.BackOffice.AdaptiveClientModule())
            .RegisterModule(new Zamagon.Services.StoreFront.AdaptiveClientModule());
        }
        public Zamagon.Services.StoreFront.Database.Db_MySQL CreateDbContext(string[] args)
        {
            string connectionString           = ConnectionstringUtility.BuildConnectionString(ConnectionstringUtility.GetConnectionString(Constants.EndPointsFile, API_Name.StoreFront, DataBaseProviderName.MySQL));
            DbContextOptionsBuilder dbOptions = new DbContextOptionsBuilder();

            dbOptions.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
            Zamagon.Services.StoreFront.Database.Db_MySQL db = new Zamagon.Services.StoreFront.Database.Db_MySQL(dbOptions.Options);
            return(db);
        }
        public Tests.Artifacts.StoreFront.Db_MySQL CreateDbContext(string[] args)
        {
            string connectionString           = ConnectionstringUtility.BuildConnectionString(ConnectionstringUtility.GetConnectionString("bin\\debug\\netcoreapp2.0\\EndPoints.json", API_Name.StoreFront, DataBaseProviderName.MySQL));
            DbContextOptionsBuilder dbOptions = new DbContextOptionsBuilder();

            dbOptions.UseMySql(ServerVersion.AutoDetect(connectionString));
            Tests.Artifacts.StoreFront.Db_MySQL db = new Tests.Artifacts.StoreFront.Db_MySQL(dbOptions.Options);
            return(db);
        }
Example #4
0
        public static IEnumerable <IEndPointConfiguration> ReadEndPointsFromDisk()
        {
            List <IEndPointConfiguration> endPoints   = EndPointUtilities.LoadEndPoints(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "appsettings.json")).ToList();
            IEndPointConfiguration        backOffice  = endPoints.FirstOrDefault(x => x.API_Name == API_Name.BackOffice && x.ProviderName == DataBaseProviderName.MySQL);
            IEndPointConfiguration        frontOffice = endPoints.FirstOrDefault(x => x.API_Name == API_Name.StoreFront && x.ProviderName == DataBaseProviderName.MySQL);

            if (backOffice != null)
            {
                backOffice.ConnectionString = ConnectionstringUtility.BuildConnectionString(endPoints.First(x => x.API_Name == API_Name.BackOffice && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString);
            }

            if (frontOffice != null)
            {
                frontOffice.ConnectionString = ConnectionstringUtility.BuildConnectionString(endPoints.First(x => x.API_Name == API_Name.StoreFront && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString);
            }

            return(endPoints);
        }
Example #5
0
        protected async Task CreateTestArtifacts()
        {
            EndPoints = EndPointUtilities.LoadEndPoints("EndPoints.json");
            if (EndPoints.Any(x => x.ProviderName == DataBaseProviderName.MySQL))
            {
                EndPoints.First(x => x.API_Name == API_Name.BackOffice && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString = ConnectionstringUtility.BuildConnectionString(EndPoints.First(x => x.API_Name == API_Name.BackOffice && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString);
                EndPoints.First(x => x.API_Name == API_Name.StoreFront && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString = ConnectionstringUtility.BuildConnectionString(EndPoints.First(x => x.API_Name == API_Name.StoreFront && x.ProviderName == DataBaseProviderName.MySQL).ConnectionString);
            }
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterModule(new LeaderAnalytics.AdaptiveClient.EntityFrameworkCore.AutofacModule());
            RegistrationHelper registrationHelper = new RegistrationHelper(builder);

            registrationHelper.RegisterEndPoints(EndPoints);
            registrationHelper.RegisterModule(new Zamagon.Services.BackOffice.AdaptiveClientModule());
            registrationHelper.RegisterModule(new Zamagon.Services.Common.AdaptiveClientModule());
            registrationHelper.RegisterModule(new Zamagon.Services.StoreFront.AdaptiveClientModule());
            Container         = builder.Build();
            BOServiceClient   = Container.Resolve <IAdaptiveClient <IBOServiceManifest> >();
            SFServiceClient   = Container.Resolve <IAdaptiveClient <ISFServiceManifest> >();
            DatabaseUtilities = Container.Resolve <IDatabaseUtilities>();
        }