Esempio n. 1
0
        private void ProcessCachedGroupOnTable(TableHeaderInfo thi, List <PacketInfoData> objects)
        {
            if (thi.tableColumnInfoList.Count == 0)
            {
                return;
            }

            int[] widths = new int[thi.tableColumnInfoList.Count];

            for (int k = 0; k < thi.tableColumnInfoList.Count; k++)
            {
                string label = thi.tableColumnInfoList[k].label;

                if (string.IsNullOrEmpty(label))
                {
                    label = thi.tableColumnInfoList[k].propertyName;
                }

                if (string.IsNullOrEmpty(label))
                {
                    widths[k] = 0;
                }
                else
                {
                    widths[k] = _lo.DisplayCells.Length(label);
                }
            }

            int cellCount; // scratch variable

            foreach (PacketInfoData o in objects)
            {
                FormatEntryData fed = o as FormatEntryData;

                if (fed == null)
                {
                    continue;
                }

                TableRowEntry tre = fed.formatEntryInfo as TableRowEntry;
                int           kk  = 0;

                foreach (FormatPropertyField fpf in tre.formatPropertyFieldList)
                {
                    cellCount = _lo.DisplayCells.Length(fpf.propertyValue);
                    if (widths[kk] < cellCount)
                    {
                        widths[kk] = cellCount;
                    }

                    kk++;
                }
            }

            TableFormattingHint hint = new TableFormattingHint();

            hint.columnWidths = widths;
            _formattingHint   = hint;
        }
        internal static FormatEntryData GenerateOutOfBandData(TerminatingErrorContext errorContext, PSPropertyExpressionFactory expressionFactory,
                                                              TypeInfoDataBase db, PSObject so, int enumerationLimit, bool useToStringFallback, out List <ErrorRecord> errors)
        {
            errors = null;

            var            typeNames = so.InternalTypeNames;
            ViewDefinition view      = DisplayDataQuery.GetOutOfBandView(expressionFactory, db, typeNames);

            ViewGenerator outOfBandViewGenerator;

            if (view != null)
            {
                // process an out of band view retrieved from the display database
                if (view.mainControl is ComplexControlBody)
                {
                    outOfBandViewGenerator = new ComplexViewGenerator();
                }
                else
                {
                    outOfBandViewGenerator = new ListViewGenerator();
                }

                outOfBandViewGenerator.Initialize(errorContext, expressionFactory, db, view, null);
            }
            else
            {
                if (DefaultScalarTypes.IsTypeInList(typeNames) ||
                    !HasNonRemotingProperties(so))
                {
                    // we force a ToString() on well known types
                    return(GenerateOutOfBandObjectAsToString(so));
                }

                if (!useToStringFallback)
                {
                    return(null);
                }

                // we must check we have enough properties for a list view
                if (new PSPropertyExpression("*").ResolveNames(so).Count == 0)
                {
                    return(null);
                }

                // we do not have a view, we default to list view
                // process an out of band view as a default
                outOfBandViewGenerator = new ListViewGenerator();
                outOfBandViewGenerator.Initialize(errorContext, expressionFactory, so, db, null);
            }

            FormatEntryData fed = outOfBandViewGenerator.GeneratePayload(so, enumerationLimit);

            fed.outOfBand   = true;
            fed.writeStream = so.WriteStream;

            errors = outOfBandViewGenerator.ErrorManager.DrainFailedResultList();

            return(fed);
        }
Esempio n. 3
0
            internal override void ProcessPayload(FormatEntryData fed)
            {
                ComplexViewEntry formatEntryInfo = fed.formatEntryInfo as ComplexViewEntry;

                if ((formatEntryInfo != null) && (formatEntryInfo.formatValueList != null))
                {
                    this.writer.WriteObject(formatEntryInfo.formatValueList);
                }
            }
        private void SendCommentOutOfBand(string msg)
        {
            FormatEntryData fed = OutOfBandFormatViewManager.GenerateOutOfBandObjectAsToString(PSObjectHelper.AsPSObject(msg));

            if (fed != null)
            {
                this.WriteObject(fed);
            }
        }
Esempio n. 5
0
        private void UpdateObjectCount(PacketInfoData o)
        {
            FormatEntryData data = o as FormatEntryData;

            if ((data != null) && !data.outOfBand)
            {
                this.currentObjectCount++;
            }
        }
Esempio n. 6
0
            /// <summary>
            /// write a row into the list
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;

                InternalInitialize(lve);
                string[] values = GetValues(lve);
                _listWriter.WriteProperties(values, this.InnerCommand._lo);
                this.InnerCommand._lo.WriteLine("");
            }
Esempio n. 7
0
        /// <summary>
        /// test if an object coming from the pipeline needs to be
        /// preprocessed by the default formatter
        /// </summary>
        /// <param name="o">object to examine for formatting</param>
        /// <returns>whether the object needs to be shunted to preprocessing</returns>
        private bool NeedsPreprocessing(object o)
        {
            FormatEntryData fed = o as FormatEntryData;

            if (fed != null)
            {
                // we got an already pre-processed object
                if (!fed.outOfBand)
                {
                    // we allow out of band data in any state
                    ValidateCurrentFormattingState(FormattingState.InsideGroup, o);
                }
                return(false);
            }
            else if (o is FormatStartData)
            {
                // when encountering FormatStartDate out of sequence,
                // pretend that the previous formatting directives were properly closed
                if (_currentFormattingState == FormattingState.InsideGroup)
                {
                    this.EndProcessing();
                    this.BeginProcessing();
                }

                // we got a Fs message, we enter a sequence
                ValidateCurrentFormattingState(FormattingState.Reset, o);
                _currentFormattingState = FormattingState.Formatting;

                return(false);
            }
            else if (o is FormatEndData)
            {
                // we got a Fe message, we exit a sequence
                ValidateCurrentFormattingState(FormattingState.Formatting, o);
                _currentFormattingState = FormattingState.Reset;

                return(false);
            }
            else if (o is GroupStartData)
            {
                ValidateCurrentFormattingState(FormattingState.Formatting, o);
                _currentFormattingState = FormattingState.InsideGroup;

                return(false);
            }
            else if (o is GroupEndData)
            {
                ValidateCurrentFormattingState(FormattingState.InsideGroup, o);
                _currentFormattingState = FormattingState.Formatting;

                return(false);
            }

            // this is a raw object
            return(true);
        }
        private void WritePayloadObject(PSObject so)
        {
            FormatEntryData o = this.viewManager.ViewGenerator.GeneratePayload(so, this.enumerationLimit);

            o.SetStreamTypeFromPSObject(so);
            this.WriteObject(o);
            List <ErrorRecord> errorRecordList = this.viewManager.ViewGenerator.ErrorManager.DrainFailedResultList();

            this.WriteErrorRecords(errorRecordList);
        }
        internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
        {
            FormatEntryData fed = new FormatEntryData();

            if (this.dataBaseInfo.view != null)
                fed.formatEntryInfo = GenerateComplexViewEntryFromDataBaseInfo(so, enumerationLimit);
            else
                fed.formatEntryInfo = GenerateComplexViewEntryFromProperties(so, enumerationLimit);
            return fed;
        }
        internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
        {
            FormatEntryData fed = new FormatEntryData();

            if (this.dataBaseInfo.view != null)
                fed.formatEntryInfo = GenerateComplexViewEntryFromDataBaseInfo(so, enumerationLimit);
            else
                fed.formatEntryInfo = GenerateComplexViewEntryFromProperties(so, enumerationLimit);
            return fed;
        }
Esempio n. 11
0
            /// <summary>
            /// write a row into the list
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry;

                if (cve == null || cve.formatValueList == null)
                {
                    return;
                }
                _writer.WriteObject(cve.formatValueList);
            }
Esempio n. 12
0
            internal override void ProcessPayload(FormatEntryData fed)
            {
                WideViewEntry       formatEntryInfo     = fed.formatEntryInfo as WideViewEntry;
                FormatPropertyField formatPropertyField = formatEntryInfo.formatPropertyField;

                this.buffer.Add(formatPropertyField.propertyValue);
                if (this.buffer.IsFull)
                {
                    this.WriteStringBuffer();
                }
            }
Esempio n. 13
0
 internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
 {
     FormatEntryData data = new FormatEntryData();
     if (base.dataBaseInfo.view != null)
     {
         data.formatEntryInfo = this.GenerateComplexViewEntryFromDataBaseInfo(so, enumerationLimit);
         return data;
     }
     data.formatEntryInfo = this.GenerateComplexViewEntryFromProperties(so, enumerationLimit);
     return data;
 }
Esempio n. 14
0
            /// <summary>
            /// write a row into the table
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                WideViewEntry       wve = fed.formatEntryInfo as WideViewEntry;
                FormatPropertyField fpf = wve.formatPropertyField as FormatPropertyField;

                _buffer.Add(fpf.propertyValue);
                if (_buffer.IsFull)
                {
                    WriteStringBuffer();
                }
            }
Esempio n. 15
0
 internal static FormatEntryData GenerateOutOfBandObjectAsToString(PSObject so)
 {
     FormatEntryData data = new FormatEntryData {
         outOfBand = true
     };
     RawTextFormatEntry entry = new RawTextFormatEntry {
         text = so.ToString()
     };
     data.formatEntryInfo = entry;
     return data;
 }
        /// <summary>
        /// write a payplad object by properly wrapping it into
        /// a FormatEntry object
        /// </summary>
        /// <param name="so">object to process</param>
        private void WritePayloadObject(PSObject so)
        {
            Diagnostics.Assert(so != null, "object so cannot be null");
            FormatEntryData fed = _viewManager.ViewGenerator.GeneratePayload(so, _enumerationLimit);

            fed.SetStreamTypeFromPSObject(so);
            this.WriteObject(fed);

            List <ErrorRecord> errors = _viewManager.ViewGenerator.ErrorManager.DrainFailedResultList();

            WriteErrorRecords(errors);
        }
Esempio n. 17
0
        internal static FormatEntryData GenerateOutOfBandObjectAsToString(PSObject so)
        {
            FormatEntryData data = new FormatEntryData {
                outOfBand = true
            };
            RawTextFormatEntry entry = new RawTextFormatEntry {
                text = so.ToString()
            };

            data.formatEntryInfo = entry;
            return(data);
        }
Esempio n. 18
0
        internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
        {
            FormatEntryData data = new FormatEntryData();

            if (base.dataBaseInfo.view != null)
            {
                data.formatEntryInfo = this.GenerateListViewEntryFromDataBaseInfo(so, enumerationLimit);
                return(data);
            }
            data.formatEntryInfo = this.GenerateListViewEntryFromProperties(so, enumerationLimit);
            return(data);
        }
Esempio n. 19
0
        private void ProcessOutOfBandPayload(FormatEntryData fed)
        {
            // try if it is raw text
            RawTextFormatEntry rte = fed.formatEntryInfo as RawTextFormatEntry;

            if (rte != null)
            {
                if (fed.isHelpObject)
                {
                    ComplexWriter complexWriter = new ComplexWriter();

                    complexWriter.Initialize(_lo, _lo.ColumnNumber);
                    complexWriter.WriteString(rte.text);
                }
                else
                {
                    _lo.WriteLine(rte.text);
                }

                return;
            }

            // try if it is a complex entry
            ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry;

            if (cve != null && cve.formatValueList != null)
            {
                ComplexWriter complexWriter = new ComplexWriter();

                complexWriter.Initialize(_lo, int.MaxValue);
                complexWriter.WriteObject(cve.formatValueList);

                return;
            }
            // try if it is a list view
            ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;

            if (lve != null && lve.listViewFieldList != null)
            {
                ListWriter listWriter = new ListWriter();

                _lo.WriteLine("");

                string[] properties = ListOutputContext.GetProperties(lve);
                listWriter.Initialize(properties, _lo.ColumnNumber, _lo.DisplayCells);
                string[] values = ListOutputContext.GetValues(lve);
                listWriter.WriteProperties(values, _lo);

                _lo.WriteLine("");

                return;
            }
        }
Esempio n. 20
0
        private void UpdateObjectCount(PacketInfoData o)
        {
            // add only of it's not a control message
            // and it's not out of band
            FormatEntryData fed = o as FormatEntryData;

            if (fed == null || fed.outOfBand)
            {
                return;
            }

            _currentObjectCount++;
        }
Esempio n. 21
0
        internal static FormatEntryData GenerateOutOfBandObjectAsToString(PSObject so)
        {
            FormatEntryData fed = new FormatEntryData();

            fed.outOfBand = true;

            RawTextFormatEntry rawTextEntry = new RawTextFormatEntry();

            rawTextEntry.text   = so.ToString();
            fed.formatEntryInfo = rawTextEntry;

            return(fed);
        }
        internal void Process(object o)
        {
            PacketInfoData  formatData      = o as PacketInfoData;
            FormatEntryData formatEntryData = formatData as FormatEntryData;

            if (formatEntryData != null)
            {
                OutputContext c = null;
                if (!formatEntryData.outOfBand)
                {
                    c = (OutputContext)this.stack.Peek();
                }
                this.payload(formatEntryData, c);
            }
            else
            {
                bool flag  = formatData is FormatStartData;
                bool flag2 = formatData is GroupStartData;
                if (flag || flag2)
                {
                    OutputContext context2 = this.contextCreation(this.ActiveOutputContext, formatData);
                    this.stack.Push(context2);
                    if (flag)
                    {
                        this.fs(context2);
                    }
                    else if (flag2)
                    {
                        this.gs(context2);
                    }
                }
                else
                {
                    GroupEndData  fe    = formatData as GroupEndData;
                    FormatEndData data4 = formatData as FormatEndData;
                    if ((fe != null) || (data4 != null))
                    {
                        OutputContext context3 = (OutputContext)this.stack.Peek();
                        if (data4 != null)
                        {
                            this.fe(data4, context3);
                        }
                        else if (fe != null)
                        {
                            this.ge(fe, context3);
                        }
                        this.stack.Pop();
                    }
                }
            }
        }
Esempio n. 23
0
        internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
        {
            FormatEntryData fed = new FormatEntryData();

            if (this.dataBaseInfo.view != null)
            {
                fed.formatEntryInfo = GenerateListViewEntryFromDataBaseInfo(so, enumerationLimit);
            }
            else
            {
                fed.formatEntryInfo = GenerateListViewEntryFromProperties(so, enumerationLimit);
            }
            return(fed);
        }
Esempio n. 24
0
 private void Notify()
 {
     if (this.notificationCallBack != null)
     {
         List <PacketInfoData> objects = new List <PacketInfoData>();
         foreach (PacketInfoData data in this.queue)
         {
             FormatEntryData data2 = data as FormatEntryData;
             if ((data2 == null) || !data2.outOfBand)
             {
                 objects.Add(data);
             }
         }
         this.notificationCallBack(this.formatStartData, objects);
     }
 }
        private bool ProcessOutOfBand(PSObject so, bool isProcessingError)
        {
            List <ErrorRecord> list;
            FormatEntryData    o = OutOfBandFormatViewManager.GenerateOutOfBandData(base.TerminatingErrorContext, this.expressionFactory, this._typeInfoDataBase, so, this.enumerationLimit, true, out list);

            if (!isProcessingError)
            {
                this.WriteErrorRecords(list);
            }
            if (o != null)
            {
                this.WriteObject(o);
                return(true);
            }
            return(false);
        }
Esempio n. 26
0
 private void ProcessCachedGroupOnTable(TableHeaderInfo thi, List <PacketInfoData> objects)
 {
     if (thi.tableColumnInfoList.Count != 0)
     {
         int[] numArray = new int[thi.tableColumnInfoList.Count];
         for (int i = 0; i < thi.tableColumnInfoList.Count; i++)
         {
             string label = thi.tableColumnInfoList[i].label;
             if (string.IsNullOrEmpty(label))
             {
                 label = thi.tableColumnInfoList[i].propertyName;
             }
             if (string.IsNullOrEmpty(label))
             {
                 numArray[i] = 0;
             }
             else
             {
                 numArray[i] = this.lo.DisplayCells.Length(label);
             }
         }
         foreach (PacketInfoData data in objects)
         {
             FormatEntryData data2 = data as FormatEntryData;
             if (data2 != null)
             {
                 TableRowEntry formatEntryInfo = data2.formatEntryInfo as TableRowEntry;
                 int           index           = 0;
                 foreach (FormatPropertyField field in formatEntryInfo.formatPropertyFieldList)
                 {
                     int num2 = this.lo.DisplayCells.Length(field.propertyValue);
                     if (numArray[index] < num2)
                     {
                         numArray[index] = num2;
                     }
                     index++;
                 }
             }
         }
         TableFormattingHint hint = new TableFormattingHint {
             columnWidths = numArray
         };
         this.formattingHint = hint;
     }
 }
Esempio n. 27
0
        private void WriteNewLineObject()
        {
            FormatEntryData fed = new FormatEntryData();

            fed.outOfBand = true;

            ComplexViewEntry cve = new ComplexViewEntry();
            FormatEntry      fe  = new FormatEntry();

            cve.formatValueList.Add(fe);

            // Formating system writes newline before each object
            // so no need to add newline here like:
            //     fe.formatValueList.Add(new FormatNewLine());
            fed.formatEntryInfo = cve;

            this.WriteObject(fed);
        }
Esempio n. 28
0
        internal static FormatEntryData GenerateOutOfBandData(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, PSObject so, int enumerationLimit, bool useToStringFallback, out List <ErrorRecord> errors)
        {
            ViewGenerator generator;

            errors = null;
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            ViewDefinition     view = DisplayDataQuery.GetOutOfBandView(expressionFactory, db, internalTypeNames);

            if (view != null)
            {
                if (view.mainControl is ComplexControlBody)
                {
                    generator = new ComplexViewGenerator();
                }
                else
                {
                    generator = new ListViewGenerator();
                }
                generator.Initialize(errorContext, expressionFactory, db, view, null);
            }
            else
            {
                if (DefaultScalarTypes.IsTypeInList(internalTypeNames) || IsPropertyLessObject(so))
                {
                    return(GenerateOutOfBandObjectAsToString(so));
                }
                if (!useToStringFallback)
                {
                    return(null);
                }
                if (new MshExpression("*").ResolveNames(so).Count <= 0)
                {
                    return(null);
                }
                generator = new ListViewGenerator();
                generator.Initialize(errorContext, expressionFactory, so, db, null);
            }
            FormatEntryData data = generator.GeneratePayload(so, enumerationLimit);

            data.outOfBand = true;
            data.SetStreamTypeFromPSObject(so);
            errors = generator.ErrorManager.DrainFailedResultList();
            return(data);
        }
Esempio n. 29
0
        private bool NeedsPreprocessing(object o)
        {
            FormatEntryData data = o as FormatEntryData;

            if (data != null)
            {
                if (!data.outOfBand)
                {
                    this.ValidateCurrentFormattingState(FormattingState.InsideGroup, o);
                }
                return(false);
            }
            if (o is FormatStartData)
            {
                if (this.currentFormattingState == FormattingState.InsideGroup)
                {
                    this.EndProcessing();
                    this.BeginProcessing();
                }
                this.ValidateCurrentFormattingState(FormattingState.Reset, o);
                this.currentFormattingState = FormattingState.Formatting;
                return(false);
            }
            if (o is FormatEndData)
            {
                this.ValidateCurrentFormattingState(FormattingState.Formatting, o);
                this.currentFormattingState = FormattingState.Reset;
                return(false);
            }
            if (o is GroupStartData)
            {
                this.ValidateCurrentFormattingState(FormattingState.Formatting, o);
                this.currentFormattingState = FormattingState.InsideGroup;
                return(false);
            }
            if (o is GroupEndData)
            {
                this.ValidateCurrentFormattingState(FormattingState.InsideGroup, o);
                this.currentFormattingState = FormattingState.Formatting;
                return(false);
            }
            return(true);
        }
        private bool ProcessOutOfBand(PSObject so, bool isProcessingError)
        {
            List <ErrorRecord> errors;
            FormatEntryData    fed = OutOfBandFormatViewManager.GenerateOutOfBandData(this.TerminatingErrorContext, _expressionFactory,
                                                                                      _typeInfoDataBase, so, _enumerationLimit, true, out errors);

            if (!isProcessingError)
            {
                WriteErrorRecords(errors);
            }

            if (fed != null)
            {
                this.WriteObject(fed);
                return(true);
            }

            return(false);
        }
        protected void WriteInternalErrorMessage(string message)
        {
            FormatEntryData o = new FormatEntryData {
                outOfBand = true
            };
            ComplexViewEntry entry = new ComplexViewEntry();
            FormatEntry      item  = new FormatEntry();

            entry.formatValueList.Add(item);
            item.formatValueList.Add(new FormatNewLine());
            FormatTextField field = new FormatTextField {
                text = message
            };

            item.formatValueList.Add(field);
            item.formatValueList.Add(new FormatNewLine());
            o.formatEntryInfo = entry;
            this.WriteObject(o);
        }
Esempio n. 32
0
        private void ProcessOutOfBandPayload(FormatEntryData fed)
        {
            RawTextFormatEntry formatEntryInfo = fed.formatEntryInfo as RawTextFormatEntry;

            if (formatEntryInfo != null)
            {
                if (fed.isHelpObject)
                {
                    ComplexWriter writer = new ComplexWriter();
                    writer.Initialize(this.lo, this.lo.ColumnNumber);
                    writer.WriteString(formatEntryInfo.text);
                }
                else
                {
                    this.lo.WriteLine(formatEntryInfo.text);
                }
            }
            else
            {
                ComplexViewEntry entry2 = fed.formatEntryInfo as ComplexViewEntry;
                if ((entry2 != null) && (entry2.formatValueList != null))
                {
                    ComplexWriter writer2 = new ComplexWriter();
                    writer2.Initialize(this.lo, this.lo.ColumnNumber);
                    writer2.WriteObject(entry2.formatValueList);
                }
                else
                {
                    ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;
                    if ((lve != null) && (lve.listViewFieldList != null))
                    {
                        ListWriter writer3 = new ListWriter();
                        this.lo.WriteLine("");
                        string[] properties = ListOutputContext.GetProperties(lve);
                        writer3.Initialize(properties, this.lo.ColumnNumber, this.lo.DisplayCells);
                        string[] values = ListOutputContext.GetValues(lve);
                        writer3.WriteProperties(values, this.lo);
                        this.lo.WriteLine("");
                    }
                }
            }
        }
 private bool ProcessOutOfBandObjectOutsideDocumentSequence(PSObject so)
 {
     if (this.ShouldProcessOutOfBand)
     {
         List <ErrorRecord> list;
         FormatEntryData    o = null;
         if (so.InternalTypeNames.Count == 0)
         {
             return(false);
         }
         o = OutOfBandFormatViewManager.GenerateOutOfBandData(base.TerminatingErrorContext, this.expressionFactory, this._typeInfoDataBase, so, this.enumerationLimit, false, out list);
         this.WriteErrorRecords(list);
         if (o != null)
         {
             this.WriteObject(o);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 34
0
 internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
 {
     TableRowEntry entry;
     FormatEntryData data = new FormatEntryData();
     if (base.dataBaseInfo.view != null)
     {
         entry = this.GenerateTableRowEntryFromDataBaseInfo(so, enumerationLimit);
     }
     else
     {
         entry = this.GenerateTableRowEntryFromFromProperties(so, enumerationLimit);
         entry.multiLine = base.dataBaseInfo.db.defaultSettingsSection.MultilineTables;
     }
     data.formatEntryInfo = entry;
     if ((base.parameters != null) && (base.parameters.shapeParameters != null))
     {
         TableSpecificParameters shapeParameters = (TableSpecificParameters) base.parameters.shapeParameters;
         if ((shapeParameters != null) && shapeParameters.multiLine.HasValue)
         {
             entry.multiLine = shapeParameters.multiLine.Value;
         }
     }
     return data;
 }
Esempio n. 35
0
            /// <summary>
            /// write a row into the table
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                int headerColumns = this.CurrentTableHeaderInfo.tableColumnInfoList.Count;

                if (headerColumns == 0)
                {
                    return;
                }

                TableRowEntry tre = fed.formatEntryInfo as TableRowEntry;

                // need to make sure we have matching counts: the header count will have to prevail
                string[] values = new string[headerColumns];
                int[] alignment = new int[headerColumns];

                int fieldCount = tre.formatPropertyFieldList.Count;

                for (int k = 0; k < headerColumns; k++)
                {
                    if (k < fieldCount)
                    {
                        values[k] = tre.formatPropertyFieldList[k].propertyValue;
                        alignment[k] = tre.formatPropertyFieldList[k].alignment;
                    }
                    else
                    {
                        values[k] = "";
                        alignment[k] = TextAlignment.Left; // hard coded default
                    }
                }
                this.Writer.GenerateRow(values, this.InnerCommand._lo, tre.multiLine, alignment, InnerCommand._lo.DisplayCells);
            }
Esempio n. 36
0
        private void ProcessOutOfBandPayload(FormatEntryData fed)
        {
            // try if it is raw text
            RawTextFormatEntry rte = fed.formatEntryInfo as RawTextFormatEntry;
            if (rte != null)
            {
                if (fed.isHelpObject)
                {
                    ComplexWriter complexWriter = new ComplexWriter();

                    complexWriter.Initialize(_lo, _lo.ColumnNumber);
                    complexWriter.WriteString(rte.text);
                }
                else
                {
                    _lo.WriteLine(rte.text);
                }

                return;
            }

            // try if it is a complex entry
            ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry;
            if (cve != null && cve.formatValueList != null)
            {
                ComplexWriter complexWriter = new ComplexWriter();

                complexWriter.Initialize(_lo, _lo.ColumnNumber);
                complexWriter.WriteObject(cve.formatValueList);

                return;
            }
            // try if it is a list view
            ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;
            if (lve != null && lve.listViewFieldList != null)
            {
                ListWriter listWriter = new ListWriter();

                _lo.WriteLine("");

                string[] properties = ListOutputContext.GetProperties(lve);
                listWriter.Initialize(properties, _lo.ColumnNumber, _lo.DisplayCells);
                string[] values = ListOutputContext.GetValues(lve);
                listWriter.WriteProperties(values, _lo);

                _lo.WriteLine("");

                return;
            }
        }
Esempio n. 37
0
 /// <summary>
 /// called when there is an entry to process, overrides will do
 /// things such as writing a row in a table
 /// </summary>
 /// <param name="fed">FormatEntryData to process</param>
 internal virtual void ProcessPayload(FormatEntryData fed) { }
Esempio n. 38
0
 /// <summary>
 /// write a row into the list
 /// </summary>
 /// <param name="fed">FormatEntryData to process</param>
 internal override void ProcessPayload(FormatEntryData fed)
 {
     ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry;
     if (cve == null || cve.formatValueList == null)
         return;
     _writer.WriteObject(cve.formatValueList);
 }
Esempio n. 39
0
        /// <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;
            }
        }
Esempio n. 40
0
 /// <summary>
 /// write a row into the list
 /// </summary>
 /// <param name="fed">FormatEntryData to process</param>
 internal override void ProcessPayload(FormatEntryData fed)
 {
     ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;
     InternalInitialize(lve);
     string[] values = GetValues(lve);
     _listWriter.WriteProperties(values, this.InnerCommand._lo);
     this.InnerCommand._lo.WriteLine("");
 }
Esempio n. 41
0
 /// <summary>
 /// write a row into the table
 /// </summary>
 /// <param name="fed">FormatEntryData to process</param>
 internal override void ProcessPayload(FormatEntryData fed)
 {
     WideViewEntry wve = fed.formatEntryInfo as WideViewEntry;
     FormatPropertyField fpf = wve.formatPropertyField as FormatPropertyField;
     _buffer.Add(fpf.propertyValue);
     if (_buffer.IsFull)
     {
         WriteStringBuffer();
     }
 }
Esempio n. 42
0
 private void ProcessOutOfBandPayload(FormatEntryData fed)
 {
     RawTextFormatEntry formatEntryInfo = fed.formatEntryInfo as RawTextFormatEntry;
     if (formatEntryInfo != null)
     {
         if (fed.isHelpObject)
         {
             ComplexWriter writer = new ComplexWriter();
             writer.Initialize(this.lo, this.lo.ColumnNumber);
             writer.WriteString(formatEntryInfo.text);
         }
         else
         {
             this.lo.WriteLine(formatEntryInfo.text);
         }
     }
     else
     {
         ComplexViewEntry entry2 = fed.formatEntryInfo as ComplexViewEntry;
         if ((entry2 != null) && (entry2.formatValueList != null))
         {
             ComplexWriter writer2 = new ComplexWriter();
             writer2.Initialize(this.lo, this.lo.ColumnNumber);
             writer2.WriteObject(entry2.formatValueList);
         }
         else
         {
             ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;
             if ((lve != null) && (lve.listViewFieldList != null))
             {
                 ListWriter writer3 = new ListWriter();
                 this.lo.WriteLine("");
                 string[] properties = ListOutputContext.GetProperties(lve);
                 writer3.Initialize(properties, this.lo.ColumnNumber, this.lo.DisplayCells);
                 string[] values = ListOutputContext.GetValues(lve);
                 writer3.WriteProperties(values, this.lo);
                 this.lo.WriteLine("");
             }
         }
     }
 }
Esempio n. 43
0
        internal override FormatEntryData GeneratePayload(PSObject so, int enumerationLimit)
        {
            FormatEntryData fed = new FormatEntryData();

            TableRowEntry tre;
            if (this.dataBaseInfo.view != null)
            {
                tre = GenerateTableRowEntryFromDataBaseInfo(so, enumerationLimit);
            }
            else
            {
                tre = GenerateTableRowEntryFromFromProperties(so, enumerationLimit);
                // get the global setting for multiline
                tre.multiLine = this.dataBaseInfo.db.defaultSettingsSection.MultilineTables;
            }
            fed.formatEntryInfo = tre;

            // override from command line, if there
            if (this.parameters != null && this.parameters.shapeParameters != null)
            {
                TableSpecificParameters tableSpecific = (TableSpecificParameters)this.parameters.shapeParameters;
                if (tableSpecific != null && tableSpecific.multiLine.HasValue)
                {
                    tre.multiLine = tableSpecific.multiLine.Value;
                }
            }
            return fed;
        }
Esempio n. 44
0
 internal override void ProcessPayload(FormatEntryData fed)
 {
     ComplexViewEntry formatEntryInfo = fed.formatEntryInfo as ComplexViewEntry;
     if ((formatEntryInfo != null) && (formatEntryInfo.formatValueList != null))
     {
         this.writer.WriteObject(formatEntryInfo.formatValueList);
     }
 }
Esempio n. 45
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;
     }
 }
Esempio n. 46
0
 internal override void ProcessPayload(FormatEntryData fed)
 {
     int count = this.CurrentTableHeaderInfo.tableColumnInfoList.Count;
     if (count != 0)
     {
         TableRowEntry formatEntryInfo = fed.formatEntryInfo as TableRowEntry;
         string[] values = new string[count];
         int[] alignment = new int[count];
         int num2 = formatEntryInfo.formatPropertyFieldList.Count;
         for (int i = 0; i < count; i++)
         {
             if (i < num2)
             {
                 values[i] = formatEntryInfo.formatPropertyFieldList[i].propertyValue;
                 alignment[i] = formatEntryInfo.formatPropertyFieldList[i].alignment;
             }
             else
             {
                 values[i] = "";
                 alignment[i] = 1;
             }
         }
         base.Writer.GenerateRow(values, base.InnerCommand.lo, formatEntryInfo.multiLine, alignment, base.InnerCommand.lo.DisplayCells);
     }
 }
Esempio n. 47
0
 internal override void ProcessPayload(FormatEntryData fed)
 {
     WideViewEntry formatEntryInfo = fed.formatEntryInfo as WideViewEntry;
     FormatPropertyField formatPropertyField = formatEntryInfo.formatPropertyField;
     this.buffer.Add(formatPropertyField.propertyValue);
     if (this.buffer.IsFull)
     {
         this.WriteStringBuffer();
     }
 }
Esempio n. 48
0
 protected void WriteInternalErrorMessage(string message)
 {
     FormatEntryData o = new FormatEntryData {
         outOfBand = true
     };
     ComplexViewEntry entry = new ComplexViewEntry();
     FormatEntry item = new FormatEntry();
     entry.formatValueList.Add(item);
     item.formatValueList.Add(new FormatNewLine());
     FormatTextField field = new FormatTextField {
         text = message
     };
     item.formatValueList.Add(field);
     item.formatValueList.Add(new FormatNewLine());
     o.formatEntryInfo = entry;
     this.WriteObject(o);
 }
Esempio n. 49
0
        protected void WriteInternalErrorMessage(string message)
        {
            FormatEntryData fed = new FormatEntryData();
            fed.outOfBand = true;

            ComplexViewEntry cve = new ComplexViewEntry();
            FormatEntry fe = new FormatEntry();
            cve.formatValueList.Add(fe);

            fe.formatValueList.Add(new FormatNewLine());

            // get a field for the message
            FormatTextField ftf = new FormatTextField();
            ftf.text = message;
            fe.formatValueList.Add(ftf);

            fe.formatValueList.Add(new FormatNewLine());

            fed.formatEntryInfo = cve;

            this.WriteObject(fed);
        }
Esempio n. 50
0
        internal static FormatEntryData GenerateOutOfBandObjectAsToString(PSObject so)
        {
            FormatEntryData fed = new FormatEntryData();
            fed.outOfBand = true;

            RawTextFormatEntry rawTextEntry = new RawTextFormatEntry();
            rawTextEntry.text = so.ToString();
            fed.formatEntryInfo = rawTextEntry;

            return fed;
        }