private bool Read()
        {
            this.AssertReaderIsOpen();
            this.currentRecord = null;
            PSDataCollection <PSObject> output = this.asyncResult.Output;

            if (this.WaitOne(output))
            {
                this.currentRecord = output[0];
                output.RemoveAt(0);
            }
            if (this.currentRecord == null && this.shellProxy.Errors != null && this.shellProxy.Errors.Count != 0 && this.shellProxy.Errors[0].Exception != null)
            {
                try
                {
                    throw this.shellProxy.Errors[0].Exception;
                }
                finally
                {
                    this.Close();
                }
            }
            if (this.shellProxy != null && this.shellProxy.Warnings != null && this.shellProxy.Warnings.Count != 0)
            {
                foreach (WarningRecord warningRecord in this.shellProxy.Warnings)
                {
                    this.writeWarning(new LocalizedString(warningRecord.Message));
                }
            }
            if (this.currentRecord == null)
            {
                this.Close();
            }
            return(null != this.currentRecord);
        }
        // Token: 0x06001067 RID: 4199 RVA: 0x00031FC8 File Offset: 0x000301C8
        public override bool Read()
        {
            ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "MonadDataReader.Read()");
            this.AssertReaderIsOpen();
            if (this.command.ActivePipeline == null)
            {
                throw new InvalidOperationException("The command has been canceled.");
            }
            this.currentRecord = null;
            PSDataCollection <PSObject> output = this.asyncResult.Output;

            if (this.WaitOne(output))
            {
                PSObject psobject = output[0];
                output.RemoveAt(0);
                this.lastResult = this.UnWrappPSObject(psobject);
                if (this.isRemote && psobject.BaseObject is PSCustomObject && this.lastResult != psobject.BaseObject)
                {
                    psobject = new PSObject(this.lastResult);
                }
                this.currentRecord = psobject;
                this.recordsAffected++;
            }
            ExTraceGlobals.VerboseTracer.Information <bool>((long)this.GetHashCode(), "<--MonadDataReader.Read(), {0}", null != this.currentRecord);
            return(null != this.currentRecord);
        }
        // Token: 0x0600105A RID: 4186 RVA: 0x00031C54 File Offset: 0x0002FE54
        internal MonadDataReader(MonadCommand command, CommandBehavior behavior, MonadAsyncResult asyncResult)
        {
            ExTraceGlobals.IntegrationTracer.Information <string, CommandBehavior>((long)this.GetHashCode(), "--> new MonadDataReader({0}, {1})", command.CommandText, behavior);
            this.command         = command;
            this.commandBehavior = behavior;
            this.connection      = command.Connection;
            this.isRemote        = command.Connection.IsRemote;
            this.asyncResult     = asyncResult;
            PSDataCollection <PSObject> output = asyncResult.Output;

            this.command.ActivePipeline.InvocationStateChanged += this.PipelineStateChanged;
            output.DataAdded += this.PipelineDataAdded;
            if (this.WaitOne(output))
            {
                ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "\tFirst result ready.");
                PSObject          psobject          = output[0];
                PagedPositionInfo pagedPositionInfo = this.UnWrappPSObject(psobject) as PagedPositionInfo;
                if (pagedPositionInfo != null)
                {
                    ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "\tPagedPositionInfo object found.");
                    output.RemoveAt(0);
                    this.positionInfo = pagedPositionInfo;
                    psobject          = null;
                    if (this.WaitOne(output))
                    {
                        psobject = output[0];
                    }
                }
                if (psobject != null)
                {
                    ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "\tFirst object returned, generating schema.");
                    this.GenerateSchema(psobject);
                    this.firstResult = this.UnWrappPSObject(psobject);
                }
            }
            ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "<-- new MonadDataReader()");
        }
Beispiel #4
0
		private static void MergeError_DataAdded(object sender, DataAddedEventArgs e, PSDataCollection<ErrorRecord> errors)
		{
			if (errors != null)
			{
				errors.RemoveAt(0);
			}
		}