public CreateDocumentViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory, Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository, BotService botService, GuidService guidService, BlockChainConfiguration config, AccountService accountService) : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository, botService) { this.guidService = guidService; this.config = config; this.accountService = accountService; }
public CreateAccountViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory, Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository, BotService botService, AccountService accountService, GuidService guidService, BlockChainConfiguration config, StateSynchronizer stateSynchronizer) : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository, botService) { this.accountService = accountService; this.guidService = guidService; this.config = config; RemoteState = CommandFactory.Create(async() => { await stateSynchronizer.SetStartState(Identifier); }); }
public BlockChainController(BotService botService, GuidService guidService, AccountService accountService, PageNavigator navigator, UserProvider userProvider, IDocumentDataRepository documentDataRepository, IUserDataRepository userDataRepository, BlockChainConfiguration configuration) { this.botService = botService; this.guidService = guidService; this.accountService = accountService; this.navigator = navigator; this.userProvider = userProvider; this.documentDataRepository = documentDataRepository; this.userDataRepository = userDataRepository; this.configuration = configuration; }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); #if DEBUG services.AddDbContext <UserDataDbContext>(ServiceLifetime.Transient); var conn = "SqlDB"; services.Configure <SqlServerConfiguration>(options => { options.ConnectionString = conn; }); #elif DEV || STAGE services.AddEntityFrameworkNpgsql() .AddDbContext <UserDataDbContext>(ServiceLifetime.Transient); services.Configure <SqlServerConfiguration>(options => { options.ConnectionString = Environment.GetEnvironmentVariable(EnvironmentVariables.Postgre); }); #endif var container = new Container(rules => rules.WithoutThrowOnRegisteringDisposableTransient()); var botConfiguration = new BotConfiguration { BotToken = Environment.GetEnvironmentVariable(EnvironmentVariables.BotToken), LoggerBotToken = Environment.GetEnvironmentVariable(EnvironmentVariables.LoggerBotToken) }; container.UseInstance(botConfiguration); var blockChainConfiguration = new BlockChainConfiguration { BlockChainAddress = Environment.GetEnvironmentVariable(EnvironmentVariables.BlockChainAddress) }; container.UseInstance(blockChainConfiguration); IocModule.Load(container); ViewLib.IocModule.Load(container); var apiClient = new HttpClient { Timeout = TimeSpan.FromSeconds(2), }; container.UseInstance(apiClient); container.UseInstance <Func <DateTimeOffset> >(() => DateTimeOffset.UtcNow); var redisHost = Environment.GetEnvironmentVariable(EnvironmentVariables.RedisHost); var redisPort = Environment.GetEnvironmentVariable(EnvironmentVariables.RedisPort); var textWriter = new TraceWriter(); #if RELEASE || STAGE var redisPassword = Environment.GetEnvironmentVariable(EnvironmentVariables.RedisPassword); container.UseInstance <Func <ConnectionMultiplexer> >( () => ConnectionMultiplexer.Connect($"{redisHost}:{redisPort},allowAdmin=true,password={redisPassword}", textWriter)); #elif DEBUG || DEV var redisIp = System.Net.Dns.GetHostEntryAsync(redisHost).Result.AddressList.Last(); container.UseInstance <Func <ConnectionMultiplexer> >(() => ConnectionMultiplexer.Connect($"{redisIp}:{redisPort}", textWriter)); #endif var serviceProvider = container.WithDependencyInjectionAdapter(services, throwIfUnresolved: type => true); #if RELEASE || STAGE || DEBUG || DEV || TECHWORKS BurnUp(serviceProvider); var stateSynchronizer = container.Resolve <StateSynchronizer>(); SynchronizerInit(stateSynchronizer); #endif UserDataDbContext DbContextFactory() => serviceProvider.Resolve <UserDataDbContext>(); serviceProvider.UseInstance((Func <UserDataDbContext>)DbContextFactory); Container = serviceProvider.BuildServiceProvider(); return(Container); }