private void RegisterComponent(string component) { int startIndexOfComponentArguments = component.IndexOf('('); string typeComponent = component.Substring(0, startIndexOfComponentArguments); string[] componentArguments = SplitByMultipleChars( component.Substring(startIndexOfComponentArguments)); if (typeComponent.Contains("Hardware")) { IComponentHardware newHardware = hardwareFactory.CreateHardware( typeComponent, componentArguments[0], int.Parse(componentArguments[1]), int.Parse(componentArguments[2])); this.newMachine.AddHardwareItem(newHardware); } else { IComponentSoftware newSoftware = softwareFactory.CreateSoftware(typeComponent, componentArguments[1], int.Parse(componentArguments[2]), int.Parse(componentArguments[3])); this.newMachine.AddSoftwareItem(componentArguments[0], newSoftware); } }
public void ReleaseSoftwareComponent(string nameOfHardware, string softwareComponent) { var hardware = GetHardwareItem(nameOfHardware); if (hardware != null) { IComponentSoftware componentToRemove = hardware.SoftwareComponets .SingleOrDefault(x => x.Name == softwareComponent); hardware.SoftwareComponets.Remove(componentToRemove); } }
public void AddSoftwareItem(string hardwareItem, IComponentSoftware item) { var hardwareType = this.hardwareComponents. FirstOrDefault(x => x.Name == hardwareItem); if (hardwareType != null && item.MemoryConsumption <= hardwareType.MaxMemory && item.CapacityConsumption <= hardwareType.MaxCapacity) { hardwareType.AddSoftwareComponent(item); } }
public IComponentSoftware CreateSoftware(string type, string name, int capacity, int memory) { IComponentSoftware componentSoftware = null; switch (type) { case "LightSoftware": return(componentSoftware = new LightSoftware(name, capacity, memory)); break; case "ExpressSoftware": return(componentSoftware = new ExpressSoftware(name, capacity, memory)); break; } return(componentSoftware); }
public void AddSoftwareComponent(IComponentSoftware softwareComponent) { this.SoftwareComponets.Add(softwareComponent); }