Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #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);
            }
        }
Exemple #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();
     }
 }
Exemple #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;
     }
 }
Exemple #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);
     }
 }
Exemple #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;
     }
 }
Exemple #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();
     }
 }