private TableRowItemDefinition LoadColumnEntry(XmlNode columnEntryNode, int index) { using (this.StackFrame(columnEntryNode, index)) { // process Mshexpression, format string and text token ViewEntryNodeMatch match = new ViewEntryNodeMatch(this); List <XmlNode> unprocessedNodes = new List <XmlNode>(); if (!match.ProcessExpressionDirectives(columnEntryNode, unprocessedNodes)) { return(null); // fatal error } TableRowItemDefinition rid = new TableRowItemDefinition(); // process the remaining nodes bool alignmentNodeFound = false; // cardinality 0..1 foreach (XmlNode n in unprocessedNodes) { if (MatchNodeName(n, XmlTags.AlignmentNode)) { if (alignmentNodeFound) { this.ProcessDuplicateNode(n); return(null); // fatal error } alignmentNodeFound = true; if (!LoadAlignmentValue(n, out rid.alignment)) { return(null); // fatal error } } else { this.ProcessUnknownNode(n); } } // finally build the item to return // add either the text token or the PSPropertyExpression with optional format string if (match.TextToken != null) { rid.formatTokenList.Add(match.TextToken); } else if (match.Expression != null) { FieldPropertyToken fpt = new FieldPropertyToken(); fpt.expression = match.Expression; fpt.fieldFormattingDirective.formatString = match.FormatString; rid.formatTokenList.Add(fpt); } return(rid); } }
internal override void PrepareForRemoteObjects(PSObject so) { PSPropertyInfo local1 = so.Properties[RemotingConstants.ComputerNameNoteProperty]; if (((base.dataBaseInfo != null) && (base.dataBaseInfo.view != null)) && (base.dataBaseInfo.view.mainControl != null)) { this.tableBody = (TableControlBody)base.dataBaseInfo.view.mainControl.Copy(); TableRowItemDefinition item = new TableRowItemDefinition(); PropertyTokenBase base2 = new FieldPropertyToken { expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false) }; item.formatTokenList.Add(base2); this.tableBody.defaultDefinition.rowItemDefinitionList.Add(item); if (this.tableBody.header.columnHeaderDefinitionList.Count > 0) { TableColumnHeaderDefinition definition2 = new TableColumnHeaderDefinition { label = new TextToken() }; definition2.label.text = RemotingConstants.ComputerNameNoteProperty; this.tableBody.header.columnHeaderDefinitionList.Add(definition2); } } }
private TableRowItemDefinition LoadColumnEntry(System.Xml.XmlNode columnEntryNode, int index) { using (base.StackFrame(columnEntryNode, index)) { ViewEntryNodeMatch match = new ViewEntryNodeMatch(this); List<System.Xml.XmlNode> unprocessedNodes = new List<System.Xml.XmlNode>(); if (!match.ProcessExpressionDirectives(columnEntryNode, unprocessedNodes)) { return null; } TableRowItemDefinition definition = new TableRowItemDefinition(); bool flag = false; foreach (System.Xml.XmlNode node in unprocessedNodes) { if (base.MatchNodeName(node, "Alignment")) { if (flag) { base.ProcessDuplicateNode(node); return null; } flag = true; if (!this.LoadAlignmentValue(node, out definition.alignment)) { return null; } } else { base.ProcessUnknownNode(node); } } if (match.TextToken != null) { definition.formatTokenList.Add(match.TextToken); } else if (match.Expression != null) { FieldPropertyToken item = new FieldPropertyToken { expression = match.Expression }; item.fieldFormattingDirective.formatString = match.FormatString; definition.formatTokenList.Add(item); } return definition; } }
private void LoadColumnEntriesFromObjectModel(TableRowDefinition trd, List<TableControlColumn> columns, int viewIndex, string typeName) { foreach (TableControlColumn column in columns) { TableRowItemDefinition item = new TableRowItemDefinition(); if (column.DisplayEntry != null) { ExpressionToken token = this.LoadExpressionFromObjectModel(column.DisplayEntry, viewIndex, typeName); if (token == null) { trd.rowItemDefinitionList = null; break; } FieldPropertyToken token2 = new FieldPropertyToken { expression = token }; item.formatTokenList.Add(token2); } item.alignment = (int) column.Alignment; trd.rowItemDefinitionList.Add(item); } }
/// <summary> /// Load the column items into the TableRowDefinition /// </summary> /// <param name="trd"></param> /// <param name="columns"></param> /// <param name="viewIndex"></param> /// <param name="typeName"></param> private void LoadColumnEntriesFromObjectModel(TableRowDefinition trd, List<TableControlColumn> columns, int viewIndex, string typeName) { foreach (TableControlColumn column in columns) { TableRowItemDefinition rid = new TableRowItemDefinition(); // Contain: // DisplayEntry --- Expression cardinality: 0..1 // Alignment --- Alignment cardinality: 0..1 if (column.DisplayEntry != null) { ExpressionToken expression = LoadExpressionFromObjectModel(column.DisplayEntry, viewIndex, typeName); if (expression == null) { trd.rowItemDefinitionList = null; return; } FieldPropertyToken fpt = new FieldPropertyToken(); fpt.expression = expression; fpt.fieldFormattingDirective.formatString = column.FormatString; rid.formatTokenList.Add(fpt); } rid.alignment = (int)column.Alignment; trd.rowItemDefinitionList.Add(rid); } }
/// <summary> /// Let the view prepare itself for RemoteObjects. This will add "ComputerName" to the /// table columns. /// </summary> /// <param name="so"></param> internal override void PrepareForRemoteObjects(PSObject so) { Diagnostics.Assert(null != so, "so cannot be null"); // make sure computername property exists. Diagnostics.Assert(null != so.Properties[RemotingConstants.ComputerNameNoteProperty], "PrepareForRemoteObjects cannot be called when the object does not contain ComputerName property."); if ((dataBaseInfo != null) && (dataBaseInfo.view != null) && (dataBaseInfo.view.mainControl != null)) { // dont change the original format definition in the database..just make a copy and work // with the copy _tableBody = (TableControlBody)this.dataBaseInfo.view.mainControl.Copy(); TableRowItemDefinition cnRowDefinition = new TableRowItemDefinition(); PropertyTokenBase propToken = new FieldPropertyToken(); propToken.expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false); cnRowDefinition.formatTokenList.Add(propToken); _tableBody.defaultDefinition.rowItemDefinitionList.Add(cnRowDefinition); // add header only if there are other header definitions if (_tableBody.header.columnHeaderDefinitionList.Count > 0) { TableColumnHeaderDefinition cnHeaderDefinition = new TableColumnHeaderDefinition(); cnHeaderDefinition.label = new TextToken(); cnHeaderDefinition.label.text = RemotingConstants.ComputerNameNoteProperty; _tableBody.header.columnHeaderDefinitionList.Add(cnHeaderDefinition); } } }
private TableRowItemDefinition LoadColumnEntry(XmlNode columnEntryNode, int index) { using (this.StackFrame(columnEntryNode, index)) { // process Mshexpression, format string and text token ViewEntryNodeMatch match = new ViewEntryNodeMatch(this); List<XmlNode> unprocessedNodes = new List<XmlNode>(); if (!match.ProcessExpressionDirectives(columnEntryNode, unprocessedNodes)) { return null; // fatal error } TableRowItemDefinition rid = new TableRowItemDefinition(); // process the remaining nodes bool alignmentNodeFound = false; // cardinality 0..1 foreach (XmlNode n in unprocessedNodes) { if (MatchNodeName(n, XmlTags.AlignmentNode)) { if (alignmentNodeFound) { this.ProcessDuplicateNode(n); return null; // fatal error } alignmentNodeFound = true; if (!LoadAlignmentValue(n, out rid.alignment)) { return null; // fatal error } } else { this.ProcessUnknownNode(n); } } // finally build the item to return // add either the text token or the MshExpression with optional format string if (match.TextToken != null) { rid.formatTokenList.Add(match.TextToken); } else if (match.Expression != null) { FieldPropertyToken fpt = new FieldPropertyToken(); fpt.expression = match.Expression; fpt.fieldFormattingDirective.formatString = match.FormatString; rid.formatTokenList.Add(fpt); } return rid; } // using }
internal override void PrepareForRemoteObjects(PSObject so) { PSPropertyInfo local1 = so.Properties[RemotingConstants.ComputerNameNoteProperty]; if (((base.dataBaseInfo != null) && (base.dataBaseInfo.view != null)) && (base.dataBaseInfo.view.mainControl != null)) { this.tableBody = (TableControlBody) base.dataBaseInfo.view.mainControl.Copy(); TableRowItemDefinition item = new TableRowItemDefinition(); PropertyTokenBase base2 = new FieldPropertyToken { expression = new ExpressionToken(RemotingConstants.ComputerNameNoteProperty, false) }; item.formatTokenList.Add(base2); this.tableBody.defaultDefinition.rowItemDefinitionList.Add(item); if (this.tableBody.header.columnHeaderDefinitionList.Count > 0) { TableColumnHeaderDefinition definition2 = new TableColumnHeaderDefinition { label = new TextToken() }; definition2.label.text = RemotingConstants.ComputerNameNoteProperty; this.tableBody.header.columnHeaderDefinitionList.Add(definition2); } } }