Esempio n. 1
0
        internal ODataEntityReferenceLink ReadEntityReferenceLink()
        {
            base.JsonReader.ReadStartObject();
            base.JsonReader.ReadPropertyName();
            base.JsonReader.ReadStartObject();
            ODataEntityReferenceLink link = new ODataEntityReferenceLink();

            ODataJsonReaderUtils.MetadataPropertyBitMask none = ODataJsonReaderUtils.MetadataPropertyBitMask.None;
            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                string strB = base.JsonReader.ReadPropertyName();
                if (string.CompareOrdinal("uri", strB) == 0)
                {
                    ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref none, ODataJsonReaderUtils.MetadataPropertyBitMask.Uri, "uri");
                    string propertyValue = base.JsonReader.ReadStringValue("uri");
                    ODataJsonReaderUtils.ValidateMetadataStringProperty(propertyValue, "uri");
                    link.Url = base.ProcessUriFromPayload(propertyValue);
                }
                else
                {
                    base.JsonReader.SkipValue();
                }
            }
            base.JsonReader.ReadEndObject();
            base.JsonReader.ReadEndObject();
            return(link);
        }
Esempio n. 2
0
        internal string ReadTypeNameFromMetadataPropertyValue()
        {
            string str = null;

            if (base.JsonReader.NodeType != JsonNodeType.StartObject)
            {
                throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonPropertyAndValueDeserializer_MetadataPropertyMustHaveObjectValue(base.JsonReader.NodeType));
            }
            base.JsonReader.ReadStartObject();
            ODataJsonReaderUtils.MetadataPropertyBitMask none = ODataJsonReaderUtils.MetadataPropertyBitMask.None;
            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                string strB = base.JsonReader.ReadPropertyName();
                if (string.CompareOrdinal("type", strB) == 0)
                {
                    ODataJsonReaderUtils.VerifyMetadataPropertyNotFound(ref none, ODataJsonReaderUtils.MetadataPropertyBitMask.Type, "type");
                    object obj2 = base.JsonReader.ReadPrimitiveValue();
                    str = obj2 as string;
                    if (str == null)
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonPropertyAndValueDeserializer_InvalidTypeName(obj2));
                    }
                }
                else
                {
                    base.JsonReader.SkipValue();
                }
            }
            base.JsonReader.ReadEndObject();
            return(str);
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 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();
     }
 }
Esempio n. 5
0
 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;
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
 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;
     }
 }
Esempio n. 8
0
 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();
     }
 }
Esempio n. 9
0
        internal void ReadEntryMetadataPropertyValue(IODataJsonReaderEntryState entryState)
        {
            ODataEntry entry = entryState.Entry;

            base.JsonReader.ReadStartObject();
            ODataStreamReferenceValue mediaResource = null;

            ODataJsonReaderUtils.MetadataPropertyBitMask none = ODataJsonReaderUtils.MetadataPropertyBitMask.None;
            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                switch (base.JsonReader.ReadPropertyName())
                {
                case "uri":
                {
                    this.ReadUriMetadataProperty(entry, ref none);
                    continue;
                }

                case "id":
                {
                    this.ReadIdMetadataProperty(entry, ref none);
                    continue;
                }

                case "etag":
                {
                    this.ReadETagMetadataProperty(entry, ref none);
                    continue;
                }

                case "type":
                {
                    base.JsonReader.SkipValue();
                    continue;
                }

                case "media_src":
                {
                    this.ReadMediaSourceMetadataProperty(ref none, ref mediaResource);
                    continue;
                }

                case "edit_media":
                {
                    this.ReadEditMediaMetadataProperty(ref none, ref mediaResource);
                    continue;
                }

                case "content_type":
                {
                    this.ReadContentTypeMetadataProperty(ref none, ref mediaResource);
                    continue;
                }

                case "media_etag":
                {
                    this.ReadMediaETagMetadataProperty(ref none, ref mediaResource);
                    continue;
                }

                case "actions":
                {
                    this.ReadActionsMetadataProperty(entry, ref none);
                    continue;
                }

                case "functions":
                {
                    this.ReadFunctionsMetadataProperty(entry, ref none);
                    continue;
                }

                case "properties":
                {
                    this.ReadPropertiesMetadataProperty(entryState, ref none);
                    continue;
                }
                }
                base.JsonReader.SkipValue();
            }
            entry.MediaResource = mediaResource;
        }