Exemplo n.º 1
0
        /// <summary>
        ///     Determine whether the object's XML contains the specified position.
        /// </summary>
        /// <param name="position">
        ///     The target position.
        /// </param>
        /// <returns>
        ///     <c>true</c>, if the the specified position lies within the object's XML span; otherwise, <c>false</c>.
        /// </returns>
        public bool XmlContains(Position position)
        {
            if (position == null)
            {
                throw new ArgumentNullException(nameof(position));
            }

            return(XmlRange.Contains(position));
        }
Exemplo n.º 2
0
        public static XmlElement GetFirstXmlElement(XmlDocument xDoc, string name, string attribute, string value, XmlRange range)
        {
            string xPath = GetXPath(name, attribute, value, range);

            return(GetFirstXmlElement(xDoc, xPath));
        }
Exemplo n.º 3
0
        public static XmlNodeList GetXmlNodeList(XmlDocument xDoc, string name, XmlRange range)
        {
            string xPath = GetXPath(name, null, null, range);

            return(GetXmlNodeList(xDoc, xPath));
        }
Exemplo n.º 4
0
        public static IEnumerable <XElement> GetXElement(XDocument xDoc, string name, string attribute, string value, XmlRange range)
        {
            string xPath = GetXPath(name, null, null, range);

            return(xDoc.Root.XPathSelectElements(xPath));
        }
Exemplo n.º 5
0
        public static XmlElement GetFirstXmlElement(XmlElement xElement, string name, XmlRange range)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xElement.OuterXml);
            return(GetFirstXmlElement(xmlDocument, name, range));
        }
Exemplo n.º 6
0
        public static XElement GetFirstXElement(XDocument xDoc, string name, XmlRange range)
        {
            string xPath = GetXPath(name, null, null, range);

            return(xDoc.Root.XPathSelectElement(xPath));
        }
Exemplo n.º 7
0
        public static IEnumerable <XElement> GetXElement(XElement xElement, string name, string attribute, string value, XmlRange range)
        {
            string xPath = GetXPath(name, null, null, range);

            return(GetXElement(xElement, xPath));
        }
Exemplo n.º 8
0
        public static XElement GetFirstXElement(XElement xElement, string name, XmlRange range)
        {
            string xPath = GetXPath(name, null, null, range);

            return(GetFirstXElement(xElement, xPath));
        }
Exemplo n.º 9
0
        public static string GetXPath(string xeName, string xeAttribute, string xeValue, XmlRange range)
        {
            string result = null;

            switch (range)
            {
            case XmlRange.All:
                result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? ("//" + xeName) : $"//{xeName}[@{xeAttribute}=\"{xeValue}\"]");
                break;

            case XmlRange.Root:
                result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? ("/" + xeName) : $"/{xeName}[@{xeAttribute}=\"{xeValue}\"]");
                break;

            case XmlRange.ThisNode:
                result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? (xeName ?? "") : $"{xeName}[@{xeAttribute}=\"{xeValue}\"]");
                break;
            }
            return(result);
        }
Exemplo n.º 10
0
 /// <summary>
 ///     Determine whether the object's XML contains the specified position.
 /// </summary>
 /// <param name="position">
 ///     The target position.
 /// </param>
 /// <returns>
 ///     <c>true</c>, if the specified position lies within the object's XML span; otherwise, <c>false</c>.
 /// </returns>
 public bool XmlContains(Position position)
 {
     return(XmlRange.Contains(position));
 }