当前位置: 首页>>代码示例>>C#>>正文


C# ManagementObject.GetText方法代码示例

本文整理汇总了C#中System.Management.ManagementObject.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementObject.GetText方法的具体用法?C# ManagementObject.GetText怎么用?C# ManagementObject.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.ManagementObject的用法示例。


在下文中一共展示了ManagementObject.GetText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ModifyDevice

 public static int ModifyDevice(this ManagementObject VM, ManagementObject Device, out ManagementObject Job)
 {
     Job = null;
     switch (VM["__CLASS"].ToString().ToUpperInvariant())
     {
         case "MSVM_COMPUTERSYSTEM":
             ManagementObject ServiceObj = GetServiceObject(VM.GetScope(), ServiceNames.VSManagement);
             Job = new ManagementObject();
             return (Int32)ServiceObj.InvokeMethod("ModifyVirtualSystemResources",
                                     new object[] { VM.Path.Path, Device.GetText(TextFormat.WmiDtd20), null, Job });
         default:
             return -1;
     }
 }
开发者ID:virmitio,项目名称:TempRepo,代码行数:14,代码来源:Utility.cs

示例2: AddDevice

        public static ManagementObject AddDevice(this ManagementObject VM, ManagementObject Device)
        {
            switch (VM["__CLASS"].ToString().ToUpperInvariant())
            {
                case "MSVM_COMPUTERSYSTEM":
                    ManagementObject ServiceObj = GetServiceObject(VM.GetScope(), ServiceNames.VSManagement);
                    ManagementBaseObject inputs = ServiceObj.GetMethodParameters("AddVirtualSystemResources");
                    inputs["TargetSystem"] = VM.Path.Path;
                    inputs["ResourceSettingData"] = new string[]{Device.GetText(TextFormat.WmiDtd20)};
                    var result = ServiceObj.InvokeMethod("AddVirtualSystemResources", inputs, null);
                    switch (Int32.Parse(result["ReturnValue"].ToString()))
                    {
                        case (int)ReturnCodes.OK:
                            var tmp = result["NewResources"];
                            return GetObject(((string[])result["NewResources"]).First());
                        case (int)ReturnCodes.JobStarted:
                            var job = GetObject(result["Job"].ToString());
                            var r = WaitForJob(job);
                            if (r == 0)
                            {
                                var res = result["NewResources"];
                                var arr = (string[])res;
                                var path = arr.First();
                                var o = GetObject(path);
                                return GetObject(((string[])result["NewResources"]).First());
                            }
                            var jobres = job.InvokeMethod("GetError", new ManagementObject(), null);
                            var errStr = jobres["Error"].ToString();
                            var errObj = GetObject(errStr);
                            return null;
                        default:
                            return null;
                    }

                default:
                    return null;
            }
        }
开发者ID:virmitio,项目名称:TempRepo,代码行数:38,代码来源:Utility.cs

示例3: GetMofFormat

		private static string GetMofFormat(ManagementObject obj)
		{
			return string.Concat(obj.GetText(TextFormat.Mof).Replace("\n", "\r\n"), "\r\n");
		}
开发者ID:nickchal,项目名称:pash,代码行数:4,代码来源:SchemaNaming.cs

示例4: AddVirtualMachineResources

        private ManagementObject AddVirtualMachineResources(ManagementObject objVm, ManagementObject resource)
        {
            if (resource == null)
                return resource;

            // request management service
            ManagementObject objVmsvc = GetVirtualSystemManagementService();

            // add resources
            string txtResource = resource.GetText(TextFormat.CimDtd20);
            ManagementBaseObject inParams = objVmsvc.GetMethodParameters("AddVirtualSystemResources");
            inParams["TargetSystem"] = objVm;
            inParams["ResourceSettingData"] = new string[] { txtResource };
            ManagementBaseObject outParams = objVmsvc.InvokeMethod("AddVirtualSystemResources", inParams, null);
            JobResult result = CreateJobResultFromWmiMethodResults(outParams);

            if (result.ReturnValue == ReturnCode.OK)
            {
                string[] wmiPaths = (string[])outParams["NewResources"];
                return wmi.GetWmiObjectByPath(wmiPaths[0]);
            }
            else if (result.ReturnValue == ReturnCode.JobStarted)
            {
                if (JobCompleted(result.Job))
                {
                    string[] wmiPaths = (string[])outParams["NewResources"];
                    return wmi.GetWmiObjectByPath(wmiPaths[0]);
                }
                else
                {
                    throw new Exception("Cannot add virtual machine resources");
                }
            }
            else
            {
                throw new Exception("Cannot add virtual machine resources: " + txtResource);
            }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:38,代码来源:HyperV.cs

示例5: GetMofFormat

 static string GetMofFormat(ManagementObject obj)
 {
     return obj.GetText(TextFormat.Mof).Replace("\n", "\r\n") + "\r\n";
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:SchemaRegistration.cs


注:本文中的System.Management.ManagementObject.GetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。