private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
        {
            TableRowEntry tre = new TableRowEntry();

            for (int k = 0; k < this.activeAssociationList.Count; k++)
            {
                FormatPropertyField      fpf       = new FormatPropertyField();
                FieldFormattingDirective directive = null;
                if (activeAssociationList[k].OriginatingParameter != null)
                {
                    directive = activeAssociationList[k].OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }

                if (directive is null)
                {
                    directive         = new FieldFormattingDirective();
                    directive.isTable = true;
                }

                fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, this.activeAssociationList[k].ResolvedExpression, directive);
                tre.formatPropertyFieldList.Add(fpf);
            }

            return(tre);
        }
Beispiel #2
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];
                Span <int> alignment = stackalloc 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);
            }
Beispiel #3
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);
                }
            }
Beispiel #4
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;
        }
Beispiel #5
0
        private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            TableRowEntry entry = new TableRowEntry();

            foreach (TableRowItemDefinition definition in this.GetActiveTableRowDefinition(this.tableBody, so, out entry.multiLine))
            {
                FormatPropertyField item = base.GenerateFormatPropertyField(definition.formatTokenList, so, enumerationLimit);
                item.alignment = definition.alignment;
                entry.formatPropertyFieldList.Add(item);
            }
            return(entry);
        }
Beispiel #6
0
        private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
        {
            TableRowEntry entry = new TableRowEntry();

            for (int i = 0; i < base.activeAssociationList.Count; i++)
            {
                FormatPropertyField      item      = new FormatPropertyField();
                FieldFormattingDirective directive = null;
                if (base.activeAssociationList[i].OriginatingParameter != null)
                {
                    directive = base.activeAssociationList[i].OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
                }
                item.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, base.activeAssociationList[i].ResolvedExpression, directive);
                entry.formatPropertyFieldList.Add(item);
            }
            return(entry);
        }
Beispiel #7
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;
     }
 }
        private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            TableRowEntry tre = new TableRowEntry();

            List <TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(_tableBody, so, out tre.multiLine);

            foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList)
            {
                FormatPropertyField fpf = GenerateFormatPropertyField(rowItem.formatTokenList, so, enumerationLimit);

                // get the alignment from the row entry
                // NOTE: if it's not set, the alignment sent with the header will prevail
                fpf.alignment = rowItem.alignment;

                tre.formatPropertyFieldList.Add(fpf);
            }

            return(tre);
        }
 private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
 {
     TableRowEntry tre = new TableRowEntry();
     for (int k = 0; k < this.activeAssociationList.Count; k++)
     {
         FormatPropertyField fpf = new FormatPropertyField();
         FieldFormattingDirective directive = null;
         if (activeAssociationList[k].OriginatingParameter != null)
         {
             directive = activeAssociationList[k].OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
         }
         fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, this.activeAssociationList[k].ResolvedExpression, directive);
         tre.formatPropertyFieldList.Add(fpf);
     }
     return tre;
 }
        private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            TableRowEntry tre = new TableRowEntry();

            List<TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(_tableBody, so, out tre.multiLine);
            foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList)
            {
                FormatPropertyField fpf = GenerateFormatPropertyField(rowItem.formatTokenList, so, enumerationLimit);

                // get the alignment from the row entry
                // NOTE: if it's not set, the alignment sent with the header will prevail
                fpf.alignment = rowItem.alignment;

                tre.formatPropertyFieldList.Add(fpf);
            }

            return tre;
        }
Beispiel #11
0
 private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
 {
     TableRowEntry entry = new TableRowEntry();
     for (int i = 0; i < base.activeAssociationList.Count; i++)
     {
         FormatPropertyField item = new FormatPropertyField();
         FieldFormattingDirective directive = null;
         if (base.activeAssociationList[i].OriginatingParameter != null)
         {
             directive = base.activeAssociationList[i].OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
         }
         item.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, base.activeAssociationList[i].ResolvedExpression, directive);
         entry.formatPropertyFieldList.Add(item);
     }
     return entry;
 }
Beispiel #12
0
 private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
 {
     TableRowEntry entry = new TableRowEntry();
     foreach (TableRowItemDefinition definition in this.GetActiveTableRowDefinition(this.tableBody, so, out entry.multiLine))
     {
         FormatPropertyField item = base.GenerateFormatPropertyField(definition.formatTokenList, so, enumerationLimit);
         item.alignment = definition.alignment;
         entry.formatPropertyFieldList.Add(item);
     }
     return entry;
 }