Esempio n. 1
0
 private static void WriteResult(PowerShellResult result)
 {
     if (!string.IsNullOrEmpty(result.Error()))
     {
         var defaultForegroundColor = Console.ForegroundColor;
         var defaultBackgroundColor = Console.BackgroundColor;
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(result.Error());
         Console.ForegroundColor = defaultForegroundColor;
         Console.BackgroundColor = defaultBackgroundColor;
     }
     if (!string.IsNullOrEmpty(result.Warning()))
     {
         var defaultForegroundColor = Console.ForegroundColor;
         var defaultBackgroundColor = Console.BackgroundColor;
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine(result.Warning());
         Console.ForegroundColor = defaultForegroundColor;
         Console.BackgroundColor = defaultBackgroundColor;
     }
     if (!string.IsNullOrEmpty(result.Result()))
     {
         Console.WriteLine(result.Result());
     }
 }
Esempio n. 2
0
        private static PowerShellResult Execute(PowerShellProcess powerShellProcess, Outputs output)
        {
            PowerShellResult result;

            switch (output)
            {
            case Outputs.json:
                result = powerShellProcess.ExecuteToJson();
                break;

            case Outputs.table:
                result = powerShellProcess.Execute();
                break;

            default:
                result = new PowerShellResult();
                break;
            }
            return(result);
        }