示例#1
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);
        }
示例#2
0
        static void Main(string[] args)
        {
            WriteLine("[Main START] Initializing car factory...");

            var db         = new DbCars();
            var carFactory = new CarFactory(db);

            #region STEP 2. apply after STEP 1. and comment out line #14
            // var carFactory = CarFactory.CreateCarFactory(db);
            #endregion

            WriteLine("Our car factory produces the following models:\n");
            carFactory.Cars.ForEach(WriteLine);

            WriteLine("\n[END] Press any key to exit...");
            ReadLine();
        }