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;
 }
        /// <summary>
        /// Read the property metadata for the properties of an entry being read.
        /// </summary>
        /// <param name="entryState">The entry state for the current reader.</param>
        /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
        /// <remarks>
        /// Pre-Condition:  first node of the 'properties' property's value (we will throw if this is not a start object node)
        /// Post-Condition: JsonNodeType.Property:      the next metadata property
        ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
        ///                 
        /// This method will not validate anything against the model because it will read the type name and thus it can't rely
        /// on knowing the actual type of the entry being read.
        /// </remarks>
        private void ReadPropertiesMetadataProperty(
            IODataJsonReaderEntryState entryState,
            ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
        {
            Debug.Assert(entryState != null, "entryState != null");

            if (!this.ReadingResponse || this.MessageReaderSettings.MaxProtocolVersion < ODataVersion.V3)
            {
                this.JsonReader.SkipValue();
                return;
            }

            ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
                ref metadataPropertiesFoundBitField,
                ODataJsonReaderUtils.MetadataPropertyBitMask.Properties,
                JsonConstants.ODataMetadataPropertiesName);

            this.JsonReader.AssertBuffering();

            // make sure the 'properties' property value is an object
            if (this.JsonReader.NodeType != JsonNodeType.StartObject)
            {
                throw new ODataException(o.Strings.ODataJsonEntryAndFeedDeserializer_PropertyInEntryMustHaveObjectValue(JsonConstants.ODataMetadataPropertiesName, this.JsonReader.NodeType));
            }

            // read over the start-object node of the metadata object for 'properties'
            this.JsonReader.ReadStartObject();

            while (this.JsonReader.NodeType == JsonNodeType.Property)
            {
                string propertyName = this.JsonReader.ReadPropertyName();

                ValidationUtils.ValidateAssociationLinkName(propertyName);
                ReaderValidationUtils.ValidateNavigationPropertyDefined(propertyName, entryState.EntityType, this.MessageReaderSettings);

                // read the start-object node of the metadata for the current propertyName
                this.JsonReader.ReadStartObject();

                while (this.JsonReader.NodeType == JsonNodeType.Property)
                {
                    string innerPropertyName = this.JsonReader.ReadPropertyName();

                    // ignore all properties we don't understand
                    if (string.CompareOrdinal(innerPropertyName, JsonConstants.ODataMetadataPropertiesAssociationUriName) == 0)
                    {
                        string associationUrlString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataPropertiesAssociationUriName);
                        ODataJsonReaderUtils.ValidateMetadataStringProperty(associationUrlString, JsonConstants.ODataMetadataPropertiesAssociationUriName);
                        ODataAssociationLink associationLink = new ODataAssociationLink
                        {
                            Name = propertyName,
                            Url = this.ProcessUriFromPayload(associationUrlString)
                        };

                        ValidationUtils.ValidateAssociationLink(associationLink);
                        entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink);
                        ReaderUtils.AddAssociationLinkToEntry(entryState.Entry, associationLink);
                    }
                    else
                    {
                        // skip over all unknown properties and read the next property or 
                        // the end of the metadata for the current propertyName
                        this.JsonReader.SkipValue();
                    }
                }

                // read the end-object node of the metadata for the current propertyName
                this.JsonReader.ReadEndObject();
            }

            // read over the end-object node of the metadata object for 'properties'
            this.JsonReader.ReadEndObject();

            this.JsonReader.AssertBuffering();
            Debug.Assert(
                this.JsonReader.NodeType == JsonNodeType.Property || this.JsonReader.NodeType == JsonNodeType.EndObject,
                "Post-Condition: expected JsonNodeType.Property or JsonNodeType.EndObject");
        }
        /// <summary>
        /// Reads the functions property in metadata value.
        /// </summary>
        /// <param name="entry">The entry being read.</param>
        /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
        /// <remarks>
        /// Pre-Condition:  first node of the 'functions' property's value
        /// Post-Condition: JsonNodeType.Property:      the next metadata property
        ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
        /// </remarks>
        private void ReadFunctionsMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
        {
            Debug.Assert(entry != null, "entry != null");

            if (this.MessageReaderSettings.MaxProtocolVersion >= ODataVersion.V3 && this.ReadingResponse)
            {
                ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
                    ref metadataPropertiesFoundBitField,
                    ODataJsonReaderUtils.MetadataPropertyBitMask.Functions,
                    JsonConstants.ODataFunctionsMetadataName);
                this.ReadOperationsMetadata(entry, false /* isActions */);
            }
            else
            {
                this.JsonReader.SkipValue();
            }
        }
 /// <summary>
 /// Reads the media_etag property in metadata value.
 /// </summary>
 /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
 /// <param name="mediaResource">The media resource value for the entry.</param>
 /// <remarks>
 /// Pre-Condition:  first node of the 'media_etag' property's value
 /// Post-Condition: JsonNodeType.Property:      the next metadata property
 ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
 /// </remarks>
 private void ReadMediaETagMetadataProperty(
     ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField,
     ref ODataStreamReferenceValue mediaResource)
 {
     if (this.UseServerFormatBehavior)
     {
         this.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
             ref metadataPropertiesFoundBitField,
             ODataJsonReaderUtils.MetadataPropertyBitMask.MediaETag,
             JsonConstants.ODataMetadataMediaETagName);
         ODataJsonReaderUtils.EnsureInstance(ref mediaResource);
         string mediaETag = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataMediaETagName);
         ODataJsonReaderUtils.ValidateMetadataStringProperty(mediaETag, JsonConstants.ODataMetadataMediaETagName);
         mediaResource.ETag = mediaETag;
     }
 }
 /// <summary>
 /// Reads the edit_media property in metadata value.
 /// </summary>
 /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
 /// <param name="mediaResource">The media resource value for the entry.</param>
 /// <remarks>
 /// Pre-Condition:  first node of the 'edit_media' property's value
 /// Post-Condition: JsonNodeType.Property:      the next metadata property
 ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
 /// </remarks>
 private void ReadEditMediaMetadataProperty(
     ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField,
     ref ODataStreamReferenceValue mediaResource)
 {
     if (this.UseServerFormatBehavior)
     {
         this.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
             ref metadataPropertiesFoundBitField,
             ODataJsonReaderUtils.MetadataPropertyBitMask.EditMedia,
             JsonConstants.ODataMetadataEditMediaName);
         ODataJsonReaderUtils.EnsureInstance(ref mediaResource);
         string mediaEditLinkString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataEditMediaName);
         ODataJsonReaderUtils.ValidateMetadataStringProperty(mediaEditLinkString, JsonConstants.ODataMetadataEditMediaName);
         mediaResource.EditLink = this.ProcessUriFromPayload(mediaEditLinkString);
     }
 }
        /// <summary>
        /// Reads the etag property in metadata value.
        /// </summary>
        /// <param name="entry">The entry being read.</param>
        /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
        /// <remarks>
        /// Pre-Condition:  first node of the 'etag' property's value
        /// Post-Condition: JsonNodeType.Property:      the next metadata property
        ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
        /// </remarks>
        private void ReadETagMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
        {
            Debug.Assert(entry != null, "entry != null");

            if (this.UseServerFormatBehavior)
            {
                this.JsonReader.SkipValue();
            }
            else
            {
                ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
                    ref metadataPropertiesFoundBitField,
                    ODataJsonReaderUtils.MetadataPropertyBitMask.ETag,
                    JsonConstants.ODataMetadataETagName);
                string etagString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataETagName);
                ODataJsonReaderUtils.ValidateMetadataStringProperty(etagString, JsonConstants.ODataMetadataETagName);
                entry.ETag = etagString;
            }
        }
        /// <summary>
        /// Reads the uri property in metadata value.
        /// </summary>
        /// <param name="entry">The entry being read.</param>
        /// <param name="metadataPropertiesFoundBitField">The bit fields with all the properties found in metadata value so far.</param>
        /// <remarks>
        /// Pre-Condition:  first node of the 'uri' property's value
        /// Post-Condition: JsonNodeType.Property:      the next metadata property
        ///                 JsonNodeType.EndObject:     the end-object node of the metadata object
        /// </remarks>
        private void ReadUriMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
        {
            Debug.Assert(entry != null, "entry != null");

            ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(
                ref metadataPropertiesFoundBitField,
                ODataJsonReaderUtils.MetadataPropertyBitMask.Uri,
                JsonConstants.ODataMetadataUriName);
            string editLinkString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataUriName);

            if (editLinkString != null)
            {
                ODataJsonReaderUtils.ValidateMetadataStringProperty(editLinkString, JsonConstants.ODataMetadataUriName);
                entry.EditLink = this.ProcessUriFromPayload(editLinkString);
            }
        }
 private void ReadPropertiesMetadataProperty(IODataJsonReaderEntryState entryState, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
 {
     if (!base.ReadingResponse || (base.MessageReaderSettings.MaxProtocolVersion < ODataVersion.V3))
     {
         base.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.Properties, "properties");
         if (base.JsonReader.NodeType != JsonNodeType.StartObject)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_PropertyInEntryMustHaveObjectValue("properties", base.JsonReader.NodeType));
         }
         base.JsonReader.ReadStartObject();
         while (base.JsonReader.NodeType == JsonNodeType.Property)
         {
             string associationLinkName = base.JsonReader.ReadPropertyName();
             ValidationUtils.ValidateAssociationLinkName(associationLinkName);
             ReaderValidationUtils.ValidateNavigationPropertyDefined(associationLinkName, entryState.EntityType, base.MessageReaderSettings);
             base.JsonReader.ReadStartObject();
             while (base.JsonReader.NodeType == JsonNodeType.Property)
             {
                 if (string.CompareOrdinal(base.JsonReader.ReadPropertyName(), "associationuri") == 0)
                 {
                     string propertyValue = base.JsonReader.ReadStringValue("associationuri");
                     ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "associationuri");
                     ODataAssociationLink associationLink = new ODataAssociationLink {
                         Name = associationLinkName,
                         Url = base.ProcessUriFromPayload(propertyValue)
                     };
                     ValidationUtils.ValidateAssociationLink(associationLink);
                     entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(associationLink);
                     ReaderUtils.AddAssociationLinkToEntry(entryState.Entry, associationLink);
                 }
                 else
                 {
                     base.JsonReader.SkipValue();
                 }
             }
             base.JsonReader.ReadEndObject();
         }
         base.JsonReader.ReadEndObject();
     }
 }
 private void ReadUriMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
 {
     ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.Uri, "uri");
     string propertyValue = base.JsonReader.ReadStringValue("uri");
     if (propertyValue != null)
     {
         ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "uri");
         entry.EditLink = base.ProcessUriFromPayload(propertyValue);
     }
 }
 private void ReadMediaSourceMetadataProperty(ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField, ref ODataStreamReferenceValue mediaResource)
 {
     if (base.UseServerFormatBehavior)
     {
         base.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.MediaUri, "media_src");
         ODataJsonReaderUtils.EnsureInstance<ODataStreamReferenceValue>(ref mediaResource);
         string propertyValue = base.JsonReader.ReadStringValue("media_src");
         ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "media_src");
         mediaResource.ReadLink = base.ProcessUriFromPayload(propertyValue);
     }
 }
 private void ReadIdMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
 {
     if (base.UseServerFormatBehavior)
     {
         base.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.Id, "id");
         string propertyValue = base.JsonReader.ReadStringValue("id");
         ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "id");
         entry.Id = propertyValue;
     }
 }
 private void ReadFunctionsMetadataProperty(ODataEntry entry, ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField)
 {
     if ((base.MessageReaderSettings.MaxProtocolVersion >= ODataVersion.V3) && base.ReadingResponse)
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.Functions, "functions");
         this.ReadOperationsMetadata(entry, false);
     }
     else
     {
         base.JsonReader.SkipValue();
     }
 }
 private void ReadContentTypeMetadataProperty(ref ODataJsonReaderUtils.MetadataPropertyBitMask metadataPropertiesFoundBitField, ref ODataStreamReferenceValue mediaResource)
 {
     if (base.UseServerFormatBehavior)
     {
         base.JsonReader.SkipValue();
     }
     else
     {
         ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref metadataPropertiesFoundBitField, ODataJsonReaderUtils.MetadataPropertyBitMask.ContentType, "content_type");
         ODataJsonReaderUtils.EnsureInstance<ODataStreamReferenceValue>(ref mediaResource);
         string propertyValue = base.JsonReader.ReadStringValue("content_type");
         ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "content_type");
         mediaResource.ContentType = propertyValue;
     }
 }
        /// <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;
        }