public DbContext(ICursesService cursesService) { _dbSingleton = DbSingleton.GetInstanceAsync(cursesService) .ConfigureAwait(false) .GetAwaiter() .GetResult(); }
public static async Task <DbSingleton> GetInstanceAsync(ICursesService cursesService) { await LazyInitializer(cursesService); return(_lazyInstance.Value); }
private static async Task LazyInitializer(ICursesService cursesService) { _lazyInstance = new Lazy <DbSingleton>(() => new DbSingleton(cursesService), LazyThreadSafetyMode.ExecutionAndPublication); _lazyInstance.Value.Valutes = await _lazyInstance.Value._cursesService.GetValutes(); }
private DbSingleton(ICursesService cursesService) { _cursesService = cursesService; }