コード例 #1
0
 private void LoadColumnEntries(XmlNode columnEntriesNode, TableRowDefinition trd)
 {
     using (this.StackFrame(columnEntriesNode))
     {
         int columnEntryIndex = 0;
         foreach (XmlNode n in columnEntriesNode.ChildNodes)
         {
             if (MatchNodeName(n, XmlTags.TableColumnItemNode))
             {
                 TableRowItemDefinition rid = LoadColumnEntry(n, columnEntryIndex++);
                 if (rid != null)
                 {
                     trd.rowItemDefinitionList.Add(rid);
                 }
                 else
                 {
                     // we failed one entry: fatal error to percolate up
                     // remove all the entries
                     trd.rowItemDefinitionList = null;
                     return; // fatal error
                 }
             }
             else
             {
                 this.ProcessUnknownNode(n);
             }
         }
     }
 }
コード例 #2
0
        private TableRowDefinition LoadRowEntryDefinition(XmlNode rowEntryNode, int index)
        {
            using (this.StackFrame(rowEntryNode, index))
            {
                bool appliesToNodeFound     = false; // cardinality 0..1
                bool columnEntriesNodeFound = false; // cardinality 1
                bool multiLineFound         = false; // cardinality 0..1

                TableRowDefinition trd = new TableRowDefinition();
                foreach (XmlNode n in rowEntryNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.EntrySelectedByNode))
                    {
                        if (appliesToNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); // fatal error
                        }

                        appliesToNodeFound = true;

                        // optional section
                        trd.appliesTo = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.TableColumnItemsNode))
                    {
                        if (columnEntriesNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); //fatal
                        }
                        LoadColumnEntries(n, trd);
                        if (trd.rowItemDefinitionList == null)
                        {
                            return(null); // fatal error
                        }
                    }
                    else if (MatchNodeName(n, XmlTags.MultiLineNode))
                    {
                        if (multiLineFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return(null); //fatal
                        }
                        multiLineFound = true;
                        if (!this.ReadBooleanNode(n, out trd.multiLine))
                        {
                            return(null); //fatal error
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }
                return(trd);
            }
        }
コード例 #3
0
        internal TableRowDefinition Copy()
        {
            TableRowDefinition tableRowDefinition = new TableRowDefinition();

            tableRowDefinition.appliesTo = this.appliesTo;
            tableRowDefinition.multiLine = this.multiLine;
            foreach (TableRowItemDefinition rowItemDefinition in this.rowItemDefinitionList)
            {
                tableRowDefinition.rowItemDefinitionList.Add(rowItemDefinition);
            }
            return(tableRowDefinition);
        }
コード例 #4
0
ファイル: TableRowDefinition.cs プロジェクト: nickchal/pash
 internal TableRowDefinition Copy()
 {
     TableRowDefinition definition = new TableRowDefinition {
         appliesTo = this.appliesTo,
         multiLine = this.multiLine
     };
     foreach (TableRowItemDefinition definition2 in this.rowItemDefinitionList)
     {
         definition.rowItemDefinitionList.Add(definition2);
     }
     return definition;
 }
コード例 #5
0
        internal TableRowDefinition Copy()
        {
            TableRowDefinition definition = new TableRowDefinition {
                appliesTo = this.appliesTo,
                multiLine = this.multiLine
            };

            foreach (TableRowItemDefinition definition2 in this.rowItemDefinitionList)
            {
                definition.rowItemDefinitionList.Add(definition2);
            }
            return(definition);
        }
コード例 #6
0
        private void LoadRowEntriesSection(TableControlBody tableBody, XmlNode rowEntriesNode)
        {
            using (this.StackFrame(rowEntriesNode))
            {
                int rowEntryIndex = 0;
                foreach (XmlNode n in rowEntriesNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.TableRowEntryNode))
                    {
                        TableRowDefinition trd = LoadRowEntryDefinition(n, rowEntryIndex++);
                        if (trd == null)
                        {
                            //Error at XPath {0} in file {1}: {2} failed to load.
                            this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.LoadTagFailed, ComputeCurrentXPath(), FilePath, XmlTags.TableRowEntryNode));
                            tableBody.defaultDefinition = null;
                            return; // fatal error
                        }

                        // determine if we have a default entry and if it's already set
                        if (trd.appliesTo == null)
                        {
                            if (tableBody.defaultDefinition == null)
                            {
                                tableBody.defaultDefinition = trd;
                            }
                            else
                            {
                                //Error at XPath {0} in file {1}: There cannot be more than one default {2}.
                                this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.TableRowEntryNode));
                                tableBody.defaultDefinition = null;
                                return; // fatal error
                            }
                        }
                        else
                        {
                            tableBody.optionalDefinitionList.Add(trd);
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (tableBody.defaultDefinition == null)
                {
                    //Error at XPath {0} in file {1}: There must be at least one default {2}.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntry, ComputeCurrentXPath(), FilePath, XmlTags.TableRowEntryNode));
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a Shallow Copy of the current object.
        /// </summary>
        /// <returns></returns>
        internal TableRowDefinition Copy()
        {
            TableRowDefinition result = new TableRowDefinition
            {
                appliesTo = this.appliesTo,
                multiLine = this.multiLine
            };

            foreach (TableRowItemDefinition trid in this.rowItemDefinitionList)
            {
                result.rowItemDefinitionList.Add(trid);
            }

            return(result);
        }
コード例 #8
0
ファイル: TableControlRow.cs プロジェクト: nickchal/pash
 internal TableControlRow(TableRowDefinition rowdefinition)
 {
     this._columns = new List<TableControlColumn>();
     foreach (TableRowItemDefinition definition in rowdefinition.rowItemDefinitionList)
     {
         TableControlColumn column;
         FieldPropertyToken token = definition.formatTokenList[0] as FieldPropertyToken;
         if (token != null)
         {
             column = new TableControlColumn(token.expression.expressionValue, definition.alignment, token.expression.isScriptBlock);
         }
         else
         {
             column = new TableControlColumn();
         }
         this._columns.Add(column);
     }
 }
コード例 #9
0
 private TableRowDefinition LoadRowEntryDefinition(System.Xml.XmlNode rowEntryNode, int index)
 {
     using (base.StackFrame(rowEntryNode, index))
     {
         bool flag = false;
         bool flag2 = false;
         bool flag3 = false;
         TableRowDefinition trd = new TableRowDefinition();
         foreach (System.Xml.XmlNode node in rowEntryNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "EntrySelectedBy"))
             {
                 if (flag)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag = true;
                 trd.appliesTo = this.LoadAppliesToSection(node, true);
             }
             else if (base.MatchNodeName(node, "TableColumnItems"))
             {
                 if (flag2)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 this.LoadColumnEntries(node, trd);
                 if (trd.rowItemDefinitionList == null)
                 {
                     return null;
                 }
             }
             else if (base.MatchNodeName(node, "Wrap"))
             {
                 if (flag3)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag3 = true;
                 if (!this.ReadBooleanNode(node, out trd.multiLine))
                 {
                     return null;
                 }
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         return trd;
     }
 }
コード例 #10
0
 private void LoadRowEntriesSectionFromObjectModel(TableControlBody tableBody, List<TableControlRow> rowEntries, int viewIndex, string typeName)
 {
     foreach (TableControlRow row in rowEntries)
     {
         TableRowDefinition trd = new TableRowDefinition();
         if (row.Columns.Count > 0)
         {
             this.LoadColumnEntriesFromObjectModel(trd, row.Columns, viewIndex, typeName);
             if (trd.rowItemDefinitionList == null)
             {
                 tableBody.defaultDefinition = null;
                 return;
             }
         }
         tableBody.defaultDefinition = trd;
     }
     if (tableBody.defaultDefinition == null)
     {
         base.ReportErrorForLoadingFromObjectModel(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, new object[] { typeName, viewIndex, "TableRowEntry" }), typeName);
     }
 }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
 private void LoadColumnEntries(System.Xml.XmlNode columnEntriesNode, TableRowDefinition trd)
 {
     using (base.StackFrame(columnEntriesNode))
     {
         int num = 0;
         foreach (System.Xml.XmlNode node in columnEntriesNode.ChildNodes)
         {
             if (base.MatchNodeName(node, "TableColumnItem"))
             {
                 TableRowItemDefinition item = this.LoadColumnEntry(node, num++);
                 if (item != null)
                 {
                     trd.rowItemDefinitionList.Add(item);
                     continue;
                 }
                 trd.rowItemDefinitionList = null;
                 return;
             }
             base.ProcessUnknownNode(node);
         }
     }
 }
コード例 #13
0
        /// <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);
            }
        }
コード例 #14
0
        /// <summary>
        /// Load row enties, set the defaultDefinition of the TableControlBody.
        /// </summary>
        /// <param name="tableBody"></param>
        /// <param name="rowEntries"></param>
        /// <param name="viewIndex"></param>
        /// <param name="typeName"></param>
        private void LoadRowEntriesSectionFromObjectModel(TableControlBody tableBody, List<TableControlRow> rowEntries, int viewIndex, string typeName)
        {
            foreach (TableControlRow row in rowEntries)
            {
                TableRowDefinition trd = new TableRowDefinition { multiLine = row.Wrap };

                // Contains:
                //   Columns --- TableColumnItems  cardinality: 0..1
                // No SelectedBy is supplied in the TableControlRow
                if (row.Columns.Count > 0)
                {
                    LoadColumnEntriesFromObjectModel(trd, row.Columns, viewIndex, typeName);
                    // trd.rowItemDefinitionList is null, it means there was a failure
                    if (trd.rowItemDefinitionList == null)
                    {
                        tableBody.defaultDefinition = null;
                        return;
                    }
                }

                if (row.SelectedBy != null)
                {
                    trd.appliesTo = LoadAppliesToSectionFromObjectModel(row.SelectedBy.TypeNames, row.SelectedBy.SelectionCondition);
                    tableBody.optionalDefinitionList.Add(trd);
                }
                else
                {
                    tableBody.defaultDefinition = trd;
                }
            }

            // rowEntries must not be empty 
            if (tableBody.defaultDefinition == null)
            {
                this.ReportErrorForLoadingFromObjectModel(
                    StringUtil.Format(FormatAndOutXmlLoadingStrings.NoDefaultShapeEntryInFormattingData, typeName, viewIndex, XmlTags.TableRowEntryNode), typeName);
                return;
            }
        }
コード例 #15
0
 private void LoadColumnEntries(XmlNode columnEntriesNode, TableRowDefinition trd)
 {
     using (this.StackFrame(columnEntriesNode))
     {
         int columnEntryIndex = 0;
         foreach (XmlNode n in columnEntriesNode.ChildNodes)
         {
             if (MatchNodeName(n, XmlTags.TableColumnItemNode))
             {
                 TableRowItemDefinition rid = LoadColumnEntry(n, columnEntryIndex++);
                 if (rid != null)
                 {
                     trd.rowItemDefinitionList.Add(rid);
                 }
                 else
                 {
                     // we failed one entry: fatal error to percolate up
                     // remove all the entries
                     trd.rowItemDefinitionList = null;
                     return; // fatal error
                 }
             }
             else
             {
                 this.ProcessUnknownNode(n);
             }
         }
     }
 }
コード例 #16
0
        /// <summary>
        /// Returns a Shallow Copy of the current object.
        /// </summary>
        /// <returns></returns>
        internal TableRowDefinition Copy()
        {
            TableRowDefinition result = new TableRowDefinition
            {
                appliesTo = this.appliesTo,
                multiLine = this.multiLine
            };
            foreach (TableRowItemDefinition trid in this.rowItemDefinitionList)
            {
                result.rowItemDefinitionList.Add(trid);
            }

            return result;
        }
コード例 #17
0
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so,
                                                                          out bool multiLine)
        {
            multiLine = tableBody.defaultDefinition.multiLine;
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                // we do not have any override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // see if we have an override that matches
            TableRowDefinition matchingRowDefinition = null;

            var       typeNames = so.InternalTypeNames;
            TypeMatch match     = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);

            foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    matchingRowDefinition = x;
                    break;
                }
            }

            if (matchingRowDefinition == null)
            {
                matchingRowDefinition = match.BestMatch as TableRowDefinition;
            }

            if (matchingRowDefinition == null)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);

                    foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            matchingRowDefinition = x;
                            break;
                        }
                    }

                    if (matchingRowDefinition == null)
                    {
                        matchingRowDefinition = match.BestMatch as TableRowDefinition;
                    }
                }
            }

            if (matchingRowDefinition == null)
            {
                // no matching override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // the overriding row definition takes the precedence
            if (matchingRowDefinition.multiLine)
            {
                multiLine = matchingRowDefinition.multiLine;
            }

            // we have an override, we need to compute the merge of the active cells
            List <TableRowItemDefinition> activeRowItemDefinitionList = new List <TableRowItemDefinition>();
            int col = 0;

            foreach (TableRowItemDefinition rowItem in matchingRowDefinition.rowItemDefinitionList)
            {
                // check if the row is an override or not
                if (rowItem.formatTokenList.Count == 0)
                {
                    // it's a place holder, use the default
                    activeRowItemDefinitionList.Add(tableBody.defaultDefinition.rowItemDefinitionList[col]);
                }
                else
                {
                    // use the override
                    activeRowItemDefinitionList.Add(rowItem);
                }

                col++;
            }

            return(activeRowItemDefinitionList);
        }
コード例 #18
0
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so, out bool multiLine)
        {
            multiLine = tableBody.defaultDefinition.multiLine;
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            TableRowDefinition bestMatch         = null;
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);

            foreach (TableRowDefinition definition2 in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                {
                    bestMatch = definition2;
                    break;
                }
            }
            if (bestMatch == null)
            {
                bestMatch = match.BestMatch as TableRowDefinition;
            }
            if (bestMatch == null)
            {
                Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
                if (typeNames != null)
                {
                    match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
                    foreach (TableRowDefinition definition3 in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(definition3, definition3.appliesTo)))
                        {
                            bestMatch = definition3;
                            break;
                        }
                    }
                    if (bestMatch == null)
                    {
                        bestMatch = match.BestMatch as TableRowDefinition;
                    }
                }
            }
            if (bestMatch == null)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            if (bestMatch.multiLine)
            {
                multiLine = bestMatch.multiLine;
            }
            List <TableRowItemDefinition> list = new List <TableRowItemDefinition>();
            int num = 0;

            foreach (TableRowItemDefinition definition4 in bestMatch.rowItemDefinitionList)
            {
                if (definition4.formatTokenList.Count == 0)
                {
                    list.Add(tableBody.defaultDefinition.rowItemDefinitionList[num]);
                }
                else
                {
                    list.Add(definition4);
                }
                num++;
            }
            return(list);
        }
コード例 #19
0
        internal TableControlRow(TableRowDefinition rowdefinition) : this()
        {
            Wrap = rowdefinition.multiLine;
            if (rowdefinition.appliesTo != null)
            {
                SelectedBy = EntrySelectedBy.Get(rowdefinition.appliesTo.referenceList);
            }
            foreach (TableRowItemDefinition itemdef in rowdefinition.rowItemDefinitionList)
            {
                FieldPropertyToken fpt = itemdef.formatTokenList[0] as FieldPropertyToken;
                TableControlColumn column;

                if (fpt != null)
                {
                    column = new TableControlColumn(fpt.expression.expressionValue, itemdef.alignment,
                                    fpt.expression.isScriptBlock, fpt.fieldFormattingDirective.formatString);
                }
                else
                {
                    column = new TableControlColumn();
                }

                Columns.Add(column);
            }
        }
コード例 #20
0
        private TableRowDefinition LoadRowEntryDefinition(XmlNode rowEntryNode, int index)
        {
            using (this.StackFrame(rowEntryNode, index))
            {
                bool appliesToNodeFound = false;    // cardinality 0..1
                bool columnEntriesNodeFound = false;         // cardinality 1
                bool multiLineFound = false;    // cardinality 0..1

                TableRowDefinition trd = new TableRowDefinition();
                foreach (XmlNode n in rowEntryNode.ChildNodes)
                {
                    if (MatchNodeName(n, XmlTags.EntrySelectedByNode))
                    {
                        if (appliesToNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; // fatal error
                        }

                        appliesToNodeFound = true;

                        // optional section
                        trd.appliesTo = LoadAppliesToSection(n, true);
                    }
                    else if (MatchNodeName(n, XmlTags.TableColumnItemsNode))
                    {
                        if (columnEntriesNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; //fatal
                        }
                        LoadColumnEntries(n, trd);
                        if (trd.rowItemDefinitionList == null)
                        {
                            return null; // fatal error
                        }
                    }
                    else if (MatchNodeName(n, XmlTags.MultiLineNode))
                    {
                        if (multiLineFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; //fatal
                        }
                        multiLineFound = true;
                        if (!this.ReadBooleanNode(n, out trd.multiLine))
                        {
                            return null; //fatal error
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }
                return trd;
            }
        }