示例#1
0
        public void AddDevice(string device = "", string name = "", string fabricator = "")
        {
            DatabaseMapping databaseMapping = null;

            switch (device)
            {
            case "clock":
                Clock clock = new Clock(name);
                _deviceContext.Clocks.Add(clock);
                databaseMapping = new DatabaseMapping {
                    DeviceTypeId = 1, Clock = clock
                };
                break;

            case "microwave":
                MicrowaveFabricatorInfo mi = microwaveFabricatorInfo[fabricator];
                Microwave microwave        = new Microwave(name, mi.Volume, mi.Lamp);
                _deviceContext.Microwaves.Add(microwave);
                databaseMapping = new DatabaseMapping {
                    DeviceTypeId = 2, Microwave = microwave
                };
                break;

            case "oven":
                OvenFabricatorInfo oi = ovenFabricatorInfo[fabricator];
                Oven oven             = new Oven(name, oi.Volume, oi.Lamp);
                _deviceContext.Ovens.Add(oven);
                databaseMapping = new DatabaseMapping {
                    DeviceTypeId = 3, Oven = oven
                };
                break;

            case "fridge":
                FridgeFabricatorInfo fi = fridgeFabricatorInfo[fabricator];
                Fridge fridge           = new Fridge(name, fi.Coldstore, fi.Freezer);
                _deviceContext.Fridges.Add(fridge);
                databaseMapping = new DatabaseMapping {
                    DeviceTypeId = 4, Fridge = fridge
                };
                break;

            default: return;
            }
            _deviceContext.DatabaseMappings.Add(databaseMapping);
            _deviceContext.SaveChanges();
        }
示例#2
0
 private void InitOvenFabricatorInfo()
 {
     ovenFabricatorInfo["Siemens"]    = new OvenFabricatorInfo(67, new Lamp(25));
     ovenFabricatorInfo["Electrolux"] = new OvenFabricatorInfo(74, new Lamp(25));
     ovenFabricatorInfo["Pyramida"]   = new OvenFabricatorInfo(56, new Lamp(15));
 }