public static void ReleaseSoftwareComponent(List <HardwareComponent> computer, string command) { string[] tokens = command.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray(); string hardwareName = tokens[0]; string softwareName = tokens[1]; if (computer.Any(h => h.Name == hardwareName)) { HardwareComponent hardware = computer.Where(h => h.Name == hardwareName).First(); if (hardware.SeeSoftware().Any(s => s.Name == softwareName)) { SoftwareComponent software = hardware.SeeSoftware().Where(s => s.Name == softwareName).First(); hardware.RemoveSoftwareComponent(software); hardware.UsedCapacity -= software.CapacityConsumption; hardware.UsedMemory -= software.MemoryConsumption; } } }
public void RemoveSoftwareComponent(SoftwareComponent software) { this.softwareComponents.Remove(software); }
public void AddSoftwareComponent(SoftwareComponent software) { this.softwareComponents.Add(software); }