コード例 #1
0
        public static void ReconfigureServices()
        {
            var url = File.ReadAllText(@"..\..\..\configurationUrl.url");
            IServiceCollection _serviceCollection = new ServiceCollection();
            var cfgBuilder = new ConfigurationBuilder();

            cfgBuilder.AddInMemoryCollection(new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("ConnectionStrings:ConnectionString", url)
            });
            IConfigurationRoot root = cfgBuilder.Build();

            #region Automapper

            var mapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfiles(typeof(MongoDb.RegisterDependenciesExt).GetTypeInfo().Assembly);
            });
            _serviceCollection.AddSingleton(sp => mapper.CreateMapper());

            #endregion
            _serviceCollection.ConfigureServices(root);
            //IConfigurationSection indexerSettingsSection = configuration.GetSection("IndexerInstanceSettings");
            //IndexerInstanceSettings indexerSettings = indexerSettingsSection.Get<IndexerInstanceSettings>();
            IndexerInstanceSettings indexerSettings = new IndexerInstanceSettings()
            {
                IndexerId    = "EthereumSamurai.IntegrationTest_0",
                StartBlock   = 0,
                ThreadAmount = 1
            };
            //Register jobs and settings
            DependencyConfig.RegisterServices(_serviceCollection, indexerSettings);

            ServiceProvider = _serviceCollection.BuildServiceProvider();
        }
コード例 #2
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(_log)
            .As <ILog>()
            .SingleInstance();

            builder.RegisterType <IHealthService>()
            .As <IHealthService>()
            .SingleInstance();

            #region Automapper

            //Add automapper
            var mapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfiles(typeof(Service.EthereumSamurai.MongoDb.RegisterDependenciesExt).GetTypeInfo().Assembly);
            });
            builder.RegisterInstance(mapper.CreateMapper());

            #endregion

            IConfigurationSection   indexerSettingsSection = _configuration.GetSection("IndexerInstanceSettings");
            IndexerInstanceSettings indexerSettings        = indexerSettingsSection.Get <IndexerInstanceSettings>();
            _services.ConfigureServices(_configuration);
            DependencyConfig.RegisterServices(_services, indexerSettings);
            var baseSettings = _settings.CurrentValue.EthereumIndexer;
            //Console.WriteLine($"Geth node configured at {baseSettings.EthereumRpcUrl}");
            RegisterRabbitQueueEx.RegisterRabbitQueues(_services, baseSettings, _log);
            builder.Populate(_services);
        }