示例#1
0
        private FormatMessagesContextManager.OutputContext CreateOutputContext(FormatMessagesContextManager.OutputContext parentContext, FormatInfoData formatInfoData)
        {
            FormatStartData formatData = formatInfoData as FormatStartData;
            if (formatData != null)
            {
                return new FormatOutputContext(parentContext, formatData);
            }
            GroupStartData data2 = formatInfoData as GroupStartData;
            if (data2 == null)
            {
                return null;
            }
            GroupOutputContext context2 = null;
            switch (this.ActiveFormattingShape)
            {
                case FormatShape.Table:
                    context2 = new TableOutputContext(this, parentContext, data2);
                    break;

                case FormatShape.List:
                    context2 = new ListOutputContext(this, parentContext, data2);
                    break;

                case FormatShape.Wide:
                    context2 = new WideOutputContext(this, parentContext, data2);
                    break;

                case FormatShape.Complex:
                    context2 = new ComplexOutputContext(this, parentContext, data2);
                    break;
            }
            context2.Initialize();
            return context2;
        }
 /// <summary>
 /// construct a context to push on the stack
 /// </summary>
 /// <param name="parentContext">parent context in the stack</param>
 /// <param name="formatData">format data to put in the context</param>
 internal FormatOutputContext(FormatMessagesContextManager.OutputContext parentContext, FormatStartData formatData)
     : base(parentContext)
 {
     Data = formatData;
 }
        /// <summary>
        /// process the current payload object
        /// </summary>
        /// <param name="fed">FormatEntryData to process</param>
        /// <param name="c">currently active context</param>
        private void ProcessPayload(FormatEntryData fed, FormatMessagesContextManager.OutputContext c)
        {
            // we assume FormatEntryData as a standard wrapper
            if (fed == null)
            {
                PSTraceSource.NewArgumentNullException("fed");
            }
            if (fed.formatEntryInfo == null)
            {
                PSTraceSource.NewArgumentNullException("fed.formatEntryInfo");
            }

            WriteStreamType oldWSState = _lo.WriteStream;
            try
            {
                _lo.WriteStream = fed.writeStream;

                if (c == null)
                {
                    ProcessOutOfBandPayload(fed);
                }
                else
                {
                    GroupOutputContext goc = (GroupOutputContext)c;

                    goc.ProcessPayload(fed);
                }
            }
            finally
            {
                _lo.WriteStream = oldWSState;
            }
        }
        /// <summary>
        /// callback for Ge processing
        /// </summary>
        /// <param name="ge">Ge notification message</param>
        /// <param name="c">current context, with Gs in it</param>
        private void ProcessGroupEnd(GroupEndData ge, FormatMessagesContextManager.OutputContext c)
        {
            //Console.WriteLine("ProcessGroupEnd");
            GroupOutputContext goc = (GroupOutputContext)c;

            goc.GroupEnd();
            this.LineOutput.WriteLine("");
        }
        /// <summary>
        /// callback for Gs processing
        /// </summary>
        /// <param name="c">the context containing the Gs entry</param>
        private void ProcessGroupStart(FormatMessagesContextManager.OutputContext c)
        {
            //Console.WriteLine("ProcessGroupStart");
            GroupOutputContext goc = (GroupOutputContext)c;


            if (goc.Data.groupingEntry != null)
            {
                _lo.WriteLine("");

                ComplexWriter writer = new ComplexWriter();
                writer.Initialize(_lo, _lo.ColumnNumber);
                writer.WriteObject(goc.Data.groupingEntry.formatValueList);

                this.LineOutput.WriteLine("");
            }
            goc.GroupStart();
        }
 /// <summary>
 /// callback for Fe processing
 /// </summary>
 /// <param name="fe">Fe notification message</param>
 /// <param name="c">current context, with Fs in it</param>
 private void ProcessFormatEnd(FormatEndData fe, FormatMessagesContextManager.OutputContext c)
 {
     //Console.WriteLine("ProcessFormatEnd");
     // we just add an empty line to the display
     this.LineOutput.WriteLine("");
 }
 /// <summary>
 /// callback for Fs processing
 /// </summary>
 /// <param name="c">the context containing the Fs entry</param>
 private void ProcessFormatStart(FormatMessagesContextManager.OutputContext c)
 {
     // we just add an empty line to the display
     this.LineOutput.WriteLine("");
 }
示例#8
0
 private void ProcessFormatEnd(FormatEndData fe, FormatMessagesContextManager.OutputContext c)
 {
     this.LineOutput.WriteLine("");
 }
示例#9
0
 internal TableOutputContextBase(OutCommandInner cmd, FormatMessagesContextManager.OutputContext parentContext, GroupStartData formatData) : base(cmd, parentContext, formatData)
 {
     this.tableWriter = new TableWriter();
 }
示例#10
0
 internal ListOutputContext(OutCommandInner cmd, FormatMessagesContextManager.OutputContext parentContext, GroupStartData formatData) : base(cmd, parentContext, formatData)
 {
     this.listWriter = new ListWriter();
 }
示例#11
0
 private void ProcessPayload(FormatEntryData fed, FormatMessagesContextManager.OutputContext c)
 {
     if (fed == null)
     {
         PSTraceSource.NewArgumentNullException("fed");
     }
     if (fed.formatEntryInfo == null)
     {
         PSTraceSource.NewArgumentNullException("fed.formatEntryInfo");
     }
     WriteStreamType writeStream = this.lo.WriteStream;
     try
     {
         this.lo.WriteStream = fed.writeStream;
         if (c == null)
         {
             this.ProcessOutOfBandPayload(fed);
         }
         else
         {
             ((GroupOutputContext) c).ProcessPayload(fed);
         }
     }
     finally
     {
         this.lo.WriteStream = writeStream;
     }
 }
示例#12
0
 private void ProcessGroupStart(FormatMessagesContextManager.OutputContext c)
 {
     GroupOutputContext context = (GroupOutputContext) c;
     if (context.Data.groupingEntry != null)
     {
         this.lo.WriteLine("");
         ComplexWriter writer = new ComplexWriter();
         writer.Initialize(this.lo, this.lo.ColumnNumber);
         writer.WriteObject(context.Data.groupingEntry.formatValueList);
         this.LineOutput.WriteLine("");
     }
     context.GroupStart();
 }
示例#13
0
 private void ProcessGroupEnd(GroupEndData ge, FormatMessagesContextManager.OutputContext c)
 {
     ((GroupOutputContext) c).GroupEnd();
     this.LineOutput.WriteLine("");
 }
示例#14
0
 private void ProcessFormatStart(FormatMessagesContextManager.OutputContext c)
 {
     this.LineOutput.WriteLine("");
 }
示例#15
0
 /// <summary>
 /// construct a context to push on the stack
 /// </summary>
 internal GroupOutputContext(OutCommandInner cmd,
                         FormatMessagesContextManager.OutputContext parentContext,
                         GroupStartData formatData)
     : base(parentContext)
 {
     InnerCommand = cmd;
     Data = formatData;
 }
示例#16
0
        /// <summary>
        /// class factory for output context
        /// </summary>
        /// <param name="parentContext">parent context in the stack</param>
        /// <param name="formatInfoData"> fromat info data received from the pipeline</param>
        /// <returns></returns>
        private FormatMessagesContextManager.OutputContext CreateOutputContext(
                                        FormatMessagesContextManager.OutputContext parentContext,
                                        FormatInfoData formatInfoData)
        {
            FormatStartData formatStartData = formatInfoData as FormatStartData;
            // initialize the format context 
            if (formatStartData != null)
            {
                FormatOutputContext foc = new FormatOutputContext(parentContext, formatStartData);

                return foc;
            }

            GroupStartData gsd = formatInfoData as GroupStartData;
            // we are starting a group, initialize the group context
            if (gsd != null)
            {
                GroupOutputContext goc = null;

                switch (ActiveFormattingShape)
                {
                    case FormatShape.Table:
                        {
                            goc = new TableOutputContext(this, parentContext, gsd);
                            break;
                        }

                    case FormatShape.List:
                        {
                            goc = new ListOutputContext(this, parentContext, gsd);
                            break;
                        }

                    case FormatShape.Wide:
                        {
                            goc = new WideOutputContext(this, parentContext, gsd);
                            break;
                        }

                    case FormatShape.Complex:
                        {
                            goc = new ComplexOutputContext(this, parentContext, gsd);
                            break;
                        }

                    default:
                        {
                            Diagnostics.Assert(false, "Invalid shape. This should never happen");
                        }
                        break;
                }
                goc.Initialize();
                return goc;
            }

            return null;
        }
示例#17
0
 /// <summary>
 /// construct a context to push on the stack
 /// </summary>
 /// <param name="cmd">reference to the OutCommandInner instance who owns this instance</param>
 /// <param name="parentContext">parent context in the stack</param>
 /// <param name="formatData">format data to put in the context</param>
 internal TableOutputContext(OutCommandInner cmd,
     FormatMessagesContextManager.OutputContext parentContext,
     GroupStartData formatData)
     : base(cmd, parentContext, formatData)
 {
 }
 internal OutputContext(FormatMessagesContextManager.OutputContext parentContextInStack)
 {
     this.parentContext = parentContextInStack;
 }