예제 #1
0
        public void GetSystemBatteryState_Task1()
        {
            var battaryState = PowerManagement.GetSystemBatteryState();
            var fields       = typeof(PowerManagement.SystemBatteryState).GetFields(BindingFlags.Public | BindingFlags.Instance);

            Console.WriteLine("System Battery State:\n");
            foreach (var field in fields)
            {
                var value = field.GetValue(battaryState);
                if (field.FieldType.IsArray)
                {
                    var arrayValue = new StringBuilder();
                    foreach (var info in (Array)value)
                    {
                        if (arrayValue.Length > 0)
                        {
                            arrayValue.Append(", ");
                        }

                        arrayValue.Append(info);
                    }

                    Console.WriteLine($"{field.Name}: {arrayValue}");
                }
                else
                {
                    Console.WriteLine($"{field.Name}: {value}");
                }
            }
        }
예제 #2
0
 public void Hibernate_Task1()
 {
     Console.WriteLine($"{(PowerManagement.Hibernate() ? "Good night..." : "Can't sleep")}");
 }
예제 #3
0
 public void Sleep_Task1()
 {
     Console.WriteLine($"{(PowerManagement.Sleep() ? "Bye bye..." : "Can't sleep")}");
 }
예제 #4
0
 public void ReserveHiberFile_Task1()
 {
     Console.WriteLine($"Hibernation file was{(PowerManagement.ReserveHiberFile() ? " succesfully" : "n't")} reserved");
 }
예제 #5
0
 public void LastWakeTime_Task1()
 {
     Console.WriteLine($"Last wake time: {PowerManagement.GetLastWakeTime()}");
 }
예제 #6
0
 public void LastSleepTime_Task1()
 {
     Console.WriteLine($"Last sleep time: {PowerManagement.GetLastSleepTime()}");
 }
예제 #7
0
 public bool Hibernate()
 {
     return(PowerManagement.Hibernate());
 }
예제 #8
0
 public bool Sleep()
 {
     return(PowerManagement.Sleep());
 }
예제 #9
0
 public bool RemoveHiberFile()
 {
     return(PowerManagement.RemoveHiberFile());
 }
예제 #10
0
 public PowerManagement.SystemBatteryState GetSystemBatteryState()
 {
     return(PowerManagement.GetSystemBatteryState());
 }
예제 #11
0
 public DateTime GetLastSleepTime()
 {
     return(PowerManagement.GetLastSleepTime());
 }