Example #1
0
        private static XPath XPathForProperty(XPath root, PropertyInfo property)
        {
            var hasAttrName = property.GetCustomAttribute <FromAttr>(true) != null;
            var attrName    = hasAttrName
                                ? property.GetCustomAttribute <FromAttr>(true)?.Node ?? property.Name
                                : null;
            var nodeName = property.GetCustomAttribute <FromNode>(true)?.Node
                           ?? property.Name;

            var xpath = !string.IsNullOrEmpty(attrName)
                            ? root.Append($"@{attrName}")
                            : root.Append(nodeName);

            return(xpath);
        }
Example #2
0
 protected override void WritePredicates(XPathPart pathPart)
 {
     WritePredicateStart();
     XPath.Append(GetElementIndex((XElement)pathPart.Node));
     WritePredicateEnd();
     base.WritePredicates(pathPart);
 }
 protected override void WriteAttributeNameWithPrefix(string namespacePrefix, string localName)
 {
     XPath.Append(localName);
 }
 protected override void WriteAttributeNameWithoutPrefix(XName name)
 {
     XPath.Append(name.LocalName);
 }
 protected override void WriteElementNameWithoutPrefix(XName element)
 {
     XPath.Append(element.LocalName);
 }