예제 #1
0
        /// <summary>
        /// Adds services to the dependency injection container.
        /// </summary>
        /// <param name="services">The collection of services.</param>
        public async Task ConfigureServicesAsync(IServiceCollection services)
        {
            services.BuildServiceProvider().GetService <ILoggerFactory>().AddConsole();

            services.AddSingleton <IConfiguration>(_ => this.configuration);

            // Setup ASP.NET MVC
            services
            .AddMvcCore()
            .AddApiExplorer()
            .AddViews()
            .AddJsonFormatters();

            // Logger
            services.AddTransient <ILogger>(ConfigurationParser.CreateLogger);

            LogStartup(services.BuildServiceProvider().GetService <ILogger>(), services.BuildServiceProvider().GetService <IHostingEnvironment>());

            // CORS Headers
            services.AddCors();

            // Ledger Store
            services.AddScoped <IStorageEngine>(await ConfigurationParser.CreateStorageEngine(services.BuildServiceProvider()));

            services.AddScoped <ILedgerQueries>(ConfigurationParser.CreateLedgerQueries);

            services.AddScoped <ILedgerIndexes>(ConfigurationParser.CreateLedgerIndexes);

            services.AddScoped <IAnchorState>(await ConfigurationParser.CreateAnchorState(services.BuildServiceProvider()));

            services.AddScoped <IAnchorRecorder>(await ConfigurationParser.CreateAnchorRecorder(services.BuildServiceProvider()));

            services.AddScoped <IMutationValidator>(await ConfigurationParser.CreateRulesValidator(services.BuildServiceProvider()));

            services.AddScoped <TransactionValidator>(ConfigurationParser.CreateTransactionValidator);

            services.AddSingleton <GlobalSettings>(ConfigurationParser.CreateGlobalSettings);

            // Transaction Stream Subscriber
            services.AddSingleton <TransactionStreamSubscriber>(ConfigurationParser.CreateStreamSubscriber);

            // Anchoring
            services.AddSingleton <LedgerAnchorWorker>(ConfigurationParser.CreateLedgerAnchorWorker);

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Aid:Tech Openchain", Version = "v1"
                });
            });
        }
예제 #2
0
        /// <summary>
        /// Adds services to the dependency injection container.
        /// </summary>
        /// <param name="services">The collection of services.</param>
        public async Task ConfigureServicesAsync(IServiceCollection services)
        {
            //TODO: review this fix; make sure logging is still ok
            //services.BuildServiceProvider().GetService<ILoggerFactory>().AddConsole();

            services.AddLogging(opt =>
            {
                opt.AddConsole();
            });


            services.AddSingleton <IConfiguration>(_ => this.configuration);

            // Setup ASP.NET MVC
            services
            .AddMvcCore(options => options.EnableEndpointRouting = false)
            .AddViews()
            .AddNewtonsoftJson();

            // Logger
            services.AddTransient <ILogger>(ConfigurationParser.CreateLogger);

            LogStartup(services.BuildServiceProvider().GetService <ILogger>(), services.BuildServiceProvider().GetService <IWebHostEnvironment>());

            // CORS Headers
            services.AddCors();

            // Ledger Store
            services.AddScoped <IStorageEngine>(await ConfigurationParser.CreateStorageEngine(services.BuildServiceProvider()));

            services.AddScoped <ILedgerQueries>(ConfigurationParser.CreateLedgerQueries);

            services.AddScoped <ILedgerIndexes>(ConfigurationParser.CreateLedgerIndexes);

            services.AddScoped <IAnchorState>(await ConfigurationParser.CreateAnchorState(services.BuildServiceProvider()));

            services.AddScoped <IAnchorRecorder>(await ConfigurationParser.CreateAnchorRecorder(services.BuildServiceProvider()));

            services.AddScoped <IMutationValidator>(await ConfigurationParser.CreateRulesValidator(services.BuildServiceProvider()));

            services.AddScoped <TransactionValidator>(ConfigurationParser.CreateTransactionValidator);

            services.AddSingleton <GlobalSettings>(ConfigurationParser.CreateGlobalSettings);

            // Transaction Stream Subscriber
            services.AddSingleton <TransactionStreamSubscriber>(ConfigurationParser.CreateStreamSubscriber);

            // Anchoring
            services.AddSingleton <LedgerAnchorWorker>(ConfigurationParser.CreateLedgerAnchorWorker);
        }
예제 #3
0
        /// <summary>
        /// Adds services to the dependency injection container.
        /// </summary>
        /// <param name="services">The collection of services.</param>
        public async Task ConfigureServicesAsync(IServiceCollection services)
        {
            services.BuildServiceProvider().GetService <ILoggerFactory>().AddConsole();

            services.AddSingleton <IConfiguration>(_ => this.configuration);

            // Setup ASP.NET MVC
            services
            .AddMvcCore()
            .AddViews()
            .AddJsonFormatters();

            // Logger
            services.AddTransient <ILogger>(ConfigurationParser.CreateLogger);

            LogStartup(services.BuildServiceProvider().GetService <ILogger>(), services.BuildServiceProvider().GetService <IHostingEnvironment>());

            // CORS Headers
            services.AddCors();

            // Ledger Store
            services.AddScoped <IStorageEngine>(await ConfigurationParser.CreateStorageEngine(services.BuildServiceProvider()));

            services.AddScoped <ILedgerQueries>(ConfigurationParser.CreateLedgerQueries);

            services.AddScoped <ILedgerIndexes>(ConfigurationParser.CreateLedgerIndexes);

            services.AddScoped <IAnchorState>(await ConfigurationParser.CreateAnchorState(services.BuildServiceProvider()));

            services.AddScoped <IAnchorRecorder>(await ConfigurationParser.CreateAnchorRecorder(services.BuildServiceProvider()));

            services.AddScoped <IMutationValidator>(await ConfigurationParser.CreateRulesValidator(services.BuildServiceProvider()));

            services.AddScoped <TransactionValidator>(ConfigurationParser.CreateTransactionValidator);

            services.AddSingleton <GlobalSettings>(ConfigurationParser.CreateGlobalSettings);

            // Transaction Stream Subscriber
            services.AddSingleton <TransactionStreamSubscriber>(ConfigurationParser.CreateStreamSubscriber);

            // Anchoring
            services.AddSingleton <LedgerAnchorWorker>(ConfigurationParser.CreateLedgerAnchorWorker);
        }