예제 #1
0
        public CarFactory(IDbCars db)
        {
            _ = db ??
                throw new ArgumentNullException(nameof(db));

            // NOTE: sync-over-async, might deadlock, i.e we are blocking!
            Cars = db.GetCarsQueryAsync().Result.ToList();
        }
예제 #2
0
        public static async Task <CarFactory> CreateCarFactory(IDbCars db)
        {
            _ = db ??
                throw new ArgumentNullException(nameof(db));

            var cars       = (await db.GetCarsQueryAsync()).ToList();
            var carFactory = new CarFactory(cars);

            return(carFactory);
        }