private static void DiscardJobOutputs(Job job, JobOutputs jobOutputsToDiscard)
 {
     if (JobOutputs.Output == (jobOutputsToDiscard & JobOutputs.Output))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <PSObject>(job.Output);
     }
     if (JobOutputs.Error == (jobOutputsToDiscard & JobOutputs.Error))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <ErrorRecord>(job.Error);
     }
     if (JobOutputs.Warning == (jobOutputsToDiscard & JobOutputs.Warning))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <WarningRecord>(job.Warning);
     }
     if (JobOutputs.Verbose == (jobOutputsToDiscard & JobOutputs.Verbose))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <VerboseRecord>(job.Verbose);
     }
     if (JobOutputs.Debug == (jobOutputsToDiscard & JobOutputs.Debug))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <DebugRecord>(job.Debug);
     }
     if (JobOutputs.Progress == (jobOutputsToDiscard & JobOutputs.Progress))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <ProgressRecord>(job.Progress);
     }
     if (JobOutputs.Results == (jobOutputsToDiscard & JobOutputs.Results))
     {
         SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs <PSStreamObject>(job.Results);
     }
 }
        private void HandleJobOutput(Job job, TSession sessionForJob, bool discardNonPipelineResults, Action <PSObject> outputAction)
        {
            Action <PSObject> processOutput = delegate(PSObject pso)
            {
                if ((pso != null) && (outputAction != null))
                {
                    outputAction(pso);
                }
            };

            job.Output.DataAdded += delegate(object sender, DataAddedEventArgs eventArgs)
            {
                PSDataCollection <PSObject> datas = (PSDataCollection <PSObject>)sender;
                if (discardNonPipelineResults)
                {
                    foreach (PSObject obj2 in datas.ReadAll())
                    {
                        processOutput(obj2);
                    }
                }
                else
                {
                    PSObject obj3 = datas[eventArgs.Index];
                    processOutput(obj3);
                }
            };
            if (discardNonPipelineResults)
            {
                SessionBasedCmdletAdapter <TObjectInstance, TSession> .DiscardJobOutputs(job, JobOutputs.Progress | JobOutputs.Debug | JobOutputs.Verbose | JobOutputs.Warning | JobOutputs.Error);
            }
        }