Exemplo n.º 1
0
        private void OnProgress(object sender, DataAddedEventArgs e)
        {
            var            data   = (PSDataCollection <ProgressRecord>)sender;
            ProgressRecord record = data[e.Index];

            Write(record.ToString());
        }
Exemplo n.º 2
0
 public override void WriteProgress(long sourceId, ProgressRecord record)
 {
     OnWrite(record.ToString());
 }
Exemplo n.º 3
0
 public override void WriteProgress(long sourceId, ProgressRecord record)
 {
     outStream.println(record.ToString());
     outStream.flush();
 }
Exemplo n.º 4
0
 public override void WriteProgress(long sourceId, ProgressRecord record)
 {
     this.OnWrite?.Invoke(record.ToString());
 }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
 public override void WriteProgress(long sourceId, ProgressRecord record)
 {
     LogTo.Debug(record.ToString());
     powerShellRunner.LogProgress(record);
 }