protected FormatPropertyField GenerateFormatPropertyField(List <FormatToken> formatTokenList, PSObject so, int enumerationLimit, out MshExpressionResult result) { result = null; FormatPropertyField field = new FormatPropertyField(); if (formatTokenList.Count != 0) { FormatToken token = formatTokenList[0]; FieldPropertyToken token2 = token as FieldPropertyToken; if (token2 != null) { MshExpression ex = this.expressionFactory.CreateFromExpressionToken(token2.expression, this.dataBaseInfo.view.loadingInfo); field.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, ex, token2.fieldFormattingDirective, out result); return(field); } TextToken tt = token as TextToken; if (tt != null) { field.propertyValue = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } return(field); } field.propertyValue = ""; return(field); }
protected FormatPropertyField GenerateFormatPropertyField(List <FormatToken> formatTokenList, PSObject so, int enumerationLimit, out PSPropertyExpressionResult result) { result = null; FormatPropertyField fpf = new FormatPropertyField(); if (formatTokenList.Count != 0) { FormatToken token = formatTokenList[0]; FieldPropertyToken fpt = token as FieldPropertyToken; if (fpt != null) { PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo); fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, ex, fpt.fieldFormattingDirective, out result); } else { TextToken tt = token as TextToken; if (tt != null) { fpf.propertyValue = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } else { fpf.propertyValue = string.Empty; } return(fpf); }
private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { ListViewEntry lve = new ListViewEntry(); ListControlEntryDefinition activeListControlEntryDefinition = GetActiveListControlEntryDefinition(_listBody, so); foreach (ListControlItemDefinition listItem in activeListControlEntryDefinition.itemDefinitionList) { if (!EvaluateDisplayCondition(so, listItem.conditionToken)) { continue; } ListViewField lvf = new ListViewField(); PSPropertyExpressionResult result; lvf.formatPropertyField = GenerateFormatPropertyField(listItem.formatTokenList, so, enumerationLimit, out result); // we need now to provide a label if (listItem.label != null) { // if the directive provides one, we use it lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(listItem.label); } else if (result != null) { // if we got a valid match from the Mshexpression, use it as a label lvf.label = result.ResolvedExpression.ToString(); } else { // we did fail getting a result (i.e. property does not exist on the object) // we try to fall back and see if we have an un-resolved PSPropertyExpression FormatToken token = listItem.formatTokenList[0]; FieldPropertyToken fpt = token as FieldPropertyToken; if (fpt != null) { PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo); // use the un-resolved PSPropertyExpression string as a label lvf.label = ex.ToString(); } else { TextToken tt = token as TextToken; if (tt != null) { // we had a text token, use it as a label (last resort...) lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } lve.listViewFieldList.Add(lvf); } return(lve); }
private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { ListViewEntry entry = new ListViewEntry(); foreach (ListControlItemDefinition definition2 in this.GetActiveListControlEntryDefinition(this.listBody, so).itemDefinitionList) { if (base.EvaluateDisplayCondition(so, definition2.conditionToken)) { MshExpressionResult result; ListViewField item = new ListViewField { formatPropertyField = base.GenerateFormatPropertyField(definition2.formatTokenList, so, enumerationLimit, out result) }; if (definition2.label != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(definition2.label); } else if (result != null) { item.label = result.ResolvedExpression.ToString(); } else { FormatToken token = definition2.formatTokenList[0]; FieldPropertyToken token2 = token as FieldPropertyToken; if (token2 != null) { item.label = base.expressionFactory.CreateFromExpressionToken(token2.expression, base.dataBaseInfo.view.loadingInfo).ToString(); } else { TextToken tt = token as TextToken; if (tt != null) { item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt); } } } entry.listViewFieldList.Add(item); } } return(entry); }
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); }
internal static CustomItemBase Create(FormatToken token) { if (token is NewLineToken) { return new CustomItemNewline(); } var textToken = token as TextToken; if (textToken != null) { return new CustomItemText { Text = textToken.text }; } var frameToken = token as FrameToken; if (frameToken != null) { var frame = new CustomItemFrame { RightIndent = (uint)frameToken.frameInfoDefinition.rightIndentation, LeftIndent = (uint)frameToken.frameInfoDefinition.leftIndentation }; var firstLine = frameToken.frameInfoDefinition.firstLine; if (firstLine > 0) { frame.FirstLineIndent = (uint)firstLine; } else if (firstLine < 0) { frame.FirstLineHanging = (uint)-firstLine; } foreach (var frameItemToken in frameToken.itemDefinition.formatTokenList) { frame.CustomItems.Add(CustomItemBase.Create(frameItemToken)); } return frame; } var cpt = token as CompoundPropertyToken; if (cpt != null) { var cie = new CustomItemExpression { EnumerateCollection = cpt.enumerateCollection }; if (cpt.conditionToken != null) { cie.ItemSelectionCondition = new DisplayEntry(cpt.conditionToken); } if (cpt.expression.expressionValue != null) { cie.Expression = new DisplayEntry(cpt.expression); } if (cpt.control != null) { cie.CustomControl = new CustomControl((ComplexControlBody)cpt.control, null); } return cie; } var fpt = token as FieldPropertyToken; if (fpt != null) { } Diagnostics.Assert(false, "Unexpected formatting token kind"); return null; }
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); }