public List <Antivirus> AntivirusInstalled() { using (PowerShell powerShell = PowerShell.Create()) { var antivurusesList = new List <Antivirus>(); powerShell.AddScript("Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntivirusProduct"); Collection <PSObject> antivuruses = powerShell.Invoke(); foreach (var antivurus in antivuruses) { var antivirusLocal = new Antivirus(); foreach (var prop in antivurus.Properties) { if (prop.Name == "displayName") { antivirusLocal.name = prop.Value.ToString(); } if (prop.Name == "productState") { antivirusLocal.productState = prop.Value.ToString(); } } antivurusesList.Add(antivirusLocal); } return(antivurusesList); } }
static void Main(string[] args) { Task copySecurity = new Backup(); Task antivirus = new Antivirus(); ICommand StartBackUp = new StartBackUpCommand(copySecurity); ICommand StopBackUp = new StopBackUpCommand(copySecurity); ICommand StartAntivirusCommand = new StartAntivirusCommand(antivirus); ICommand StopAntivirusCommand = new StopAntivirusCommand(antivirus); IInvoker TaskPlanner = new TaskPlanner(); TaskPlanner.SetCommand(StartBackUp); TaskPlanner.Invoke(); TaskPlanner.SetCommand(StopBackUp); TaskPlanner.Invoke(); Console.WriteLine("\n"); TaskPlanner.SetCommand(StartAntivirusCommand); TaskPlanner.Invoke(); TaskPlanner.SetCommand(StopAntivirusCommand); TaskPlanner.Invoke(); Console.ReadKey(); }
private Antivirus GetAntivirus() { var objectCollection = new ManagementObjectSearcher(@"root\SecurityCenter2", "SELECT * FROM AntiVirusProduct").Get(); var antivirusName = ""; foreach (ManagementObject virusChecker in objectCollection) { antivirusName += virusChecker["displayName"].ToString() + " "; } return(Antivirus.Create(antivirusName, (objectCollection.Count > 0))); }
protected override void OnInitialize() { _antivirus = null; _capture = null; _timedActivation = null; _consumableActivation = null; if (Entity.TryGetComponent(out _itemType) && Entity.TryGetComponent(out _currentLocation) && Entity.TryGetComponent(out _owner) && Entity.TryGetComponent(out _activation)) { _selectionOptions.SetActive(false); var spriteName = _itemType.GetType().Name.ToLowerInvariant(); _descriptionText.GetComponent <TextLocalization>().Key = spriteName.ToUpperInvariant() + "_DESCRIPTION"; LogProxy.Info($"Creating item type: {spriteName}"); gameObject.name = $"{Name}_{spriteName}"; _foregroundSprite.sprite = Resources.Load <Sprite>(spriteName); _foregroundText.text = string.Empty; Entity.TryGetComponent(out _timedActivation); Entity.TryGetComponent(out _antivirus); Entity.TryGetComponent(out _capture); Entity.TryGetComponent(out _consumableActivation); UpdateColour(); _midgroundSprite.enabled = false; _midgroundSprite.type = Image.Type.Simple; //TODO: extract item specific logic to subclasses InitializeAntivirus(); InitializeCapture(); UpdateInventory(); } else { throw new EntityInitializationException($"Could not load all required components for Entity Id {Entity.Id}"); } }
public static Color GetColourForGenome(this Antivirus antivirus) { return(antivirus.TargetGenome.GetColourForGenome()); }
public Machine RegisterNewMachine() { try { var HardDrives = new List <HardDrive>(); HardDrives.Add(HardDrive.Create("C:/", 1000000, 10000000)); HardDrives.Add(HardDrive.Create("E:/", 1000000, 10000000)); var randomMachine = Machine.Create("Random-Machine-Name", "192.0.2.235", Antivirus.Create("Avast-XPTO", false), GetOSVersion(), GetRuntimeInstalledVersion(), true, HardDrives); var response = _context.Machines.Add(randomMachine); _context.SaveChanges(); Log.Information($"Machine created: Id: {response.Entity.Id} Name: {response.Entity.Name}"); return(response.Entity); } catch (Exception ex) { Log.Information($"RegisterNewMachine Repository Exception {ex.Message} {ex.InnerException.Message}"); throw; } }