public static AstXNameBindingAttribute FindBindingAttributeForSubtype(MemberInfo memberInfo, Type subtype) { var bindingAttributes = CustomAttributeProvider.Global.GetAttribute <AstXNameBindingAttribute>(memberInfo, false); AstXNameBindingAttribute lastMatched = null; foreach (AstXNameBindingAttribute bindingAttribute in bindingAttributes) { if (!bindingAttribute.HasSubtypeOverride || bindingAttribute.SubtypeOverride.IsAssignableFrom(subtype)) { lastMatched = bindingAttribute; } } return(lastMatched); }
private static void ParseChildElements(ParserContext context) { foreach (XElement childElement in context.XElement.Elements()) { PropertyBindingAttributePair propertyBinding = PropertyBinder.GetPropertyBinding(context, childElement.Name, false); ParseChildXObject(context, childElement, childElement.Value, propertyBinding == null ? null : propertyBinding.Property); } XElement element = context.XElement; PropertyBindingAttributePair textPropertyBinding = PropertyBinder.GetPropertyBinding(context, XName.Get("__self", element.Name.NamespaceName), false); AstXNameBindingAttribute textBindingAttribute = textPropertyBinding == null ? null : textPropertyBinding.BindingAttribute; if (textBindingAttribute != null && textBindingAttribute.IsSelf) { ParseChildXObject(context, element.LastNode, element.Value, textPropertyBinding.Property); } }
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); } }
public PropertyBindingAttributePair(PropertyInfo property, AstXNameBindingAttribute bindingAttribute) { Property = property; BindingAttribute = bindingAttribute; }
public PropertyBindingAttributePair(PropertyInfo Property, AstXNameBindingAttribute BindingAttribute) { this.Property = Property; this.BindingAttribute = BindingAttribute; }
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); } }