/// <summary>
        /// Reads a an association link in atom:entry.
        /// </summary>
        /// <param name="entryState">The reader entry state for the entry being read.</param>
        /// <param name="linkRelation">The rel attribute value for the link, unescaped parsed URI.</param>
        /// <param name="linkHRef">The href attribute value for the link (or null if the href attribute was not present).</param>
        /// <returns>true, if the association link was read succesfully, false otherwise.</returns>
        /// <remarks>
        /// Pre-Condition:   XmlNodeType.Element atom:link  - The atom:link element to read.
        /// Post-Condition:  Any                            - The node after the atom:link element if the link was read by this method.
        ///                  XmlNodeType.Element atom:link  - The atom:link element to read if the link was not read by this method.
        /// </remarks>
        private bool TryReadAssociationLinkInEntry(IODataAtomReaderEntryState entryState, string linkRelation, string linkHRef)
        {
            Debug.Assert(entryState != null, "entryState != null");
            Debug.Assert(linkRelation != null, "linkRelation != null");
            this.XmlReader.AssertNotBuffering();
            this.AssertXmlCondition(XmlNodeType.Element);
            Debug.Assert(
                this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace && this.XmlReader.LocalName == AtomConstants.AtomLinkElementName,
                "The XML reader must be on the atom:link element for this method to work.");

            string associationLinkName = AtomUtils.GetNameFromAtomLinkRelationAttribute(linkRelation, AtomConstants.ODataNavigationPropertiesAssociationLinkRelationPrefix);
            if (string.IsNullOrEmpty(associationLinkName) || !this.ReadingResponse || this.MessageReaderSettings.MaxProtocolVersion < ODataVersion.V3)
            {
                return false;
            }

            ReaderValidationUtils.ValidateNavigationPropertyDefined(associationLinkName, entryState.EntityType, this.MessageReaderSettings);

            // Get the type of the link
            string asssociationLinkType = this.XmlReader.GetAttribute(this.AtomTypeAttributeName, this.EmptyNamespace);

            if (asssociationLinkType != null &&
                !HttpUtils.CompareMediaTypeNames(asssociationLinkType, MimeConstants.MimeApplicationXml))
            {
                throw new ODataException(o.Strings.ODataAtomEntryAndFeedDeserializer_InvalidTypeAttributeOnAssociationLink(associationLinkName));
            }

            ODataAssociationLink associationLink = new ODataAssociationLink { Name = associationLinkName };

            // Allow null (we won't set the Url property) and empty (relative URL) values.
            if (linkHRef != null)
            {
                associationLink.Url = this.ProcessUriFromPayload(linkHRef, this.XmlReader.XmlBaseUri);
            }

            entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink);
            ReaderUtils.AddAssociationLinkToEntry(entryState.Entry, associationLink);

            // Read and store ATOM link metadata (captures extra info like lang, title) if ATOM metadata reading is turned on.
            AtomLinkMetadata atomLinkMetadata = this.EntryMetadataDeserializer.ReadAtomLinkElementInEntryContent(linkRelation, linkHRef);
            if (atomLinkMetadata != null)
            {
                associationLink.SetAnnotation(atomLinkMetadata);
            }

            this.XmlReader.Skip();
            return true;
        }
 private bool TryReadAssociationLinkInEntry(IODataAtomReaderEntryState entryState, string linkRelation, string linkHRef)
 {
     string nameFromAtomLinkRelationAttribute = AtomUtils.GetNameFromAtomLinkRelationAttribute(linkRelation, "http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/");
     if ((string.IsNullOrEmpty(nameFromAtomLinkRelationAttribute) || !base.ReadingResponse) || (base.MessageReaderSettings.MaxProtocolVersion < ODataVersion.V3))
     {
         return false;
     }
     ReaderValidationUtils.ValidateNavigationPropertyDefined(nameFromAtomLinkRelationAttribute, entryState.EntityType, base.MessageReaderSettings);
     string attribute = base.XmlReader.GetAttribute(base.AtomTypeAttributeName, base.EmptyNamespace);
     if ((attribute != null) && !HttpUtils.CompareMediaTypeNames(attribute, "application/xml"))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomEntryAndFeedDeserializer_InvalidTypeAttributeOnAssociationLink(nameFromAtomLinkRelationAttribute));
     }
     ODataAssociationLink associationLink = new ODataAssociationLink {
         Name = nameFromAtomLinkRelationAttribute
     };
     if (linkHRef != null)
     {
         associationLink.Url = base.ProcessUriFromPayload(linkHRef, base.XmlReader.XmlBaseUri);
     }
     entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink);
     ReaderUtils.AddAssociationLinkToEntry(entryState.Entry, associationLink);
     AtomLinkMetadata annotation = this.EntryMetadataDeserializer.ReadAtomLinkElementInEntryContent(linkRelation, linkHRef);
     if (annotation != null)
     {
         associationLink.SetAnnotation<AtomLinkMetadata>(annotation);
     }
     base.XmlReader.Skip();
     return true;
 }