コード例 #1
0
 public static PsStreamEventHandlers GetUIHandlers(WorkerContext ctx) => new PsStreamEventHandlers()
 {
     Debug = (o, e) =>
     {
         DebugRecord newRecord = ((PSDataCollection <DebugRecord>)o)[e.Index];
         if (!string.IsNullOrEmpty(newRecord.Message))
         {
             Program.MainFrmInstance.SetStatus(newRecord.Message);
         }
     },
     Error = (o, ev) =>
     {
         ErrorRecord newRecord = ((PSDataCollection <ErrorRecord>)o)[ev.Index];
         MessageBox.Show(newRecord.ToString(), "Powershell Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     },
     Information = (o, e) =>
     {
         InformationalRecord newRecord = ((PSDataCollection <InformationalRecord>)o)[e.Index];
         if (!string.IsNullOrEmpty(newRecord.Message))
         {
             Program.MainFrmInstance.SetStatus(newRecord.Message);
         }
     },
     Progress = (o, ev) =>
     {
         ProgressRecord r = ((PSDataCollection <ProgressRecord>)o)[ev.Index];
         ctx.d.ReportCaption(r.Activity);
         if (r.PercentComplete >= 0 && r.PercentComplete <= 100)
         {
             ctx.d.ReportProgress(r.PercentComplete);
         }
     },
     Verbose = (o, e) =>
     {
         VerboseRecord newRecord = ((PSDataCollection <VerboseRecord>)o)[e.Index];
         if (!string.IsNullOrEmpty(newRecord.Message))
         {
             Program.MainFrmInstance.SetStatus(newRecord.Message);
         }
     },
     Warning = (o, e) =>
     {
         WarningRecord newRecord = ((PSDataCollection <WarningRecord>)o)[e.Index];
         if (!string.IsNullOrEmpty(newRecord.Message))
         {
             Program.MainFrmInstance.SetStatus(newRecord.Message);
         }
     }
 };
コード例 #2
0
ファイル: UniversalStreamRecord.cs プロジェクト: texhex/Xteq5
 public static UniversalStreamRecord FromInformationalRecord(InformationalRecord record)
 {
     return(new UniversalStreamRecord(record.Message, record.InvocationInfo));
 }