Example #1
0
 public ControllerNodeSet(ControllerNodeSet nodeSet, List<XPathNavigator> nodes)
 {
     this._navigator = nodeSet._navigator;
     this._resolver = nodeSet._resolver;
     this._nodes = nodes;
 }
Example #2
0
 public ControllerNodeSet SelectDataFields(params System.String[] fieldNames)
 {
     List<XPathNavigator> list = new List<XPathNavigator>();
     foreach (XPathNavigator node in _nodes)
     {
         ControllerNodeSet nodeSet = new ControllerNodeSet(this, node);
         if (fieldNames.Length == 0)
             list.AddRange(nodeSet.SelectInContext("dataField", "dataField").Nodes);
         else
             list.AddRange(nodeSet.SelectInContext("dataField", "dataField[@fieldName=$fieldName]", fieldNames).Nodes);
     }
     return new ControllerNodeSet(this, list);
 }
Example #3
0
 public ControllerNodeSet Move(ControllerNodeSet target)
 {
     if (target.Nodes.Count != 1)
         return this;
     XPathNavigator targetNode = target.Nodes[0];
     foreach (XPathNavigator node in _nodes)
     {
         bool skip = true;
         if (((targetNode.Name == "category") || (targetNode.Name == "view")) && (node.Name == "dataField"))
             skip = false;
         if ((targetNode.Name == "actionGroup") && (node.Name == "action"))
             skip = false;
         if (!(skip))
         {
             XPathNavigator newParent = targetNode;
             if (targetNode.Name == "category")
                 newParent = targetNode.SelectSingleNode("c:dataFields", _resolver);
             if (newParent != null)
             {
                 newParent.AppendChild(node);
                 node.DeleteSelf();
             }
         }
     }
     return new ControllerNodeSet(this, targetNode);
 }
Example #4
0
 public ControllerNodeSet(ControllerNodeSet nodeSet, XPathNavigator node)
     : this(nodeSet, new List<XPathNavigator>())
 {
     _nodes.Add(node);
 }
Example #5
0
 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;
 }
Example #6
0
 public ControllerNodeSet(ControllerNodeSet nodeSet)
     : this(nodeSet._navigator, nodeSet._resolver)
 {
 }
Example #7
0
 public ControllerNodeSet CreateActionGroup(string id)
 {
     ControllerNodeSet actionGroupNode = new ControllerNodeSet(_navigator, _resolver).Select("<actionGroup/>").AppendTo("/dataController/actions").Select("/dataController/actions/actionGroup[last()]");
     if (!(String.IsNullOrEmpty(id)))
         actionGroupNode.Attr("id", id);
     return actionGroupNode;
 }
Example #8
0
 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;
 }
Example #9
0
 private ControllerNodeSet SetProperty(string name, object value, params System.String[] requiresElement)
 {
     foreach (XPathNavigator node in _nodes)
     {
         ControllerNodeSet nodeSet = new ControllerNodeSet(this, node);
         if (Array.IndexOf(requiresElement, node.Name) >= 0)
             nodeSet.Elem(name, value);
         else
             nodeSet.Attr(name, value);
     }
     return this;
 }
Example #10
0
 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);
 }
Example #11
0
 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;
 }
Example #12
0
 public ControllerNodeSet Use()
 {
     if (_nodes.Count > 0)
     {
         StringBuilder sb = new StringBuilder();
         foreach (XPathNavigator node in _nodes)
             sb.Append(node.OuterXml);
         string nodeName = _nodes[0].Name;
         XPathNavigator parentNode = _nodes[0].SelectSingleNode("parent::*");
         parentNode.InnerXml = sb.ToString();
         ControllerNodeSet nodeSet = new ControllerNodeSet(this, parentNode);
         List<XPathNavigator> list = new List<XPathNavigator>();
         list.AddRange(nodeSet.SelectInContext(nodeName, nodeName).Nodes);
         return new ControllerNodeSet(this, list);
     }
     return this;
 }
Example #13
0
 /// <summary>
 /// Appends a collection specified by the argument to each node in the node sets.
 /// </summary>
 /// <param name="nodeSet">The collection of child nodes.</param>
 /// <returns>The collection of child nodes after they were appended to the nodes in the original node set.</returns>
 public ControllerNodeSet AppendTo(ControllerNodeSet nodeSet)
 {
     foreach (XPathNavigator node in this._nodes)
         foreach (XPathNavigator parentNode in nodeSet._nodes)
             parentNode.AppendChild(node.OuterXml);
     return nodeSet;
 }