/// <summary>
        /// Converts the ComplexMultiValueProperty into a NavigationPropertyInstance if the base returned an EntitySetInstance
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public override ODataPayloadElement Visit(ComplexMultiValueProperty payloadElement)
        {
            ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement");
            var replacedCollection = this.Recurse(payloadElement.Value);

            if (!this.ShouldReplace(payloadElement.Value, replacedCollection))
            {
                return(payloadElement);
            }

            var complexmulti = replacedCollection as ComplexMultiValue;

            if (complexmulti != null)
            {
                return(payloadElement.ReplaceWith(new ComplexMultiValueProperty(payloadElement.Name, complexmulti)));
            }

            var entityset = replacedCollection as EntitySetInstance;

            ExceptionUtilities.CheckObjectNotNull(entityset, "Replaced collection should be either ComplexMultiValue or EntitySetInstance");
            return(payloadElement.ReplaceWith(new NavigationPropertyInstance(payloadElement.Name, replacedCollection)));
        }
示例#2
0
        /// <summary>
        /// Visits the children of the given payload element and replaces it with a copy if any child changes
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public virtual ODataPayloadElement Visit(ComplexMultiValueProperty payloadElement)
        {
            ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement");
            var replacedCollection = this.Recurse(payloadElement.Value) as ComplexMultiValue;

            ExceptionUtilities.CheckObjectNotNull(replacedCollection, "Replaced complex collection was null or wrong type");

            if (!this.ShouldReplace(payloadElement.Value, replacedCollection))
            {
                return(payloadElement);
            }

            return(payloadElement.ReplaceWith(new ComplexMultiValueProperty(payloadElement.Name, replacedCollection)));
        }
        /// <summary>
        /// Normalizes complex multi-value properties, potentially replacing them with complex collections if the metadata indicates the payload is from a service operation
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public override ODataPayloadElement Visit(ComplexMultiValueProperty payloadElement)
        {
            var replaced = base.Visit(payloadElement);
            if (replaced.ElementType == ODataPayloadElementType.ComplexMultiValueProperty)
            {
                payloadElement = (ComplexMultiValueProperty)replaced;
                if (this.ShouldReplaceWithCollection(payloadElement, payloadElement.Value.IsNull, payloadElement.Value.FullTypeName))
                {
                    return payloadElement
                        .ReplaceWith(new ComplexInstanceCollection(payloadElement.Value.ToArray()))
                        .WithAnnotations(new CollectionNameAnnotation() { Name = payloadElement.Name });
                }
            }

            return replaced;
        }
示例#4
0
        /// <summary>
        /// Normalizes complex multi-value properties, potentially replacing them with complex collections if the metadata indicates the payload is from a service operation
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public override ODataPayloadElement Visit(ComplexMultiValueProperty payloadElement)
        {
            var replaced = base.Visit(payloadElement);

            if (replaced.ElementType == ODataPayloadElementType.ComplexMultiValueProperty)
            {
                payloadElement = (ComplexMultiValueProperty)replaced;
                if (this.ShouldReplaceWithCollection(payloadElement, payloadElement.Value.IsNull, payloadElement.Value.FullTypeName))
                {
                    return(payloadElement
                           .ReplaceWith(new ComplexInstanceCollection(payloadElement.Value.ToArray()))
                           .WithAnnotations(new CollectionNameAnnotation()
                    {
                        Name = payloadElement.Name
                    }));
                }
            }

            return(replaced);
        }
        /// <summary>
        /// Converts the ComplexMultiValueProperty into a NavigationPropertyInstance if the base returned an EntitySetInstance
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public override ODataPayloadElement Visit(ComplexMultiValueProperty payloadElement)
        {
            ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement");
            var replacedCollection = this.Recurse(payloadElement.Value);
            if (!this.ShouldReplace(payloadElement.Value, replacedCollection))
            {
                return payloadElement;
            }

            var complexmulti = replacedCollection as ComplexMultiValue;
            if (complexmulti != null)
            {
                return payloadElement.ReplaceWith(new ComplexMultiValueProperty(payloadElement.Name, complexmulti));
            }

            var entityset = replacedCollection as EntitySetInstance;
            ExceptionUtilities.CheckObjectNotNull(entityset, "Replaced collection should be either ComplexMultiValue or EntitySetInstance");
            return payloadElement.ReplaceWith(new NavigationPropertyInstance(payloadElement.Name, replacedCollection));
        }