コード例 #1
0
        public PowerPlan ToPowerPlan()
        {
            var result = new PowerPlan();

            result.Name = this.wmiPowerPlan.GetPropertyValue("ElementName").ToString();
            result.Description = this.wmiPowerPlan.GetPropertyValue("Description").ToString();

            String instanceId = this.wmiPowerPlan.GetPropertyValue("InstanceID").ToString();
            result.InstanceId = instanceId;

            int guidStringLength = 38;

            Guid guid = Guid.Empty;

            if (instanceId.Length >= guidStringLength && Guid.TryParse(instanceId.Substring(instanceId.Length - guidStringLength, guidStringLength), out guid))
            {
                result.Id = guid;
            }

            bool isActive;
            if(Boolean.TryParse(this.wmiPowerPlan.GetPropertyValue("IsActive").ToString(), out isActive))
            {
                result.IsActive = isActive;
            }

            result.WmiPowerPlan = this.wmiPowerPlan;

            return result;
        }
コード例 #2
0
 public PowerPlanViewModel(PowerPlan model)
 {
     this.model = model;
 }