Exemplo n.º 1
0
        /// <summary>
        /// Creates a nested resource info for a projected nested resource info that is missing from the payload.
        /// </summary>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <returns>The nested resource info created.</returns>
        internal static ODataJsonLightReaderNestedResourceInfo CreateProjectedNestedResourceInfo(IEdmNavigationProperty navigationProperty)
        {
            Debug.Assert(navigationProperty != null, "navigationProperty != null");

            ODataNestedResourceInfo nestedResourceInfo = new ODataNestedResourceInfo {
                Name = navigationProperty.Name, IsCollection = navigationProperty.Type.IsCollection()
            };
            ODataJsonLightReaderNestedResourceInfo readerNestedResourceInfo = new ODataJsonLightReaderNestedResourceInfo(nestedResourceInfo, navigationProperty, /*isExpanded*/ false);

            return(readerNestedResourceInfo);
        }
Exemplo n.º 2
0
        internal static ODataJsonLightReaderNestedResourceInfo CreateResourceReaderNestedResourceInfo(
            ODataNestedResourceInfo nestedResourceInfo,
            IEdmStructuredType nestedResourceType)
        {
            Debug.Assert(nestedResourceInfo != null, "nestedResourceInfo != null");
            Debug.Assert(nestedResourceInfo.IsCollection == false, "Resource can only be reported for a singleton nested resource info.");

            ODataJsonLightReaderNestedResourceInfo readerNestedResourceInfo = new ODataJsonLightReaderNestedResourceInfo(nestedResourceInfo, nestedResourceType, /*isExpanded*/ true);

            return(readerNestedResourceInfo);
        }
Exemplo n.º 3
0
        internal static ODataJsonLightReaderNestedResourceInfo CreateResourceSetReaderNestedResourceInfo(
            ODataNestedResourceInfo nestedResourceInfo,
            IEdmStructuredType nestedResourceType,
            ODataResourceSet resourceSet)
        {
            Debug.Assert(nestedResourceInfo != null, "nestedResourceInfo != null");
            Debug.Assert(nestedResourceInfo.IsCollection == true, "Resource sets can only be reported for collection nested resource info.");
            Debug.Assert(resourceSet != null, "resourceSet != null");

            ODataJsonLightReaderNestedResourceInfo readerNestedResourceInfo = new ODataJsonLightReaderNestedResourceInfo(nestedResourceInfo, nestedResourceType, /*isExpanded*/ true);

            readerNestedResourceInfo.resourceSet = resourceSet;
            return(readerNestedResourceInfo);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a nested resource info for a collection of entity reference links.
        /// </summary>
        /// <param name="nestedResourceInfo">The nested resource info to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <param name="entityReferenceLinks">The entity reference links for the nested resource info to report.</param>
        /// <param name="isExpanded">true if the nested resource info is expanded.</param>
        /// <returns>The nested resource info created.</returns>
        internal static ODataJsonLightReaderNestedResourceInfo CreateCollectionEntityReferenceLinksInfo(
            ODataNestedResourceInfo nestedResourceInfo,
            IEdmNavigationProperty navigationProperty,
            LinkedList <ODataEntityReferenceLink> entityReferenceLinks,
            bool isExpanded)
        {
            Debug.Assert(nestedResourceInfo != null, "nestedResourceInfo != null");
            Debug.Assert(nestedResourceInfo.IsCollection == true, "Collection entity reference can only be reported for a collection navigation links.");
            Debug.Assert(navigationProperty != null, "navigationProperty != null");
            Debug.Assert(entityReferenceLinks == null || entityReferenceLinks.Count > 0, "entityReferenceLinks == null || entityReferenceLinks.Count > 0");

            ODataJsonLightReaderNestedResourceInfo readerNestedResourceInfo = new ODataJsonLightReaderNestedResourceInfo(nestedResourceInfo, navigationProperty, isExpanded);

            readerNestedResourceInfo.entityReferenceLinks = entityReferenceLinks;
            return(readerNestedResourceInfo);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a nested resource info for a singleton entity reference link.
        /// </summary>
        /// <param name="nestedResourceInfo">The nested resource info to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <param name="entityReferenceLink">The entity reference link for the nested resource info to report.</param>
        /// <param name="isExpanded">true if the nested resource info is expanded.</param>
        /// <returns>The nested resource info created.</returns>
        internal static ODataJsonLightReaderNestedResourceInfo CreateSingletonEntityReferenceLinkInfo(
            ODataNestedResourceInfo nestedResourceInfo,
            IEdmNavigationProperty navigationProperty,
            ODataEntityReferenceLink entityReferenceLink,
            bool isExpanded)
        {
            Debug.Assert(nestedResourceInfo != null, "nestedResourceInfo != null");
            Debug.Assert(nestedResourceInfo.IsCollection == false, "Singleton entity reference can only be reported for a singleton navigation links.");
            Debug.Assert(navigationProperty != null, "navigationProperty != null");

            ODataJsonLightReaderNestedResourceInfo readerNestedResourceInfo = new ODataJsonLightReaderNestedResourceInfo(nestedResourceInfo, navigationProperty, isExpanded);

            if (entityReferenceLink != null)
            {
                readerNestedResourceInfo.entityReferenceLinks = new LinkedList <ODataEntityReferenceLink>();
                readerNestedResourceInfo.entityReferenceLinks.AddFirst(entityReferenceLink);
            }

            return(readerNestedResourceInfo);
        }