Пример #1
0
        public static void Main()
        {
            #if DEBUG
            Console.SetIn(new System.IO.StreamReader("../../input_1.txt"));
            #endif

            string manufacturerString  = Console.ReadLine();
            var    manufacturerFactory = new ManufacturerFactory();
            var    manufacturer        = manufacturerFactory.Create(manufacturerString);

            var store            = new Store(manufacturer);
            var commandProcessor = new CommandProcessor(store);
            var commandExecutor  = new CommandExecutor(commandProcessor);

            while (true)
            {
                var line = Console.ReadLine();
                if (string.IsNullOrEmpty(line) || line.StartsWith("Exit"))
                {
                    break;
                }

                commandExecutor.Execute(line);
            }
        }
Пример #2
0
        public TimeLogMapperFactory(TaskDataMapper taskDataMapper)
        {
            _taskDataMapper         = taskDataMapper;
            _timeLogMapper          = new TimeLogMapper(taskDataMapper);
            _multiFileTimeLogMapper = new MultiFileTimeLogMapper(taskDataMapper);

            _manufacturer = ManufacturerFactory.GetManufacturer(taskDataMapper);
        }
Пример #3
0
        private static void CreateComputers()
        {
            var manufacturerName = Console.ReadLine();
            var manufacturerFactory = new ManufacturerFactory();
            IComputersFactory computerFactory = manufacturerFactory.GetManufacturer(manufacturerName);

            pc = computerFactory.CreatePersonalComputer();
            laptop = computerFactory.CreateLaptop();
            server = computerFactory.CreateServer();
        }
Пример #4
0
        private void ManufacturerInitializeComputersFromInput()
        {
            var manufacturerName = Console.ReadLine();

            ManufacturerFactory manufacturerCreator = new ManufacturerFactory();

            ComputersFactory manufacturer = manufacturerCreator.CreateManufacturer(manufacturerName);

            this.pc = manufacturer.CreatePc();
            this.laptop = manufacturer.CreateLaptop();
            this.server = manufacturer.CreateServer();
        }
Пример #5
0
        private void ManufacturerInitializeComputersFromInput()
        {
            var manufacturerName = Console.ReadLine();

            ManufacturerFactory manufacturerCreator = new ManufacturerFactory();

            ComputersFactory manufacturer = manufacturerCreator.CreateManufacturer(manufacturerName);

            this.pc     = manufacturer.CreatePc();
            this.laptop = manufacturer.CreateLaptop();
            this.server = manufacturer.CreateServer();
        }
        private static void CreateComputers()
        {
            var manufacturerFactory = new ManufacturerFactory();

            var manufacturerName = Console.ReadLine();
            IComputersFactory computerFactory =
                manufacturerFactory.GetManufacturer(manufacturerName);

            pc     = computerFactory.CreatePersonalComputer();
            laptop = computerFactory.CreateLaptop();
            server = computerFactory.CreateServer();
        }
Пример #7
0
        public static void Main()
        {
            Random random = new Random();
            ManufacturerFactory manufacturerFactory = new ManufacturerFactory(random);
            var manufacturerName = Console.ReadLine();
            IComputerManufacturer computerFactory = manufacturerFactory.GetManufacturerFactory(manufacturerName);
            ILaptopComputer laptop = computerFactory.MakeLaptopComputer();
            IPersonalComputer personalComputer = computerFactory.MakePersonalComputer();
            IServerComputer server = computerFactory.MakeSeverComputer();

            while (true)
            {
                var input = Console.ReadLine();
                if (input == null)
                {
                    break;
                }

                if (input.StartsWith("Exit"))
                {
                    break;
                }

                var commandParts = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (commandParts.Length != 2)
                {
                    // throw new ArgumentException("Invalid command!");
                    Console.WriteLine("Invalid command!");
                }

                var commandName = commandParts[0];
                var commandArgument = int.Parse(commandParts[1]);

                if (commandName == "Charge")
                {
                    laptop.ChargeBattery(commandArgument);
                }
                else if (commandName == "Process")
                {
                    server.Process(commandArgument);
                }
                else if (commandName == "Play")
                {
                    personalComputer.Play(commandArgument);
                }
                else
                {
                    // continue;
                    Console.WriteLine("Invalid command!");
                }
            }
        }
Пример #8
0
        public ProductMapper(TaskDataMapper taskDataMapper, ProductGroupMapper productGroupMapper) : base(taskDataMapper, "PDT")
        {
            _productGroupMapper = productGroupMapper;

            _manufacturer = ManufacturerFactory.GetManufacturer(taskDataMapper);
        }
        public async Task InitFactories(string url, string account)
        {
            string       baseUrl  = url;
            const string password = "";

            ProductFactory         = new ProductFactory(baseUrl, account, password);
            CategoryFactory        = new CategoryFactory(baseUrl, account, password);
            StockFactory           = new StockAvailableFactory(baseUrl, account, password);
            FeatureValuesFactory   = new ProductFeatureValueFactory(baseUrl, account, password);
            ImageFactory           = new ImageFactory(baseUrl, account, password);
            ProductSupplierFactory = new ProductSupplierFactory(baseUrl, account, password);

            ManufacturerFactory = new ManufacturerFactory(baseUrl, account, password);

            SpecialPriceFactory = new SpecificPriceFactory(baseUrl, account, password);

            var featuresFactory = new ProductFeatureFactory(baseUrl, account, password);
            var features        = await featuresFactory.GetAll();

            //SizeFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Размер", StringComparison.OrdinalIgnoreCase));
            //ColorFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Цвет", StringComparison.OrdinalIgnoreCase));

            BatteryFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Батарейки", StringComparison.OrdinalIgnoreCase));
            if (BatteryFeature == null)
            {
                BatteryFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Батарейки")
                    }
                };
                BatteryFeature = await featuresFactory.Add(BatteryFeature);
            }

            MaterialFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Материал", StringComparison.OrdinalIgnoreCase));
            if (MaterialFeature == null)
            {
                MaterialFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Материал")
                    }
                };
                MaterialFeature = await featuresFactory.Add(MaterialFeature);
            }

            CountryFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Страна", StringComparison.OrdinalIgnoreCase));
            if (CountryFeature == null)
            {
                CountryFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Страна")
                    }
                };
                CountryFeature = await featuresFactory.Add(CountryFeature);
            }

            PackingFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Упаковка", StringComparison.OrdinalIgnoreCase));
            if (PackingFeature == null)
            {
                PackingFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Упаковка")
                    }
                };
                PackingFeature = await featuresFactory.Add(PackingFeature);
            }

            LengthFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Длина", StringComparison.OrdinalIgnoreCase));
            if (LengthFeature == null)
            {
                LengthFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Длина")
                    }
                };
                LengthFeature = await featuresFactory.Add(LengthFeature);
            }

            DiameterFeature = features.FirstOrDefault(f => f.name.First().Value.Equals("Диаметр", StringComparison.OrdinalIgnoreCase));
            if (DiameterFeature == null)
            {
                DiameterFeature = new product_feature()
                {
                    name = new List <language> {
                        new language(1, "Диаметр")
                    }
                };
                DiameterFeature = await featuresFactory.Add(DiameterFeature);
            }

            var optionsFactory = new ProductOptionFactory(baseUrl, account, password);
            var options        = await optionsFactory.GetAll();

            SizeOption = options.FirstOrDefault(f => f.name.First().Value.Equals("size", StringComparison.OrdinalIgnoreCase));
            if (SizeOption == null)
            {
                Log.Error("Size option not found, add size option!");
                throw new Exception("Size option not found");
            }

            ColorOption = options.FirstOrDefault(f => f.name.First().Value.Equals("color", StringComparison.OrdinalIgnoreCase));
            if (ColorOption == null)
            {
                Log.Error("Color option not found, add size option!");
                throw new Exception("Color option not found");
            }

            OptionsValueFactory = new ProductOptionValueFactory(baseUrl, account, password);

            CombinationFactory = new CombinationFactory(baseUrl, account, password);

            SupplierFactory = new SupplierFactory(baseUrl, account, password);
            Suppliers       = await SupplierFactory.GetAll();

            if (!Suppliers.Any())
            {
                throw new Exception("Suppliers not found, add them manualy");
            }
        }
Пример #10
0
 public void Setup()
 {
     factory = new ManufacturerFactory(TestUrl, TestApiKey, null);
 }