コード例 #1
0
        private void InitializeGroupBy()
        {
            // first check if there is an override from the command line
            if (parameters != null && parameters.groupByParameter != null)
            {
                // get the expression to use
                PSPropertyExpression groupingKeyExpression = parameters.groupByParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression;

                // set the label
                string label    = null;
                object labelKey = parameters.groupByParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey);
                if (labelKey != AutomationNull.Value)
                {
                    label = labelKey as string;
                }

                _groupingManager = new GroupingInfoManager();
                _groupingManager.Initialize(groupingKeyExpression, label);
                return;
            }

            // check if we have a view to initialize from
            if (this.dataBaseInfo.view != null)
            {
                GroupBy gb = this.dataBaseInfo.view.groupBy;
                if (gb is null)
                {
                    return;
                }

                if (gb.startGroup is null || gb.startGroup.expression is null)
                {
                    return;
                }

                PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(gb.startGroup.expression, this.dataBaseInfo.view.loadingInfo);

                _groupingManager = new GroupingInfoManager();
                _groupingManager.Initialize(ex, null);
            }
        }
コード例 #2
0
 private GroupBy LoadGroupBySection(System.Xml.XmlNode groupByNode)
 {
     using (base.StackFrame(groupByNode))
     {
         ExpressionNodeMatch match = new ExpressionNodeMatch(this);
         ComplexControlMatch match2 = new ComplexControlMatch(this);
         bool flag = false;
         bool flag2 = false;
         bool flag3 = false;
         GroupBy by = new GroupBy();
         TextToken token = null;
         foreach (System.Xml.XmlNode node in groupByNode)
         {
             if (match.MatchNode(node))
             {
                 if (flag)
                 {
                     base.ProcessDuplicateNode(node);
                     return null;
                 }
                 flag = true;
                 if (!match.ProcessNode(node))
                 {
                     return null;
                 }
             }
             else if (match2.MatchNode(node))
             {
                 if (flag2)
                 {
                     base.ProcessDuplicateAlternateNode(node, "CustomControl", "CustomControlName");
                     return null;
                 }
                 flag2 = true;
                 if (!match2.ProcessNode(node))
                 {
                     return null;
                 }
             }
             else if (base.MatchNodeNameWithAttributes(node, "Label"))
             {
                 if (flag3)
                 {
                     base.ProcessDuplicateAlternateNode(node, "CustomControl", "CustomControlName");
                     return null;
                 }
                 flag3 = true;
                 token = this.LoadLabel(node);
                 if (token == null)
                 {
                     return null;
                 }
             }
             else
             {
                 base.ProcessUnknownNode(node);
             }
         }
         if (flag2 && flag3)
         {
             base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ControlAndLabel, base.ComputeCurrentXPath(), base.FilePath));
             return null;
         }
         if (flag2 || flag3)
         {
             if (!flag)
             {
                 base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ControlLabelWithoutExpression, base.ComputeCurrentXPath(), base.FilePath));
                 return null;
             }
             if (flag2)
             {
                 by.startGroup.control = match2.Control;
             }
             else if (flag3)
             {
                 by.startGroup.labelTextToken = token;
             }
         }
         if (flag)
         {
             ExpressionToken token2 = match.GenerateExpressionToken();
             if (token2 == null)
             {
                 return null;
             }
             by.startGroup.expression = token2;
             return by;
         }
         base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ExpectExpression, base.ComputeCurrentXPath(), base.FilePath));
         return null;
     }
 }
コード例 #3
0
        private GroupBy LoadGroupBySection(XmlNode groupByNode)
        {
            using (this.StackFrame(groupByNode))
            {
                ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this);
                ComplexControlMatch controlMatch = new ComplexControlMatch(this);

                bool expressionNodeFound = false;       // cardinality 0..1

                // these two nodes are mutually exclusive
                bool controlFound = false;              // cardinality 0..1
                bool labelFound = false;              // cardinality 0..1

                GroupBy groupBy = new GroupBy();
                TextToken labelTextToken = null;

                foreach (XmlNode n in groupByNode)
                {
                    if (expressionMatch.MatchNode(n))
                    {
                        if (expressionNodeFound)
                        {
                            this.ProcessDuplicateNode(n);
                            return null; // fatal error
                        }
                        expressionNodeFound = true;
                        if (!expressionMatch.ProcessNode(n))
                            return null; // fatal error
                    }
                    else if (controlMatch.MatchNode(n))
                    {
                        if (controlFound)
                        {
                            this.ProcessDuplicateAlternateNode(n, XmlTags.ComplexControlNode, XmlTags.ComplexControlNameNode);
                            return null;
                        }
                        controlFound = true;
                        if (!controlMatch.ProcessNode(n))
                            return null; // fatal error
                    }
                    else if (MatchNodeNameWithAttributes(n, XmlTags.LabelNode))
                    {
                        if (labelFound)
                        {
                            this.ProcessDuplicateAlternateNode(n, XmlTags.ComplexControlNode, XmlTags.ComplexControlNameNode);
                            return null;
                        }
                        labelFound = true;

                        labelTextToken = LoadLabel(n);
                        if (labelTextToken == null)
                        {
                            return null; // fatal error
                        }
                    }
                    else
                    {
                        this.ProcessUnknownNode(n);
                    }
                }

                if (controlFound && labelFound)
                {
                    //Error at XPath {0} in file {1}: Cannot have control and label at the same time.
                    this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ControlAndLabel, ComputeCurrentXPath(), FilePath));
                    return null; // fatal error
                }

                if (controlFound || labelFound)
                {
                    if (!expressionNodeFound)
                    {
                        //Error at XPath {0} in file {1}: Cannot have control or label without an expression.
                        this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ControlLabelWithoutExpression, ComputeCurrentXPath(), FilePath));
                        return null; // fatal error
                    }
                    if (controlFound)
                    {
                        groupBy.startGroup.control = controlMatch.Control;
                    }
                    else if (labelFound)
                    {
                        groupBy.startGroup.labelTextToken = labelTextToken;
                    }
                }

                if (expressionNodeFound)
                {
                    // we add only if we encountered one, since it's not mandatory
                    ExpressionToken expression = expressionMatch.GenerateExpressionToken();
                    if (expression == null)
                    {
                        return null; // fatal error
                    }
                    groupBy.startGroup.expression = expression;
                    return groupBy;
                }


                // failure: expression is mandatory
                //Error at XPath {0} in file {1}: An expression is expected.
                this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ExpectExpression, ComputeCurrentXPath(), FilePath));
                return null;
            }
        }