Пример #1
0
 /// <summary>
 /// Specifies the equality function for the xml tree annotation
 /// </summary>
 /// <param name="xmlTree">The xml tree annotation</param>
 /// <param name="func">The equality function</param>
 /// <returns>The annotation with the equality function set</returns>
 public static XmlTreeAnnotation SetValueEqualityFunc(this XmlTreeAnnotation xmlTree, Func <object, object, bool> func)
 {
     ExceptionUtilities.CheckArgumentNotNull(func, "func");
     ExceptionUtilities.CheckArgumentNotNull(xmlTree, "xmlTree");
     xmlTree.ValueEqualityFunc = func;
     return(xmlTree);
 }
Пример #2
0
        /// <summary>
        /// Creates a clone of the annotation
        /// </summary>
        /// <returns>a clone of the annotation</returns>
        public override ODataPayloadElementAnnotation Clone()
        {
            var clone = new XmlTreeAnnotation
            {
                PropertyValue     = this.PropertyValue,
                NamespaceName     = this.NamespaceName,
                NamespacePrefix   = this.NamespacePrefix,
                LocalName         = this.LocalName,
                IsAttribute       = this.IsAttribute,
                ValueEqualityFunc = this.ValueEqualityFunc,
            };

            clone.Children.AddRange(this.Children.Select(c => (XmlTreeAnnotation)c.Clone()).ToArray());
            return(clone);
        }
        private static AtomGeneratorMetadata CreateGeneratorMetadata(XmlTreeAnnotation epmTree)
        {
            AtomGeneratorMetadata metadata = new AtomGeneratorMetadata()
            {
                Name = epmTree.PropertyValue
            };

            foreach (XmlTreeAnnotation attribute in epmTree.Children.Where(child => child.IsAttribute))
            {
                if (string.IsNullOrEmpty(attribute.NamespaceName))
                {
                    string localName = attribute.LocalName;
                    if (localName == TestAtomConstants.AtomGeneratorUriAttributeName)
                    {
                        metadata.Uri = string.IsNullOrEmpty(attribute.PropertyValue) ? null : new Uri(attribute.PropertyValue);
                    }
                    else if (localName == TestAtomConstants.AtomGeneratorVersionAttributeName)
                    {
                        metadata.Version = attribute.PropertyValue;
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported metadata '" + localName + "' found for a generator.");
                    }
                }
            }

            return metadata;
        }
Пример #4
0
        /// <summary>
        /// Creates a clone of the annotation
        /// </summary>
        /// <returns>a clone of the annotation</returns>
        public override ODataPayloadElementAnnotation Clone()
        {
            var clone = new XmlTreeAnnotation
            {
                PropertyValue = this.PropertyValue,
                NamespaceName = this.NamespaceName,
                NamespacePrefix = this.NamespacePrefix,
                LocalName = this.LocalName,
                IsAttribute = this.IsAttribute,
                ValueEqualityFunc = this.ValueEqualityFunc,
            };

            clone.Children.AddRange(this.Children.Select(c => (XmlTreeAnnotation)c.Clone()).ToArray());
            return clone;
        }
        /// <summary>
        /// Builds the entity-property-mapping tree represented by the given xml element
        /// </summary>
        /// <param name="element">The element to build from</param>
        /// <returns>The entity-property-mapping tree</returns>
        private XmlTreeAnnotation BuildEpmTree(XElement element)
        {
            var mappedProperty = new XmlTreeAnnotation()
            {
                IsAttribute = false,
                LocalName = element.Name.LocalName,
                NamespaceName = element.Name.NamespaceName,
                NamespacePrefix = element.GetPrefixOfNamespace(element.Name.Namespace),
                PropertyValue = element.Nodes().OfType<XText>().Select(t => t.Value).SingleOrDefault(),
            };

            foreach (var subElement in element.Elements())
            {
                mappedProperty.Children.Add(this.BuildEpmTree(subElement));
            }

            foreach (var attribute in element.Attributes().Where(a => !a.IsNamespaceDeclaration))
            {
                mappedProperty.Children.Add(this.BuildEpmTree(attribute));
            }

            return mappedProperty;
        }