Beispiel #1
0
        public FakeDomainFactory()
        {
            Repository = new FakeRepositoryFactory();
            RepositoryInitializer Initializer = new RepositoryInitializer(Repository);

            Initializer.SetupAll();
        }
 public override void Initialize()
 {
     RepositoryInitializer.InitRepository();
     Mvx.RegisterType <IComputeAreaService, ComputeAreaService>();
     Mvx.RegisterType <IShapesCreator, ShapesCreator>();
     Mvx.RegisterType <IShapeRemover, ShapeRemover>();
     Mvx.RegisterType <ISubmissionService, SubmissionService>();
 }
        static void Main()
        {
            RepositoryInitializer.Init();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Beispiel #4
0
    /// <summary>
    /// Initializes the module.
    /// </summary>
    public static void Initialize()
    {
        var serviceLocator = ServiceLocator.Default;

        RepositoryInitializer.RegisterRepositories();

        serviceLocator.RegisterType <IAccountService, AccountService>();
        serviceLocator.RegisterType <ILicenseGenerationService, LicenseGenerationGenerationService>();
        serviceLocator.RegisterType <ILicenseValidationService, LicenseValidationService>();
    }
Beispiel #5
0
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            Container.RegisterType <ILogger, Logger>(new ContainerControlledLifetimeManager());

            RepositoryInitializer.Initialize(Container,
                                             () => PathHelper.AppDataFolderPath);

            DomainServicesInitializer.Initialize(Container);
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            SwaggerInitializer.Configure(services);

            SetupCommanderDatabase(services);

            services.AddControllers().AddNewtonsoftJson(serializer => serializer.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver());

            AutoMapperInitializer.Configure(services);

            RepositoryInitializer.Configure(services);

            BusinessServiceInitializer.Configure(services);

            DALInitializer.Configure(services);
        }
Beispiel #7
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                var logger   = services.GetRequiredService <ILogger <Program> >();
                try
                {
                    var repository = services.GetRequiredService <IRepository>();
                    await RepositoryInitializer.InitializeRepository(repository, logger);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "An error occurred while seeding the repository.");
                }
            }

            await host.RunAsync();
        }
Beispiel #8
0
        /// <summary>
        /// 初始化数据库。
        /// </summary>
        /// <param name="host">已经创建的应用程序宿主环境。</param>
        private static void InitializeDatabase(IWebHost host)
        {
            _logger.Trace("初始化数据库...");

            using (var serviceScope = host.Services.CreateScope())
            {
                var repo            = serviceScope.ServiceProvider.GetService <Repository>();
                var repoInitializer = new RepositoryInitializer(
                    repo, serviceScope.ServiceProvider.GetService <ILogger <RepositoryInitializer> >());

                try
                {
                    repoInitializer.Initialize();
                    repoInitializer.Seed();
                }
                catch (Exception ex)
                {
                    _logger.Error("初始化数据库失败:{0}:{1}", ex.GetType(), ex.Message);
                    throw;
                }
            }
        }
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     RepositoryInitializer.Init();
 }
Beispiel #10
0
 public InMemoryAccountsRepository()
 {
     accounts = RepositoryInitializer.GetAccounts();
 }