private void OnProgress(object sender, DataAddedEventArgs e) { var data = (PSDataCollection <ProgressRecord>)sender; ProgressRecord record = data[e.Index]; Write(record.ToString()); }
public override void WriteProgress(long sourceId, ProgressRecord record) { OnWrite(record.ToString()); }
public override void WriteProgress(long sourceId, ProgressRecord record) { outStream.println(record.ToString()); outStream.flush(); }
public override void WriteProgress(long sourceId, ProgressRecord record) { this.OnWrite?.Invoke(record.ToString()); }
/// <summary> /// Sets up the PowerShell shell stream event handlers. /// </summary> /// <param name="shell">The PowerShell shell.</param> private static void SetupStreamEventHandlers(PowerShell shell) { Logger.Instance.WriteMethodEntry(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlers); try { shell.Streams.ClearStreams(); shell.Streams.Error.DataAdded += delegate(object sender, DataAddedEventArgs e) { PSDataCollection <ErrorRecord> errorStream = (PSDataCollection <ErrorRecord>)sender; ErrorRecord record = errorStream[e.Index]; if (record == null) { return; } StringBuilder builder = new StringBuilder(); builder.AppendLine(record.ToString()); if (record.InvocationInfo != null) { builder.AppendLine(); builder.AppendLine(record.InvocationInfo.PositionMessage); } Logger.Instance.WriteError(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlersErrorEvents, builder.ToString()); }; shell.Streams.Warning.DataAdded += delegate(object sender, DataAddedEventArgs e) { PSDataCollection <WarningRecord> warningStream = (PSDataCollection <WarningRecord>)sender; WarningRecord record = warningStream[e.Index]; if (record != null) { Logger.Instance.WriteWarning(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlersWarningEvents, record.ToString()); } }; shell.Streams.Debug.DataAdded += delegate(object sender, DataAddedEventArgs e) { PSDataCollection <DebugRecord> debugStream = (PSDataCollection <DebugRecord>)sender; DebugRecord record = debugStream[e.Index]; if (record != null) { Logger.Instance.WriteInfo(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlersDebugEvents, record.ToString()); } }; shell.Streams.Verbose.DataAdded += delegate(object sender, DataAddedEventArgs e) { PSDataCollection <VerboseRecord> versboseStream = (PSDataCollection <VerboseRecord>)sender; VerboseRecord record = versboseStream[e.Index]; if (record != null) { Logger.Instance.WriteVerbose(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlersEvents, record.ToString()); } }; shell.Streams.Progress.DataAdded += delegate(object sender, DataAddedEventArgs e) { PSDataCollection <ProgressRecord> progressStream = (PSDataCollection <ProgressRecord>)sender; ProgressRecord record = progressStream[e.Index]; if (record != null) { Logger.Instance.WriteInfo(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlersProgressEvents, record.ToString()); } }; } finally { Logger.Instance.WriteMethodExit(EventIdentifier.RunPowerShellScriptSetupStreamEventHandlers); } }
public override void WriteProgress(long sourceId, ProgressRecord record) { LogTo.Debug(record.ToString()); powerShellRunner.LogProgress(record); }