public ControllerNodeSet CreateDataField(string fieldName, string aliasFieldName) { ControllerNodeSet existingFieldNode = SelectDataField(fieldName); if (existingFieldNode.Nodes.Count > 0) return existingFieldNode; foreach (XPathNavigator node in _nodes) { ControllerNodeSet parentNode = new ControllerNodeSet(this, node); ControllerNodeSet dataFieldsNode = parentNode; if (node.Name != "dataFields") { dataFieldsNode = parentNode.Select("dataFields|ancestor::dataFields[1]"); if (dataFieldsNode.Nodes.Count == 0) { Select("<dataFields/>").AppendTo(parentNode); dataFieldsNode = parentNode.Select("dataFields"); } } ControllerNodeSet dataFieldNode = Select("<dataField/>").AppendTo(dataFieldsNode).Select("dataField[last()]").Attr("fieldName", fieldName); if (!(String.IsNullOrEmpty(aliasFieldName))) dataFieldNode.Attr("aliasFieldName", aliasFieldName); return dataFieldNode; } return this; }
protected ControllerNodeSet SelectFieldItemsNode() { List<XPathNavigator> list = new List<XPathNavigator>(); foreach (XPathNavigator node in _nodes) { ControllerNodeSet parentNode = new ControllerNodeSet(this, node); ControllerNodeSet itemsNode = parentNode.Select("items"); if (itemsNode.Nodes.Count == 0) { parentNode.Select("<items/>").AppendTo(parentNode); itemsNode = parentNode.Select("items"); } list.AddRange(itemsNode.Nodes); } return new ControllerNodeSet(this, list); }
public ControllerNodeSet CreateCategory(string id, string headerText) { foreach (XPathNavigator node in _nodes) { ControllerNodeSet parentNode = new ControllerNodeSet(this, node); ControllerNodeSet categoriesNode = parentNode; if (node.Name != "categories") { categoriesNode = parentNode.Select("categories|ancestor::categories[1]"); if (categoriesNode.Nodes.Count == 0) { Select("<categories/>").AppendTo(parentNode); categoriesNode = parentNode.Select("categories"); } } return Select("<category/>").AppendTo(categoriesNode).Select("category[last()]").Attr("id", id).Attr("headerText", headerText).Elem("dataFields", null); } return this; }
protected ControllerNodeSet CreateExpression(string rootElement, params System.String[] attributes) { foreach (XPathNavigator node in _nodes) { ControllerNodeSet nodeSet = new ControllerNodeSet(this, node); ControllerNodeSet rootNode = nodeSet.Select(rootElement); if (rootNode.Nodes.Count == 0) { Select(String.Format("<{0}/>", rootElement)).AppendTo(nodeSet); rootNode = nodeSet.Select(rootElement); } ControllerNodeSet expressionNode = nodeSet.Select("expression[1]"); if (expressionNode.Nodes.Count == 0) { Select("<expression/>").AppendTo(rootNode); expressionNode = rootNode.Select("expression"); } int i = 0; while (i < attributes.Length) { expressionNode.Attr(attributes[i], attributes[(i + 1)]); i = (i + 2); } } return this; }