Example #1
0
        /// <summary>
        /// Reads the properties of an entity reference link.
        /// </summary>
        /// <param name="entityReferenceLinks">The <see cref="ODataEntityReferenceLinks"/> instance to set the read property values on.</param>
        /// <param name="propertiesFoundBitField">The bit field with all the properties already read.</param>
        /// <returns>true if the method found the 'results' property; otherwise false.</returns>
        private bool ReadEntityReferenceLinkProperties(
            ODataEntityReferenceLinks entityReferenceLinks,
            ref ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask propertiesFoundBitField)
        {
            Debug.Assert(entityReferenceLinks != null, "entityReferenceLinks != null");
            this.JsonReader.AssertNotBuffering();

            while (this.JsonReader.NodeType == JsonNodeType.Property)
            {
                string propertyName = this.JsonReader.ReadPropertyName();
                switch (propertyName)
                {
                case JsonConstants.ODataResultsName:
                    ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.Results,
                        JsonConstants.ODataResultsName);
                    this.JsonReader.AssertNotBuffering();
                    return(true);

                case JsonConstants.ODataCountName:
                    ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.Count,
                        JsonConstants.ODataCountName);
                    object countValue = this.JsonReader.ReadPrimitiveValue();
                    long?  count      = (long?)ODataJsonReaderUtils.ConvertValue(countValue, EdmCoreModel.Instance.GetInt64(true), this.MessageReaderSettings, this.Version, /*validateNullValue*/ true);
                    ODataJsonReaderUtils.ValidateCountPropertyInEntityReferenceLinks(count);
                    entityReferenceLinks.Count = count;
                    break;

                case JsonConstants.ODataNextLinkName:
                    ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.NextPageLink,
                        JsonConstants.ODataNextLinkName);
                    string nextLinkString = this.JsonReader.ReadStringValue(JsonConstants.ODataNextLinkName);
                    ODataJsonReaderUtils.ValidateEntityReferenceLinksStringProperty(nextLinkString, JsonConstants.ODataNextLinkName);
                    entityReferenceLinks.NextPageLink = this.ProcessUriFromPayload(nextLinkString);
                    break;

                default:
                    // Skip all unrecognized properties
                    this.JsonReader.SkipValue();
                    break;
                }
            }

            this.JsonReader.AssertNotBuffering();
            return(false);
        }
Example #2
0
        private object ReadPrimitiveValueImplementation(IEdmPrimitiveTypeReference expectedValueTypeReference, bool validateNullValue)
        {
            if ((expectedValueTypeReference != null) && expectedValueTypeReference.IsSpatial())
            {
                return(this.ReadSpatialValue(expectedValueTypeReference, validateNullValue));
            }
            object obj2 = base.JsonReader.ReadPrimitiveValue();

            if ((expectedValueTypeReference != null) && !base.MessageReaderSettings.DisablePrimitiveTypeConversion)
            {
                obj2 = ODataJsonReaderUtils.ConvertValue(obj2, expectedValueTypeReference, base.MessageReaderSettings, base.Version, validateNullValue);
            }
            return(obj2);
        }
Example #3
0
        private bool ReadEntityReferenceLinkProperties(ODataEntityReferenceLinks entityReferenceLinks, ref ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask propertiesFoundBitField)
        {
            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                string str3 = base.JsonReader.ReadPropertyName();
                if (str3 == null)
                {
                    goto Label_00D9;
                }
                if (!(str3 == "results"))
                {
                    if (str3 == "__count")
                    {
                        goto Label_0057;
                    }
                    if (str3 == "__next")
                    {
                        goto Label_00A2;
                    }
                    goto Label_00D9;
                }
                ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.Results, "results");
                return(true);

Label_0057:
                ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.Count, "__count");
                long?propertyValue = (long?)ODataJsonReaderUtils.ConvertValue(base.JsonReader.ReadPrimitiveValue(), EdmCoreModel.Instance.GetInt64(true), base.MessageReaderSettings, base.Version, true);
                ODataJsonReaderUtils.ValidateCountPropertyInEntityReferenceLinks(propertyValue);
                entityReferenceLinks.Count = propertyValue;
                continue;
Label_00A2:
                ODataJsonReaderUtils.VerifyEntityReferenceLinksWrapperPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.EntityReferenceLinksWrapperPropertyBitMask.NextPageLink, "__next");
                string str2 = base.JsonReader.ReadStringValue("__next");
                ODataJsonReaderUtils.ValidateEntityReferenceLinksStringProperty(str2, "__next");
                entityReferenceLinks.NextPageLink = base.ProcessUriFromPayload(str2);
                continue;
Label_00D9:
                base.JsonReader.SkipValue();
            }
            return(false);
        }
Example #4
0
        private void ReadFeedProperty(ODataFeed feed, string propertyName, bool isExpandedLinkContent)
        {
            switch (ODataJsonReaderUtils.DetermineFeedPropertyKind(propertyName))
            {
            case ODataJsonReaderUtils.FeedPropertyKind.Unsupported:
                base.JsonReader.SkipValue();
                return;

            case ODataJsonReaderUtils.FeedPropertyKind.Count:
            {
                if ((!base.ReadingResponse || (base.Version < ODataVersion.V2)) || isExpandedLinkContent)
                {
                    base.JsonReader.SkipValue();
                    return;
                }
                string propertyValue = base.JsonReader.ReadStringValue("__count");
                ODataJsonReaderUtils.ValidateFeedProperty(propertyValue, "__count");
                long num = (long)ODataJsonReaderUtils.ConvertValue(propertyValue, EdmCoreModel.Instance.GetInt64(false), base.MessageReaderSettings, base.Version, true);
                feed.Count = new long?(num);
                return;
            }

            case ODataJsonReaderUtils.FeedPropertyKind.Results:
                throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleFeedResultsPropertiesFound);

            case ODataJsonReaderUtils.FeedPropertyKind.NextPageLink:
            {
                if (!base.ReadingResponse || (base.Version < ODataVersion.V2))
                {
                    base.JsonReader.SkipValue();
                    return;
                }
                string str2 = base.JsonReader.ReadStringValue("__next");
                ODataJsonReaderUtils.ValidateFeedProperty(str2, "__next");
                feed.NextPageLink = base.ProcessUriFromPayload(str2);
                return;
            }
            }
            throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataJsonEntryAndFeedDeserializer_ReadFeedProperty));
        }