/// <summary> /// Write the metadata for an OData association link; makes sure any duplicate of the link's values duplicated in metadata are equal. /// </summary> /// <param name="associationLink">The association link for which to write the metadata.</param> /// <param name="owningType">The <see cref="IEdmEntityType"/> instance the association link is defined on.</param> /// <param name="duplicatePropertyNamesChecker">The checker instance for duplicate property names.</param> /// <param name="projectedProperties">Set of projected properties, or null if all properties should be written.</param> internal void WriteAssociationLink( ODataAssociationLink associationLink, IEdmEntityType owningType, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, ProjectedPropertiesAnnotation projectedProperties) { DebugUtils.CheckNoExternalCallers(); ValidationUtils.ValidateAssociationLinkNotNull(associationLink); string associationLinkName = associationLink.Name; if (projectedProperties.ShouldSkipProperty(associationLinkName)) { return; } this.ValidateAssociationLink(associationLink, owningType); duplicatePropertyNamesChecker.CheckForDuplicateAssociationLinkNames(associationLink); AtomLinkMetadata linkMetadata = associationLink.GetAnnotation <AtomLinkMetadata>(); string linkRelation = AtomUtils.ComputeODataAssociationLinkRelation(associationLink); AtomLinkMetadata mergedLinkMetadata = ODataAtomWriterMetadataUtils.MergeLinkMetadata(linkMetadata, linkRelation, associationLink.Url, associationLinkName, MimeConstants.MimeApplicationXml); this.atomEntryMetadataSerializer.WriteAtomLink(mergedLinkMetadata, null /* etag*/); }
public static AtomLinkMetadata Atom(this ODataAssociationLink associationLink) { ExceptionUtils.CheckArgumentNotNull <ODataAssociationLink>(associationLink, "associationLink"); AtomLinkMetadata annotation = associationLink.GetAnnotation <AtomLinkMetadata>(); if (annotation == null) { annotation = new AtomLinkMetadata(); associationLink.SetAnnotation <AtomLinkMetadata>(annotation); } return(annotation); }
internal void WriteAssociationLink(ODataAssociationLink associationLink, IEdmEntityType owningType, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, ProjectedPropertiesAnnotation projectedProperties) { ValidationUtils.ValidateAssociationLinkNotNull(associationLink); if (!projectedProperties.ShouldSkipProperty(associationLink.Name)) { base.ValidateAssociationLink(associationLink, owningType); duplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink); AtomLinkMetadata annotation = associationLink.GetAnnotation <AtomLinkMetadata>(); string relation = AtomUtils.ComputeODataAssociationLinkRelation(associationLink); AtomLinkMetadata linkMetadata = ODataAtomWriterMetadataUtils.MergeLinkMetadata(annotation, relation, associationLink.Url, associationLink.Name, "application/xml"); this.atomEntryMetadataSerializer.WriteAtomLink(linkMetadata, null); } }
/// <summary> /// Extension method to get the <see cref="AtomLinkMetadata"/> for an association link. /// </summary> /// <param name="associationLink">The association link to get the annotation from.</param> /// <returns>An <see cref="AtomLinkMetadata" /> instance or null if no annotation of that type exists.</returns> public static AtomLinkMetadata Atom(this ODataAssociationLink associationLink) { ExceptionUtils.CheckArgumentNotNull(associationLink, "associationLink"); AtomLinkMetadata linkMetadata = associationLink.GetAnnotation <AtomLinkMetadata>(); if (linkMetadata == null) { linkMetadata = new AtomLinkMetadata(); associationLink.SetAnnotation(linkMetadata); } return(linkMetadata); }
/// <summary> /// Write the metadata for an OData association link; makes sure any duplicate of the link's values duplicated in metadata are equal. /// </summary> /// <param name="associationLink">The association link for which to write the metadata.</param> /// <param name="owningType">The <see cref="IEdmEntityType"/> instance the association link is defined on.</param> /// <param name="duplicatePropertyNamesChecker">The checker instance for duplicate property names.</param> /// <param name="projectedProperties">Set of projected properties, or null if all properties should be written.</param> internal void WriteAssociationLink( ODataAssociationLink associationLink, IEdmEntityType owningType, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, ProjectedPropertiesAnnotation projectedProperties) { DebugUtils.CheckNoExternalCallers(); ValidationUtils.ValidateAssociationLinkNotNull(associationLink); if (projectedProperties.ShouldSkipProperty(associationLink.Name)) { return; } this.ValidateAssociationLink(associationLink, owningType); duplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink); AtomLinkMetadata linkMetadata = associationLink.GetAnnotation<AtomLinkMetadata>(); string linkRelation = AtomUtils.ComputeODataAssociationLinkRelation(associationLink); AtomLinkMetadata mergedLinkMetadata = ODataAtomWriterMetadataUtils.MergeLinkMetadata(linkMetadata, linkRelation, associationLink.Url, associationLink.Name, MimeConstants.MimeApplicationXml); this.atomEntryMetadataSerializer.WriteAtomLink(mergedLinkMetadata, null /* etag*/); }