Example #1
0
        private void BindXPathQuery(AstNode parentASTNode, XElement xElement, PropertyBindingAttributePair propertyBinding, AstXNameBindingAttribute BindingAttribute, XmlIRDocumentType docType)
        {
            object EvaluationResult = xElement.XPathEvaluate(BindingAttribute.XPathQuery);

            if (IsContainerOf(typeof(IEnumerable <object>), EvaluationResult.GetType()))
            {
                foreach (object child in (IEnumerable <object>)EvaluationResult)
                {
                    XAttribute childAttribute = child as XAttribute;
                    XElement   childElement   = child as XElement;
                    XText      childText      = child as XText;
                    if (childAttribute != null)
                    {
                        ParseChildXObject(parentASTNode, childAttribute, childAttribute.Name, childAttribute.Value, propertyBinding.Property, docType);
                    }
                    else if (childElement != null)
                    {
                        ParseChildXObject(parentASTNode, childElement, childElement.Name, childElement.Value, propertyBinding.Property, docType);
                    }
                    else if (childText != null)
                    {
                        ParseChildXObject(parentASTNode, childText, null, childText.Value, propertyBinding.Property, docType);
                    }
                }
            }
            else
            {
                XAttribute xResult = new XAttribute(XName.Get("XPathEvaluationResult", this._DefaultXmlNamespace), EvaluationResult);
                ParseChildXObject(parentASTNode, xResult, xResult.Name, xResult.Value, propertyBinding.Property, docType);
            }
        }
Example #2
0
 private void ParseAttributes(XElement element, AstNode astNode, XmlIRDocumentType docType)
 {
     foreach (XAttribute xAttribute in element.Attributes())
     {
         PropertyBindingAttributePair propertyBinding = GetPropertyBinding(astNode, xAttribute.Name, true);
         ParseChildXObject(astNode, xAttribute, xAttribute.Name, xAttribute.Value, propertyBinding == null ? null : propertyBinding.Property, docType);
     }
 }
Example #3
0
        private void ParseChildElements(XElement element, AstNode parentASTNode, XmlIRDocumentType docType)
        {
            foreach (XElement xElement in element.Elements())
            {
                PropertyBindingAttributePair propertyBinding = GetPropertyBinding(parentASTNode, xElement.Name, false);

                AstXNameBindingAttribute BindingAttribute = propertyBinding == null ? null : propertyBinding.BindingAttribute;
                if (BindingAttribute != null && BindingAttribute.HasXPathQuery)
                {
                    BindXPathQuery(parentASTNode, xElement, propertyBinding, BindingAttribute, docType);
                }
                ParseChildXObject(parentASTNode, xElement, xElement.Name, xElement.Value, propertyBinding == null ? null : propertyBinding.Property, docType);
            }
            PropertyBindingAttributePair textPropertyBinding  = GetPropertyBinding(parentASTNode, XName.Get("__self", element.Name.NamespaceName));
            AstXNameBindingAttribute     textBindingAttribute = textPropertyBinding == null ? null : textPropertyBinding.BindingAttribute;

            if (textBindingAttribute != null && textBindingAttribute.HasXPathQuery)
            {
                BindXPathQuery(parentASTNode, element, textPropertyBinding, textBindingAttribute, docType);
            }
        }
Example #4
0
        private void BindXPathQuery(AstNode parentASTNode, XElement xElement, PropertyBindingAttributePair propertyBinding, AstXNameBindingAttribute BindingAttribute, XmlIRDocumentType docType)
        {
            object EvaluationResult = xElement.XPathEvaluate(BindingAttribute.XPathQuery);

            if (IsContainerOf(typeof(IEnumerable<object>), EvaluationResult.GetType()))
            {
                foreach (object child in (IEnumerable<object>)EvaluationResult)
                {
                    XAttribute childAttribute = child as XAttribute;
                    XElement childElement = child as XElement;
                    XText childText = child as XText;
                    if (childAttribute != null)
                    {
                        ParseChildXObject(parentASTNode, childAttribute, childAttribute.Name, childAttribute.Value, propertyBinding.Property, docType);
                    }
                    else if (childElement != null)
                    {
                        ParseChildXObject(parentASTNode, childElement, childElement.Name, childElement.Value, propertyBinding.Property, docType);
                    }
                    else if (childText != null)
                    {
                        ParseChildXObject(parentASTNode, childText, null, childText.Value, propertyBinding.Property, docType);
                    }
                }
            }
            else
            {
                XAttribute xResult = new XAttribute(XName.Get("XPathEvaluationResult", this._DefaultXmlNamespace), EvaluationResult);
                ParseChildXObject(parentASTNode, xResult, xResult.Name, xResult.Value, propertyBinding.Property, docType);
            }

        }