private ExpressionToken LoadItemSelectionCondition(XmlNode itemNode) { using (this.StackFrame(itemNode)) { bool expressionNodeFound = false; // cardinality 1 ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this); foreach (XmlNode n in itemNode.ChildNodes) { if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { this.ProcessDuplicateNode(n); return(null); // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) { return(null); } } else { this.ProcessUnknownNode(n); } } return(expressionMatch.GenerateExpressionToken()); } }
private TypeOrGroupReference LoadSelectionConditionNode(System.Xml.XmlNode selectionConditionNode) { using (base.StackFrame(selectionConditionNode)) { TypeOrGroupReference reference = null; bool flag = false; bool flag2 = false; bool flag3 = false; ExpressionNodeMatch match = new ExpressionNodeMatch(this); foreach (System.Xml.XmlNode node in selectionConditionNode.ChildNodes) { if (base.MatchNodeName(node, "SelectionSetName")) { if (flag3) { base.ProcessDuplicateAlternateNode(node, "SelectionSetName", "TypeName"); return null; } flag3 = true; TypeGroupReference reference2 = this.LoadTypeGroupReference(node); if (reference2 == null) { return null; } reference = reference2; } else if (base.MatchNodeName(node, "TypeName")) { if (flag2) { base.ProcessDuplicateAlternateNode(node, "SelectionSetName", "TypeName"); return null; } flag2 = true; TypeReference reference3 = this.LoadTypeReference(node); if (reference3 == null) { return null; } reference = reference3; } else if (match.MatchNode(node)) { if (flag) { base.ProcessDuplicateNode(node); return null; } flag = true; if (!match.ProcessNode(node)) { return null; } } else { base.ProcessUnknownNode(node); } } if (flag2 && flag3) { base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.SelectionSetNameAndTypeName, base.ComputeCurrentXPath(), base.FilePath)); return null; } if (reference == null) { base.ReportMissingNodes(new string[] { "SelectionSetName", "TypeName" }); return null; } if (flag) { reference.conditionToken = match.GenerateExpressionToken(); if (reference.conditionToken == null) { return null; } return reference; } base.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.ExpectExpression, base.ComputeCurrentXPath(), base.FilePath)); return null; } }
private bool LoadPropertyBaseHelper(System.Xml.XmlNode propertyBaseNode, PropertyTokenBase ptb, List<System.Xml.XmlNode> unprocessedNodes) { ExpressionNodeMatch match = new ExpressionNodeMatch(this); bool flag = false; bool flag2 = false; bool flag3 = false; ExpressionToken token = null; foreach (System.Xml.XmlNode node in propertyBaseNode.ChildNodes) { if (match.MatchNode(node)) { if (flag) { base.ProcessDuplicateNode(node); return false; } flag = true; if (!match.ProcessNode(node)) { return false; } } else if (base.MatchNodeName(node, "EnumerateCollection")) { if (flag2) { base.ProcessDuplicateNode(node); return false; } flag2 = true; if (!this.ReadBooleanNode(node, out ptb.enumerateCollection)) { return false; } } else if (base.MatchNodeName(node, "ItemSelectionCondition")) { if (flag3) { base.ProcessDuplicateNode(node); return false; } flag3 = true; token = this.LoadItemSelectionCondition(node); if (token == null) { return false; } } else if (!XmlLoaderBase.IsFilteredOutNode(node)) { unprocessedNodes.Add(node); } } if (flag) { ExpressionToken token2 = match.GenerateExpressionToken(); if (token2 == null) { return false; } ptb.expression = token2; ptb.conditionToken = token; } return true; }
private ExpressionToken LoadItemSelectionCondition(System.Xml.XmlNode itemNode) { using (base.StackFrame(itemNode)) { bool flag = false; ExpressionNodeMatch match = new ExpressionNodeMatch(this); foreach (System.Xml.XmlNode node in itemNode.ChildNodes) { if (match.MatchNode(node)) { if (flag) { base.ProcessDuplicateNode(node); return null; } flag = true; if (!match.ProcessNode(node)) { return null; } } else { base.ProcessUnknownNode(node); } } return match.GenerateExpressionToken(); } }
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; } }
internal bool ProcessExpressionDirectives(XmlNode containerNode, List<XmlNode> unprocessedNodes) { if (containerNode == null) throw PSTraceSource.NewArgumentNullException("containerNode"); string formatString = null; TextToken textToken = null; ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(_loader); bool formatStringNodeFound = false; // cardinality 0..1 bool expressionNodeFound = false; // cardinality 0..1 bool textNodeFound = false; // cardinality 0..1 foreach (XmlNode n in containerNode.ChildNodes) { if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { _loader.ProcessDuplicateNode(n); return false; // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) return false; // fatal error } else if (_loader.MatchNodeName(n, XmlTags.FormatStringNode)) { if (formatStringNodeFound) { _loader.ProcessDuplicateNode(n); return false; // fatal error } formatStringNodeFound = true; formatString = _loader.GetMandatoryInnerText(n); if (formatString == null) { //Error at XPath {0} in file {1}: Missing a format string. _loader.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NoFormatString, _loader.ComputeCurrentXPath(), _loader.FilePath)); return false; // fatal error } } else if (_loader.MatchNodeNameWithAttributes(n, XmlTags.TextNode)) { if (textNodeFound) { _loader.ProcessDuplicateNode(n); return false; // fatal error } textNodeFound = true; textToken = _loader.LoadText(n); if (textToken == null) { //Error at XPath {0} in file {1}: Invalid {2}. _loader.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidNode, _loader.ComputeCurrentXPath(), _loader.FilePath, XmlTags.TextNode)); return false; // fatal error } } else { // for further processing by calling context unprocessedNodes.Add(n); } } // foreach if (expressionNodeFound) { // RULE: cannot have a text node and an expression at the same time if (textNodeFound) { //Error at XPath {0} in file {1}: {2} cannot be specified with an expression. _loader.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NodeWithExpression, _loader.ComputeCurrentXPath(), _loader.FilePath, XmlTags.TextNode)); return false; // fatal error } ExpressionToken expression = expressionMatch.GenerateExpressionToken(); if (expression == null) { return false; // fatal error } // set the output data if (!string.IsNullOrEmpty(formatString)) { _formatString = formatString; } _expression = expression; } else { // RULE: we cannot have a format string without an expression node if (formatStringNodeFound) { //Error at XPath {0} in file {1}: {2} cannot be specified without an expression. _loader.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.NodeWithoutExpression, _loader.ComputeCurrentXPath(), _loader.FilePath, XmlTags.FormatStringNode)); return false; // fatal error } // we might have a text node if (textNodeFound) { _textToken = textToken; } } return true; }
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; } }
private TypeOrGroupReference LoadSelectionConditionNode(XmlNode selectionConditionNode) { using (this.StackFrame(selectionConditionNode)) { TypeOrGroupReference retVal = null; bool expressionNodeFound = false; // cardinality 1 // these two nodes are mutually exclusive bool typeFound = false; // cardinality 0..1 bool typeGroupFound = false; // cardinality 0..1 ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this); foreach (XmlNode n in selectionConditionNode.ChildNodes) { if (MatchNodeName(n, XmlTags.SelectionSetNameNode)) { if (typeGroupFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.SelectionSetNameNode, XmlTags.TypeNameNode); return null; } typeGroupFound = true; TypeGroupReference tgr = LoadTypeGroupReference(n); if (tgr != null) { retVal = tgr; } else { return null; } } else if (MatchNodeName(n, XmlTags.TypeNameNode)) { if (typeFound) { this.ProcessDuplicateAlternateNode(n, XmlTags.SelectionSetNameNode, XmlTags.TypeNameNode); return null; } typeFound = true; TypeReference tr = LoadTypeReference(n); if (tr != null) { retVal = tr; } else { return null; } } else if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { this.ProcessDuplicateNode(n); return null; // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) return null; // fatal error } else { this.ProcessUnknownNode(n); } } if (typeFound && typeGroupFound) { //Error at XPath {0} in file {1}: Cannot have SelectionSetName and TypeName at the same time. this.ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.SelectionSetNameAndTypeName, ComputeCurrentXPath(), FilePath)); return null; // fatal error } if (retVal == null) { // missing mandatory node this.ReportMissingNodes(new string[] { XmlTags.SelectionSetNameNode, XmlTags.TypeNameNode }); return null; } if (expressionNodeFound) { // mandatory node retVal.conditionToken = expressionMatch.GenerateExpressionToken(); if (retVal.conditionToken == null) { return null; // fatal error } return retVal; } // 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; } }
private bool LoadPropertyBaseHelper(XmlNode propertyBaseNode, PropertyTokenBase ptb, List <XmlNode> unprocessedNodes) { ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this); bool expressionNodeFound = false; // cardinality 0..1 bool collectionNodeFound = false; // cardinality 0..1 bool itemSelectionConditionNodeFound = false; // cardinality 0..1 ExpressionToken condition = null; foreach (XmlNode n in propertyBaseNode.ChildNodes) { if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { this.ProcessDuplicateNode(n); return(false); // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) { return(false); // fatal error } } else if (MatchNodeName(n, XmlTags.EnumerateCollectionNode)) { if (collectionNodeFound) { this.ProcessDuplicateNode(n); return(false); } collectionNodeFound = true; if (!ReadBooleanNode(n, out ptb.enumerateCollection)) { return(false); } } else if (MatchNodeName(n, XmlTags.ItemSelectionConditionNode)) { if (itemSelectionConditionNodeFound) { this.ProcessDuplicateNode(n); return(false); } itemSelectionConditionNodeFound = true; condition = LoadItemSelectionCondition(n); if (condition == null) { return(false); } } else { if (!IsFilteredOutNode(n)) { unprocessedNodes.Add(n); } } } // foreach if (expressionNodeFound) { // we add only if we encountered one, since it's not mandatory ExpressionToken expression = expressionMatch.GenerateExpressionToken(); if (expression == null) { return(false); // fatal error } ptb.expression = expression; ptb.conditionToken = condition; } return(true); }
private ExpressionToken LoadItemSelectionCondition(XmlNode itemNode) { using (this.StackFrame(itemNode)) { bool expressionNodeFound = false; // cardinality 1 ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this); foreach (XmlNode n in itemNode.ChildNodes) { if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { this.ProcessDuplicateNode(n); return null; // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) return null; } else { this.ProcessUnknownNode(n); } } return expressionMatch.GenerateExpressionToken(); } }
private bool LoadPropertyBaseHelper(XmlNode propertyBaseNode, PropertyTokenBase ptb, List<XmlNode> unprocessedNodes) { ExpressionNodeMatch expressionMatch = new ExpressionNodeMatch(this); bool expressionNodeFound = false; // cardinality 0..1 bool collectionNodeFound = false; // cardinality 0..1 bool itemSelectionConditionNodeFound = false; // cardinality 0..1 ExpressionToken condition = null; foreach (XmlNode n in propertyBaseNode.ChildNodes) { if (expressionMatch.MatchNode(n)) { if (expressionNodeFound) { this.ProcessDuplicateNode(n); return false; // fatal error } expressionNodeFound = true; if (!expressionMatch.ProcessNode(n)) return false; // fatal error } else if (MatchNodeName(n, XmlTags.EnumerateCollectionNode)) { if (collectionNodeFound) { this.ProcessDuplicateNode(n); return false; } collectionNodeFound = true; if (!ReadBooleanNode(n, out ptb.enumerateCollection)) return false; } else if (MatchNodeName(n, XmlTags.ItemSelectionConditionNode)) { if (itemSelectionConditionNodeFound) { this.ProcessDuplicateNode(n); return false; } itemSelectionConditionNodeFound = true; condition = LoadItemSelectionCondition(n); if (condition == null) { return false; } } else { if (!IsFilteredOutNode(n)) unprocessedNodes.Add(n); } } // foreach if (expressionNodeFound) { // we add only if we encountered one, since it's not mandatory ExpressionToken expression = expressionMatch.GenerateExpressionToken(); if (expression == null) { return false; // fatal error } ptb.expression = expression; ptb.conditionToken = condition; } return true; }