Exemplo n.º 1
0
 private void ProcessObject(PSObject input)
 {
     if (this.windowProxy.IsWindowClosed())
     {
         LocalPipeline currentlyRunningPipeline = (LocalPipeline)base.Context.CurrentRunspace.GetCurrentlyRunningPipeline();
         if ((currentlyRunningPipeline != null) && !currentlyRunningPipeline.IsStopping)
         {
             currentlyRunningPipeline.StopAsync();
         }
     }
     else
     {
         object baseObject = input.BaseObject;
         if (((baseObject is ScriptBlock) || (baseObject is SwitchParameter)) || (((baseObject is PSReference) || (baseObject is FormatInfoData)) || (baseObject is PSObject)))
         {
             ErrorRecord errorRecord = new ErrorRecord(new FormatException(StringUtil.Format(FormatAndOut_out_gridview.DataNotQualifiedForGridView, new object[0])), "DataNotQualifiedForGridView", ErrorCategory.InvalidType, null);
             base.ThrowTerminatingError(errorRecord);
         }
         if (this.gridHeader == null)
         {
             this.windowProxy.ShowWindow();
             this.gridHeader = GridHeader.ConstructGridHeader(input, this);
         }
         else
         {
             this.gridHeader.ProcessInputObject(input);
         }
         Exception lastException = this.windowProxy.GetLastException();
         if (lastException != null)
         {
             ErrorRecord record2 = new ErrorRecord(lastException, "ManagementListInvocationException", ErrorCategory.OperationStopped, null);
             base.ThrowTerminatingError(record2);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Execute formatting on a single object.
        /// </summary>
        /// <param name="input">object to process</param>
        private void ProcessObject(PSObject input)
        {
            // Make sure the OGV window is not closed.
            if (_windowProxy.IsWindowClosed())
            {
                LocalPipeline pipeline = (LocalPipeline)this.Context.CurrentRunspace.GetCurrentlyRunningPipeline();

                if (pipeline != null && !pipeline.IsStopping)
                {
                    // Stop the pipeline cleanly.
                    pipeline.StopAsync();
                }

                return;
            }

            object baseObject = input.BaseObject;

            // Throw a terminating error for types that are not supported.
            if (baseObject is ScriptBlock ||
                baseObject is SwitchParameter ||
                baseObject is PSReference ||
                baseObject is FormatInfoData ||
                baseObject is PSObject)
            {
                ErrorRecord error = new ErrorRecord(
                    new FormatException(StringUtil.Format(FormatAndOut_out_gridview.DataNotQualifiedForGridView)),
                    DataNotQualifiedForGridView,
                    ErrorCategory.InvalidType,
                    null);

                this.ThrowTerminatingError(error);
            }

            if (_gridHeader == null)
            {
                // Columns have not been added yet; Start the main window and add columns.
                _windowProxy.ShowWindow();
                _gridHeader = GridHeader.ConstructGridHeader(input, this);
            }
            else
            {
                _gridHeader.ProcessInputObject(input);
            }

            // Some thread synchronization needed.
            Exception exception = _windowProxy.GetLastException();

            if (exception != null)
            {
                ErrorRecord error = new ErrorRecord(
                    exception,
                    "ManagementListInvocationException",
                    ErrorCategory.OperationStopped,
                    null);

                this.ThrowTerminatingError(error);
            }
        }