public VMConfig GetVMConfig(string VMName)
        {
            VMConfig currentVMConfig = new VMConfig();

            using (System.IO.StreamReader file = System.IO.File.OpenText(VMconfigPath))
            {
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    JObject o = (JObject)JToken.ReadFrom(reader);

                    if (o.ContainsKey(VMName))
                    {
                        JObject vmObj = ((JObject)o[VMName]);
                        currentVMConfig.VMName     = Convert.ToString(vmObj["VMName"].ToString());
                        currentVMConfig.Installed  = Convert.ToBoolean(vmObj["Installed"].ToString());
                        currentVMConfig.CPUNum     = Convert.ToInt32(vmObj["CPUCount"].ToString());
                        currentVMConfig.MemorySize = Convert.ToUInt64(vmObj["PowerOnMemorySize"].ToString());
                        currentVMConfig.CPULimt    = Convert.ToInt32(vmObj["CPULimit"].ToString());
                    }
                    else
                    {
                        Console.WriteLine("配置文件中无该虚拟机:" + VMName);
                        return(null);
                    }
                }
            }
            return(currentVMConfig);
        }
        public VMState()
        {
            ManagementScope  scope;
            ManagementObject managementService;

            scope             = new ManagementScope(@"\\.\root\virtualization\v2", null);
            managementService = WmiUtilities.GetVirtualMachineManagementService(scope);

            GetConfig configParser = new GetConfig();

            VM1Config = configParser.GetVMConfig("VM1");
            if (VM1Config != null)
            {
                VM1 = new VirtualMachine(VM1Config.VMName, scope, managementService);
            }
            VM2Config = configParser.GetVMConfig("VM2");
            if (VM2Config != null)
            {
                VM2 = new VirtualMachine(VM2Config.VMName, scope, managementService);
            }
            VM3Config = configParser.GetVMConfig("VM3");
            if (VM3Config != null)
            {
                VM3 = new VirtualMachine(VM3Config.VMName, scope, managementService);
            }
            DockerVMConfig = configParser.GetVMConfig("Docker");
        }
        public VMState(string MpcVMConfigPath)
        {
            GetConfig configParser = new GetConfig();

            VM1Config = configParser.GetVMConfig("VM1");
            VM2Config = configParser.GetVMConfig("VM2");
            VM3Config = configParser.GetVMConfig("VM3");

            configParser.currentMpcVMInfo = configParser.GetMpcVMInfo(MpcVMConfigPath, "LocalVM");
            if (configParser.currentMpcVMInfo.Installed == true)
            {
                ManagementScope  scope;
                ManagementObject managementService;

                scope             = new ManagementScope(@"\\.\root\virtualization\v2", null);
                managementService = WmiUtilities.GetVirtualMachineManagementService(scope);
                VM1 = new VirtualMachine("LocalVM", scope, managementService);
            }
            configParser.currentMpcVMInfo = configParser.GetMpcVMInfo(MpcVMConfigPath, "NetVM1");
            if (configParser.currentMpcVMInfo.Installed == true)
            {
                ManagementScope  scope;
                ManagementObject managementService;

                scope             = new ManagementScope(@"\\.\root\virtualization\v2", null);
                managementService = WmiUtilities.GetVirtualMachineManagementService(scope);
                VM2 = new VirtualMachine("NetVM1", scope, managementService);
            }
            configParser.currentMpcVMInfo = configParser.GetMpcVMInfo(MpcVMConfigPath, "NetVM2");
            if (configParser.currentMpcVMInfo.Installed == true)
            {
                ManagementScope  scope;
                ManagementObject managementService;

                scope             = new ManagementScope(@"\\.\root\virtualization\v2", null);
                managementService = WmiUtilities.GetVirtualMachineManagementService(scope);
                VM3 = new VirtualMachine("NetVM2", scope, managementService);
            }
        }