Exemplo n.º 1
0
        //ToDo: make async versions
        public static ComputerInventory FromConfigurationFile(this ComputerInventory me, string path)
        {
            if (path == string.Empty)
            {
                throw new ArgumentNullException(nameof(path));
            }
            string            computerName;
            ComputerHardware  lcH;
            ComputerSoftware  lcS;
            ComputerProcesses lcP;

            // Use JSON as the default structure
            //var computerInventory = FromJson<ComputerInventory>();
            // Just read the file into a
            // If using XML,
            // open the path as a stream, setup async buffered read, read into a structured format, catch exceptions
            // Get the hardware by selecting a node range in the structured format
            // lcH=new ComputerHardware().FromStructuredFormat(path);
            // ToDo: add "FromComputerName" extension method to ComputerSoftware and ComputerProcesses
            lcH          = me.ComputerHardware;
            lcS          = me.ComputerSoftware;
            lcP          = me.ComputerProcesses;
            computerName = me.ComputerName;
            return(new ComputerInventory(lcH, lcS, lcP, computerName));
        }
Exemplo n.º 2
0
        public static ComputerInventory FromComputerName(this ComputerInventory me, string computerName)
        {
            if (computerName == string.Empty)
            {
                throw new ArgumentNullException(nameof(computerName));
            }
            ComputerHardware  lcH;
            ComputerSoftware  lcS;
            ComputerProcesses lcP;

            switch (computerName.Trim().ToLowerInvariant())
            {
            //ToDo: read actual inventory, currently specific for laptop
            case "localhost":
                // Get the hardware
                lcH = new ComputerHardware().FromComputerName(computerName);
                // ToDo: add "FromComputerName" extension method to ComputerSoftware and ComputerProcesses
                lcS = me.ComputerSoftware;
                lcP = me.ComputerProcesses;
                break;

            default:
                throw new NotImplementedException($"cannot populate ComputerInventory object from computerName = {computerName}");
            }

            ComputerInventory lCI = new ComputerInventory()
            {
                ComputerName = computerName, ComputerHardware = lcH, ComputerSoftware = lcS, ComputerProcesses = lcP
            };

            return(lCI);
        }
 //ToDo: Implement writing a ComputerInventory object to a set of Configuration Settings
 public static Dictionary <string, string> ToConfigurationSettings(this ComputerInventory computerInventory)
 {
     throw new NotImplementedException();
 }
 public static ComputerInventory InventoryThisComputer(this ComputerInventory computerInventory)
 {
     throw new NotImplementedException();
 }