Пример #1
0
        /// <summary>
        ///     Compose the application according to the supplied configuration
        /// </summary>
        /// <param name="services">The service collection to register services into.</param>
        /// <param name="applicationConfiguration">Application configuration.</param>
        public static void Configure(IServiceCollection services, ApplicationConfiguration applicationConfiguration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddSingleton(applicationConfiguration);
            services.AddSingleton(typeof(ExecutionEnvironment), implementationInstance: applicationConfiguration.Environment);
            services.AddHttpContextAccessor();

            services.AddSingleton <IRandomSource, DefaultRandomSource>();

            SecurityServices.ConfigureWalletSalt(services: services, walletSaltString: applicationConfiguration.WalletSalt);

            EthereumAccountsSetup.Configure(services);

            string configurationFolder = ApplicationConfigLocator.ConfigurationFilesPath;

            AlertDispatcherSetup.Configure(services: services, configuration: applicationConfiguration.Configuration, pluginsPath: configurationFolder);

            CommonMiddlewareServicesSetup.Configure(services: services);
            CommonServicesSetup.Configure(services);

            ContractsSetup.Configure(services);

            EthereumServices.ConfigureEthereumServices(services: services, configuration: applicationConfiguration);

            DatabaseSetup.Configure(services: services, configuration: applicationConfiguration.SqlServerConfiguration);

            ServiceInterfacesSetup.Configure(services);
            ServiceInterfaceHubSetup.Configure(services);

            ObjectLockingSetup.Configure(serviceCollection: services, applicationConfiguration.Environment.IsLocalOrTest());

            LogicSetup.Configure(services: services,
                                 faucetConfiguration: applicationConfiguration.FaucetConfiguration,
                                 faucetBalanceConfiguration: applicationConfiguration.FaucetBalanceConfiguration,
                                 houseAlerterConfiguration: applicationConfiguration.HouseBalanceConfiguration);
        }