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; }
private TableHeaderInfo GenerateTableHeaderInfoFromProperties(PSObject so) { TableHeaderInfo info = new TableHeaderInfo { hideHeader = this.HideHeaders }; for (int i = 0; i < base.activeAssociationList.Count; i++) { MshResolvedExpressionParameterAssociation association = base.activeAssociationList[i]; TableColumnInfo item = new TableColumnInfo(); if (association.OriginatingParameter != null) { object entry = association.OriginatingParameter.GetEntry("label"); if (entry != AutomationNull.Value) { item.propertyName = (string)entry; } } if (item.propertyName == null) { item.propertyName = base.activeAssociationList[i].ResolvedExpression.ToString(); } if (association.OriginatingParameter != null) { object obj3 = association.OriginatingParameter.GetEntry("width"); if (obj3 != AutomationNull.Value) { item.width = (int)obj3; } else { item.width = 0; } } else { item.width = 0; } if (association.OriginatingParameter != null) { object obj4 = association.OriginatingParameter.GetEntry("alignment"); if (obj4 != AutomationNull.Value) { item.alignment = (int)obj4; } else { item.alignment = ComputeDefaultAlignment(so, association.ResolvedExpression); } } else { item.alignment = ComputeDefaultAlignment(so, association.ResolvedExpression); } info.tableColumnInfoList.Add(item); } return(info); }
private bool ProcessObject(PSObject so) { object o = _formatObjectDeserializer.Deserialize(so); //Console.WriteLine("OutCommandInner.Execute() retrieved object {0}, of type {1}", o.ToString(), o.GetType()); if (NeedsPreprocessing(o)) { return(false); } // instantiate the cache if not done yet if (_cache == null) { _cache = new FormattedObjectsCache(this.LineOutput.RequiresBuffering); } // no need for formatting, just process the object FormatStartData formatStart = o as FormatStartData; if (formatStart != null) { // get autosize flag from object // turn on group caching if (formatStart.autosizeInfo != null) { FormattedObjectsCache.ProcessCachedGroupNotification callBack = new FormattedObjectsCache.ProcessCachedGroupNotification(ProcessCachedGroup); _cache.EnableGroupCaching(callBack, formatStart.autosizeInfo.objectCount); } else { // If the format info doesn't define column widths, then auto-size based on the first ten elements TableHeaderInfo headerInfo = formatStart.shapeInfo as TableHeaderInfo; if ((headerInfo != null) && (headerInfo.tableColumnInfoList.Count > 0) && (headerInfo.tableColumnInfoList[0].width == 0)) { FormattedObjectsCache.ProcessCachedGroupNotification callBack = new FormattedObjectsCache.ProcessCachedGroupNotification(ProcessCachedGroup); _cache.EnableGroupCaching(callBack, TimeSpan.FromMilliseconds(300)); } } } //Console.WriteLine("OutCommandInner.Execute() calling ctxManager.Process({0})",o.ToString()); List <PacketInfoData> info = _cache.Add((PacketInfoData)o); if (info != null) { for (int k = 0; k < info.Count; k++) { _ctxManager.Process(info[k]); } } return(true); }
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 void ProcessCachedGroup(FormatStartData formatStartData, List <PacketInfoData> objects) { this.formattingHint = null; TableHeaderInfo shapeInfo = formatStartData.shapeInfo as TableHeaderInfo; if (shapeInfo != null) { this.ProcessCachedGroupOnTable(shapeInfo, objects); } else { WideViewHeaderInfo wvhi = formatStartData.shapeInfo as WideViewHeaderInfo; if (wvhi != null) { this.ProcessCachedGroupOnWide(wvhi, objects); } } }
/// <summary> /// handler for processing the caching notification and responsible for /// setting the value of the formatting hint /// </summary> /// <param name="formatStartData"></param> /// <param name="objects"></param> private void ProcessCachedGroup(FormatStartData formatStartData, List <PacketInfoData> objects) { _formattingHint = null; TableHeaderInfo thi = formatStartData.shapeInfo as TableHeaderInfo; if (thi != null) { ProcessCachedGroupOnTable(thi, objects); return; } WideViewHeaderInfo wvhi = formatStartData.shapeInfo as WideViewHeaderInfo; if (wvhi != null) { ProcessCachedGroupOnWide(wvhi, objects); return; } }
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; }
private TableHeaderInfo GenerateTableHeaderInfoFromProperties(PSObject so) { TableHeaderInfo thi = new TableHeaderInfo(); thi.hideHeader = this.HideHeaders; for (int k = 0; k < this.activeAssociationList.Count; k++) { MshResolvedExpressionParameterAssociation a = this.activeAssociationList[k]; TableColumnInfo ci = new TableColumnInfo(); // set the label of the column if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey); if (key != AutomationNull.Value) { ci.propertyName = (string)key; } } if (ci.propertyName == null) { ci.propertyName = this.activeAssociationList[k].ResolvedExpression.ToString(); } // set the width of the table if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.WidthEntryKey); if (key != AutomationNull.Value) { ci.width = (int)key; } else { ci.width = 0; // let Column Width Manager decide the width } } else { ci.width = 0; // let Column Width Manager decide the width } // set the alignment if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.AlignmentEntryKey); if (key != AutomationNull.Value) { ci.alignment = (int)key; } else { ci.alignment = ComputeDefaultAlignment(so, a.ResolvedExpression); } } else { ci.alignment = ComputeDefaultAlignment(so, a.ResolvedExpression); } thi.tableColumnInfoList.Add(ci); } return(thi); }
private TableHeaderInfo GenerateTableHeaderInfoFromDataBaseInfo(PSObject so) { TableHeaderInfo thi = new TableHeaderInfo(); bool dummy; List <TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(_tableBody, so, out dummy); thi.hideHeader = this.HideHeaders; thi.repeatHeader = this.RepeatHeader; int col = 0; foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList) { TableColumnInfo ci = new TableColumnInfo(); TableColumnHeaderDefinition colHeader = null; if (_tableBody.header.columnHeaderDefinitionList.Count > 0) { colHeader = _tableBody.header.columnHeaderDefinitionList[col]; } if (colHeader != null) { ci.width = colHeader.width; ci.alignment = colHeader.alignment; if (colHeader.label != null) { ci.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(colHeader.label); } } if (ci.alignment == TextAlignment.Undefined) { ci.alignment = rowItem.alignment; } if (ci.label == null) { FormatToken token = null; if (rowItem.formatTokenList.Count > 0) { token = rowItem.formatTokenList[0]; } if (token != null) { FieldPropertyToken fpt = token as FieldPropertyToken; if (fpt != null) { ci.label = fpt.expression.expressionValue; } else { TextToken tt = token as TextToken; if (tt != null) { ci.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } else { ci.label = string.Empty; } } thi.tableColumnInfoList.Add(ci); col++; } return(thi); }
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 TableHeaderInfo GenerateTableHeaderInfoFromProperties(PSObject so) { TableHeaderInfo thi = new TableHeaderInfo(); thi.hideHeader = this.HideHeaders; for (int k = 0; k < this.activeAssociationList.Count; k++) { MshResolvedExpressionParameterAssociation a = this.activeAssociationList[k]; TableColumnInfo ci = new TableColumnInfo(); // set the label of the column if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey); if (key != AutomationNull.Value) ci.propertyName = (string)key; } if (ci.propertyName == null) { ci.propertyName = this.activeAssociationList[k].ResolvedExpression.ToString(); } // set the width of the table if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.WidthEntryKey); if (key != AutomationNull.Value) ci.width = (int)key; else { ci.width = 0; // let Column Width Manager decide the width } } else { ci.width = 0; // let Column Width Manager decide the width } // set the alignment if (a.OriginatingParameter != null) { object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.AlignmentEntryKey); if (key != AutomationNull.Value) ci.alignment = (int)key; else ci.alignment = ComputeDefaultAlignment(so, a.ResolvedExpression); } else { ci.alignment = ComputeDefaultAlignment(so, a.ResolvedExpression); } thi.tableColumnInfoList.Add(ci); } return thi; }
private TableHeaderInfo GenerateTableHeaderInfoFromDataBaseInfo(PSObject so) { TableHeaderInfo thi = new TableHeaderInfo(); bool dummy; List<TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(_tableBody, so, out dummy); thi.hideHeader = this.HideHeaders; int col = 0; foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList) { TableColumnInfo ci = new TableColumnInfo(); TableColumnHeaderDefinition colHeader = null; if (_tableBody.header.columnHeaderDefinitionList.Count > 0) colHeader = _tableBody.header.columnHeaderDefinitionList[col]; if (colHeader != null) { ci.width = colHeader.width; ci.alignment = colHeader.alignment; if (colHeader.label != null) ci.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(colHeader.label); } if (ci.alignment == TextAlignment.Undefined) { ci.alignment = rowItem.alignment; } if (ci.label == null) { FormatToken token = null; if (rowItem.formatTokenList.Count > 0) token = rowItem.formatTokenList[0]; if (token != null) { FieldPropertyToken fpt = token as FieldPropertyToken; if (fpt != null) { ci.label = fpt.expression.expressionValue; } else { TextToken tt = token as TextToken; if (tt != null) { ci.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } else { ci.label = ""; } } thi.tableColumnInfoList.Add(ci); col++; } return thi; }
private TableHeaderInfo GenerateTableHeaderInfoFromDataBaseInfo(PSObject so) { bool flag; TableHeaderInfo info = new TableHeaderInfo(); List <TableRowItemDefinition> list = this.GetActiveTableRowDefinition(this.tableBody, so, out flag); info.hideHeader = this.HideHeaders; int num = 0; foreach (TableRowItemDefinition definition in list) { TableColumnInfo item = new TableColumnInfo(); TableColumnHeaderDefinition definition2 = null; if (this.tableBody.header.columnHeaderDefinitionList.Count > 0) { definition2 = this.tableBody.header.columnHeaderDefinitionList[num]; } if (definition2 != null) { item.width = definition2.width; item.alignment = definition2.alignment; if (definition2.label != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(definition2.label); } } if (item.alignment == 0) { item.alignment = definition.alignment; } if (item.label == null) { FormatToken token = null; if (definition.formatTokenList.Count > 0) { token = definition.formatTokenList[0]; } if (token != null) { FieldPropertyToken token2 = token as FieldPropertyToken; if (token2 != null) { item.label = token2.expression.expressionValue; } else { TextToken tt = token as TextToken; if (tt != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } else { item.label = ""; } } info.tableColumnInfoList.Add(item); num++; } return(info); }
private TableHeaderInfo GenerateTableHeaderInfoFromDataBaseInfo(PSObject so) { bool flag; TableHeaderInfo info = new TableHeaderInfo(); List<TableRowItemDefinition> list = this.GetActiveTableRowDefinition(this.tableBody, so, out flag); info.hideHeader = this.HideHeaders; int num = 0; foreach (TableRowItemDefinition definition in list) { TableColumnInfo item = new TableColumnInfo(); TableColumnHeaderDefinition definition2 = null; if (this.tableBody.header.columnHeaderDefinitionList.Count > 0) { definition2 = this.tableBody.header.columnHeaderDefinitionList[num]; } if (definition2 != null) { item.width = definition2.width; item.alignment = definition2.alignment; if (definition2.label != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(definition2.label); } } if (item.alignment == 0) { item.alignment = definition.alignment; } if (item.label == null) { FormatToken token = null; if (definition.formatTokenList.Count > 0) { token = definition.formatTokenList[0]; } if (token != null) { FieldPropertyToken token2 = token as FieldPropertyToken; if (token2 != null) { item.label = token2.expression.expressionValue; } else { TextToken tt = token as TextToken; if (tt != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } else { item.label = ""; } } info.tableColumnInfoList.Add(item); num++; } return info; }
private TableHeaderInfo GenerateTableHeaderInfoFromProperties(PSObject so) { TableHeaderInfo info = new TableHeaderInfo { hideHeader = this.HideHeaders }; for (int i = 0; i < base.activeAssociationList.Count; i++) { MshResolvedExpressionParameterAssociation association = base.activeAssociationList[i]; TableColumnInfo item = new TableColumnInfo(); if (association.OriginatingParameter != null) { object entry = association.OriginatingParameter.GetEntry("label"); if (entry != AutomationNull.Value) { item.propertyName = (string) entry; } } if (item.propertyName == null) { item.propertyName = base.activeAssociationList[i].ResolvedExpression.ToString(); } if (association.OriginatingParameter != null) { object obj3 = association.OriginatingParameter.GetEntry("width"); if (obj3 != AutomationNull.Value) { item.width = (int) obj3; } else { item.width = 0; } } else { item.width = 0; } if (association.OriginatingParameter != null) { object obj4 = association.OriginatingParameter.GetEntry("alignment"); if (obj4 != AutomationNull.Value) { item.alignment = (int) obj4; } else { item.alignment = ComputeDefaultAlignment(so, association.ResolvedExpression); } } else { item.alignment = ComputeDefaultAlignment(so, association.ResolvedExpression); } info.tableColumnInfoList.Add(item); } return info; }