private ODataMediaAnnotations CreateAnnotations(ODataStreamReferenceValue value)
 {
     return value == null ? null : new ODataMediaAnnotations
     {
         ContentType = value.ContentType,
         ReadLink = value.ReadLink,
         EditLink = value.EditLink,
         ETag = value.ETag,
     };
 }
 internal void WriteEntryMediaEditLink(ODataStreamReferenceValue mediaResource)
 {
     Uri editLink = mediaResource.EditLink;
     if (editLink != null)
     {
         AtomStreamReferenceMetadata annotation = mediaResource.GetAnnotation<AtomStreamReferenceMetadata>();
         AtomLinkMetadata metadata = (annotation == null) ? null : annotation.EditLink;
         AtomLinkMetadata linkMetadata = ODataAtomWriterMetadataUtils.MergeLinkMetadata(metadata, "edit-media", editLink, null, null);
         this.atomEntryMetadataSerializer.WriteAtomLink(linkMetadata, mediaResource.ETag);
     }
 }
 internal void WriteStreamReferenceValueContent(ODataStreamReferenceValue streamReferenceValue)
 {
     Uri editLink = streamReferenceValue.EditLink;
     if (editLink != null)
     {
         base.JsonWriter.WriteName("edit_media");
         base.JsonWriter.WriteValue(base.UriToAbsoluteUriString(editLink));
     }
     if (streamReferenceValue.ReadLink != null)
     {
         base.JsonWriter.WriteName("media_src");
         base.JsonWriter.WriteValue(base.UriToAbsoluteUriString(streamReferenceValue.ReadLink));
     }
     if (streamReferenceValue.ContentType != null)
     {
         base.JsonWriter.WriteName("content_type");
         base.JsonWriter.WriteValue(streamReferenceValue.ContentType);
     }
     string eTag = streamReferenceValue.ETag;
     if (eTag != null)
     {
         this.WriteETag("media_etag", eTag);
     }
 }
 private void WriteStreamReferenceValue(ODataStreamReferenceValue streamReferenceValue)
 {
     base.JsonWriter.StartObjectScope();
     base.JsonWriter.WriteName("__mediaresource");
     base.JsonWriter.StartObjectScope();
     this.WriteStreamReferenceValueContent(streamReferenceValue);
     base.JsonWriter.EndObjectScope();
     base.JsonWriter.EndObjectScope();
 }
        /// <summary>
        /// Validates an <see cref="ODataStreamReferenceValue"/> to ensure all required information is specified and valid.
        /// </summary>
        /// <param name="streamReference">The stream reference to validate.</param>
        /// <param name="isDefaultStream">true if <paramref name="streamReference"/> is the default stream for an entity; false if it is a named stream property value.</param>
        internal static void ValidateStreamReferenceValue(ODataStreamReferenceValue streamReference, bool isDefaultStream)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(streamReference != null, "streamReference != null");

            if (streamReference.ContentType != null && streamReference.ContentType.Length == 0)
            {
                throw new ODataException(Strings.WriterValidationUtils_StreamReferenceValueEmptyContentType);
            }

            if (isDefaultStream && streamReference.ReadLink == null && streamReference.ContentType != null)
            {
                throw new ODataException(Strings.WriterValidationUtils_DefaultStreamWithContentTypeWithoutReadLink);
            }

            if (isDefaultStream && streamReference.ReadLink != null && streamReference.ContentType == null)
            {
                throw new ODataException(Strings.WriterValidationUtils_DefaultStreamWithReadLinkWithoutContentType);
            }

            // Default stream can be completely empty (no links or anything)
            // that is used to effectively mark the entry as MLE without providing any MR information.
            // OData clients when creating new MLE/MR might not have the MR information (yet) when sending the first PUT, but they still
            // need to mark the entry as MLE so that properties are written out-of-content. In such scenario the client can just set an empty
            // default stream to mark the entry as MLE.
            // That will cause the ATOM writer to write the properties outside the content without producing any content element.
            if (streamReference.EditLink == null && streamReference.ReadLink == null && !isDefaultStream)
            {
                throw new ODataException(Strings.WriterValidationUtils_StreamReferenceValueMustHaveEditLinkOrReadLink);
            }

            if (streamReference.EditLink == null && streamReference.ETag != null)
            {
                throw new ODataException(Strings.WriterValidationUtils_StreamReferenceValueMustHaveEditLinkToHaveETag);
            }
        }
        /// <summary>
        /// Reads the stream reference metadata from the value of the __mediaresource property.
        /// </summary>
        /// <returns>The value of the stream reference with the metadata properties filled.</returns>
        /// <remarks>
        /// Pre-Condition:  Fails if the current node is not a JsonNodeType.StartObject
        /// Post-Condition: Either a property node or an EndObject node.
        /// </remarks>
        private ODataStreamReferenceValue ReadStreamReferenceValue()
        {
            this.JsonReader.AssertNotBuffering();

            // read the start of the __mediaresource object
            this.JsonReader.ReadStartObject();

            ODataStreamReferenceValue streamReference = new ODataStreamReferenceValue();
            while (this.JsonReader.NodeType == JsonNodeType.Property)
            {
                string propertyName = this.JsonReader.ReadPropertyName();
                switch (propertyName)
                {
                    case JsonConstants.ODataMetadataEditMediaName:      // "edit_media": "url"
                        if (streamReference.EditLink != null)
                        {
                            // we found another edit_media property; this is not allowed
                            throw new ODataException(o.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty(JsonConstants.ODataMetadataEditMediaName));
                        }

                        string editLinkString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataEditMediaName);
                        ODataJsonReaderUtils.ValidateMediaResourceStringProperty(editLinkString, JsonConstants.ODataMetadataEditMediaName);
                        streamReference.EditLink = this.ProcessUriFromPayload(editLinkString);
                        break;

                    case JsonConstants.ODataMetadataMediaUriName:       // "media_src" : "url"
                        if (streamReference.ReadLink != null)
                        {
                            // we found another media_src property; this is not allowed
                            throw new ODataException(o.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty(JsonConstants.ODataMetadataMediaUriName));
                        }

                        string readLinkString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataMediaUriName);
                        ODataJsonReaderUtils.ValidateMediaResourceStringProperty(readLinkString, JsonConstants.ODataMetadataMediaUriName);
                        streamReference.ReadLink = this.ProcessUriFromPayload(readLinkString);
                        break;

                    case JsonConstants.ODataMetadataContentTypeName:    // "content_type" : "type"
                        if (streamReference.ContentType != null)
                        {
                            // we found another content_type property; this is not allowed
                            throw new ODataException(o.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty(JsonConstants.ODataMetadataContentTypeName));
                        }

                        string contentTypeString = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataContentTypeName);
                        ODataJsonReaderUtils.ValidateMediaResourceStringProperty(contentTypeString, JsonConstants.ODataMetadataContentTypeName);
                        streamReference.ContentType = contentTypeString;
                        break;

                    case JsonConstants.ODataMetadataMediaETagName:      // "media_etag" : "etag"
                        if (streamReference.ETag != null)
                        {
                            // we found another content_type property; this is not allowed
                            throw new ODataException(o.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty(JsonConstants.ODataMetadataMediaETagName));
                        }

                        string etag = this.JsonReader.ReadStringValue(JsonConstants.ODataMetadataMediaETagName);
                        ODataJsonReaderUtils.ValidateMediaResourceStringProperty(etag, JsonConstants.ODataMetadataMediaETagName);
                        streamReference.ETag = etag;
                        break;

                    default:
                        // ignore all properties that we don't recognize
                        this.JsonReader.SkipValue();
                        break;
                }
            }

            Debug.Assert(this.JsonReader.NodeType == JsonNodeType.EndObject, "Only Property or EndObject can appear at the object scope.");
            this.JsonReader.ReadEndObject();

            this.JsonReader.AssertNotBuffering();
            Debug.Assert(
                this.JsonReader.NodeType == JsonNodeType.Property || this.JsonReader.NodeType == JsonNodeType.EndObject,
                "Post-Condition: JsonNodeType.Property or JsonNodeType.EndObject");

            return streamReference;
        }
 /// <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;
     }
 }
示例#8
0
        private ODataStreamReferenceValue GetNamedStreamPropertyValue(object element, ResourceProperty namedStreamProperty, Uri relativeUri)
        {
            string str;
            Uri uri;
            string str2;
            base.Service.StreamProvider.GetStreamDescription(element, namedStreamProperty, base.Service.OperationContext, out str, out uri, out str2);
            ODataStreamReferenceValue value2 = new ODataStreamReferenceValue {
                ContentType = str2,
				EditLink = RequestUriProcessor.AppendUnescapedSegment(relativeUri, namedStreamProperty.Name)
            };
            if (!string.IsNullOrEmpty(str))
            {
                value2.ETag = str;
            }
            value2.ReadLink = uri;
            return value2;
        }
示例#9
0
 internal static void ValidateStreamReferenceValue(ODataStreamReferenceValue streamReference, bool isDefaultStream)
 {
     if ((streamReference.ContentType != null) && (streamReference.ContentType.Length == 0))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_StreamReferenceValueEmptyContentType);
     }
     if ((isDefaultStream && (streamReference.ReadLink == null)) && (streamReference.ContentType != null))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_DefaultStreamWithContentTypeWithoutReadLink);
     }
     if ((isDefaultStream && (streamReference.ReadLink != null)) && (streamReference.ContentType == null))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_DefaultStreamWithReadLinkWithoutContentType);
     }
     if (((streamReference.EditLink == null) && (streamReference.ReadLink == null)) && !isDefaultStream)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_StreamReferenceValueMustHaveEditLinkOrReadLink);
     }
     if ((streamReference.EditLink == null) && (streamReference.ETag != null))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_StreamReferenceValueMustHaveEditLinkToHaveETag);
     }
 }
        /// <summary>
        /// Writes a stream property
        /// </summary>
        /// <param name="streamReferenceValue">The stream reference value to be written</param>
        private void WriteStreamReferenceValue(ODataStreamReferenceValue streamReferenceValue)
        {
            Debug.Assert(streamReferenceValue != null, "streamReferenceValue != null");

            // start of the stream reference value
            this.JsonWriter.StartObjectScope();

            // the __mediaresource property
            this.JsonWriter.WriteName(JsonConstants.ODataMetadataMediaResourceName);

            // start of the __mediaresource property value
            this.JsonWriter.StartObjectScope();

            this.WriteStreamReferenceValueContent(streamReferenceValue);

            // end of the __mediaresource propert value
            this.JsonWriter.EndObjectScope();

            // end of the stream reference value
            this.JsonWriter.EndObjectScope();
        }
        /// <summary>
        /// Writes the metadata content for a media resource or a named stream
        /// </summary>
        /// <param name="streamReferenceValue">The stream reference value for which to write the metadata</param>
        internal void WriteStreamReferenceValueContent(ODataStreamReferenceValue streamReferenceValue)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(streamReferenceValue != null, "streamReferenceValue != null");

            // Write the "edit_media": "url"
            Uri mediaEditLink = streamReferenceValue.EditLink;
            if (mediaEditLink != null)
            {
                this.JsonWriter.WriteName(JsonConstants.ODataMetadataEditMediaName);
                this.JsonWriter.WriteValue(this.UriToAbsoluteUriString(mediaEditLink));
            }

            // Write the "media_src": "url"
            if (streamReferenceValue.ReadLink != null)
            {
                this.JsonWriter.WriteName(JsonConstants.ODataMetadataMediaUriName);
                this.JsonWriter.WriteValue(this.UriToAbsoluteUriString(streamReferenceValue.ReadLink));
            }

            // Write the "content_type": "type"
            if (streamReferenceValue.ContentType != null)
            {
                this.JsonWriter.WriteName(JsonConstants.ODataMetadataContentTypeName);
                this.JsonWriter.WriteValue(streamReferenceValue.ContentType);
            }

            // Write the "media_etag": "etag"
            string mediaETag = streamReferenceValue.ETag;
            if (mediaETag != null)
            {
                // Note ValidationUtils.ValidateStreamReferenceValue() should have been called prior to this to make sure mediaEditLink is not null here.
                Debug.Assert(mediaEditLink != null, "The stream edit link cannot be null when the etag value is set.");
                this.WriteETag(JsonConstants.ODataMetadataMediaETagName, mediaETag);
            }
        }
 private ODataStreamReferenceValue GetNewOrExistingStreamPropertyValue(IODataAtomReaderEntryState entryState, string streamPropertyName)
 {
     ODataStreamReferenceValue value2;
     List<ODataProperty> propertiesList = ReaderUtils.GetPropertiesList(entryState.Entry.Properties);
     ODataProperty streamProperty = propertiesList.FirstOrDefault<ODataProperty>(p => string.CompareOrdinal(p.Name, streamPropertyName) == 0);
     if (streamProperty == null)
     {
         IEdmProperty streamEdmProperty = ReaderValidationUtils.ValidateLinkPropertyDefined(streamPropertyName, entryState.EntityType, base.MessageReaderSettings);
         value2 = new ODataStreamReferenceValue();
         streamProperty = new ODataProperty {
             Name = streamPropertyName,
             Value = value2
         };
         ReaderValidationUtils.ValidateStreamReferenceProperty(streamProperty, entryState.EntityType, streamEdmProperty);
         entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(streamProperty);
         propertiesList.Add(streamProperty);
         return value2;
     }
     value2 = streamProperty.Value as ODataStreamReferenceValue;
     if (value2 == null)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomEntryAndFeedDeserializer_StreamPropertyDuplicatePropertyName(streamPropertyName));
     }
     return value2;
 }
 private ODataStreamReferenceValue ReadStreamReferenceValue()
 {
     base.JsonReader.ReadStartObject();
     ODataStreamReferenceValue value2 = new ODataStreamReferenceValue();
     while (base.JsonReader.NodeType == JsonNodeType.Property)
     {
         string str6 = base.JsonReader.ReadPropertyName();
         if (str6 == null)
         {
             goto Label_0186;
         }
         if (!(str6 == "edit_media"))
         {
             if (str6 == "media_src")
             {
                 goto Label_00BA;
             }
             if (str6 == "content_type")
             {
                 goto Label_0106;
             }
             if (str6 == "media_etag")
             {
                 goto Label_0146;
             }
             goto Label_0186;
         }
         if (value2.EditLink != null)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty("edit_media"));
         }
         string propertyValue = base.JsonReader.ReadStringValue("edit_media");
         ODataJsonReaderUtils.ValidateMediaResourceStringProperty(propertyValue, "edit_media");
         value2.EditLink = base.ProcessUriFromPayload(propertyValue);
         continue;
     Label_00BA:
         if (value2.ReadLink != null)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty("media_src"));
         }
         string str3 = base.JsonReader.ReadStringValue("media_src");
         ODataJsonReaderUtils.ValidateMediaResourceStringProperty(str3, "media_src");
         value2.ReadLink = base.ProcessUriFromPayload(str3);
         continue;
     Label_0106:
         if (value2.ContentType != null)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty("content_type"));
         }
         string str4 = base.JsonReader.ReadStringValue("content_type");
         ODataJsonReaderUtils.ValidateMediaResourceStringProperty(str4, "content_type");
         value2.ContentType = str4;
         continue;
     Label_0146:
         if (value2.ETag != null)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ODataJsonEntryAndFeedDeserializer_MultipleMetadataPropertiesForStreamProperty("media_etag"));
         }
         string str5 = base.JsonReader.ReadStringValue("media_etag");
         ODataJsonReaderUtils.ValidateMediaResourceStringProperty(str5, "media_etag");
         value2.ETag = str5;
         continue;
     Label_0186:
         base.JsonReader.SkipValue();
     }
     base.JsonReader.ReadEndObject();
     return value2;
 }
 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 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>
        /// Returns an existing stream property value if it already exists in the list of OData properties otherwise creates a new 
        /// ODataProperty for the stream property and returns the value of that property.
        /// </summary>
        /// <param name="entryState">The reader entry state for the entry being read.</param>
        /// <param name="streamPropertyName">The name of the stream property to return.</param>
        /// <returns>A new or an existing stream property value.</returns>
        private ODataStreamReferenceValue GetNewOrExistingStreamPropertyValue(IODataAtomReaderEntryState entryState, string streamPropertyName)
        {
            Debug.Assert(entryState != null, "entryState != null");
            Debug.Assert(streamPropertyName != null, "streamPropertyName != null");

            List<ODataProperty> properties = ReaderUtils.GetPropertiesList(entryState.Entry.Properties);

            // Property names are case sensitive, so compare in a case sensitive way.
            ODataProperty streamProperty = properties.FirstOrDefault(p => String.CompareOrdinal(p.Name, streamPropertyName) == 0);

            ODataStreamReferenceValue streamReferenceValue;
            if (streamProperty == null)
            {
                // The ValidateLinkPropertyDefined will fail if a stream property is not defined and the reader settings don't allow
                // reporting undeclared link properties. So if the method returns null, it means report the undeclared property anyway.
                IEdmProperty streamEdmProperty = ReaderValidationUtils.ValidateLinkPropertyDefined(streamPropertyName, entryState.EntityType, this.MessageReaderSettings);

                streamReferenceValue = new ODataStreamReferenceValue();
                streamProperty = new ODataProperty
                {
                    Name = streamPropertyName,
                    Value = streamReferenceValue
                };

                ReaderValidationUtils.ValidateStreamReferenceProperty(streamProperty, entryState.EntityType, streamEdmProperty);
                entryState.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(streamProperty);
                properties.Add(streamProperty);
            }
            else
            {
                streamReferenceValue = streamProperty.Value as ODataStreamReferenceValue;
                if (streamReferenceValue == null)
                {
                    throw new ODataException(o.Strings.ODataAtomEntryAndFeedDeserializer_StreamPropertyDuplicatePropertyName(streamPropertyName));
                }
            }

            return streamReferenceValue;
        }
 /// <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);
     }
 }
示例#18
0
        private ODataStreamReferenceValue GetMediaResource(object element, ResourceType entityResourceType, string title, Uri relativeUri)
        {
            ODataStreamReferenceValue value2 = null;
            if (entityResourceType.IsMediaLinkEntry)
            {
                string str;
                Uri uri;
                string str2;
                base.Service.StreamProvider.GetStreamDescription(element, null, base.Service.OperationContext, out str, out uri, out str2);
				Uri uri2 = RequestUriProcessor.AppendEscapedSegment(relativeUri, "$value");
                value2 = new ODataStreamReferenceValue {
                    EditLink = uri2,
                    ContentType = str2,
                    ReadLink = uri ?? uri2
                };
                AtomStreamReferenceMetadata metadata2 = new AtomStreamReferenceMetadata();
                AtomLinkMetadata metadata3 = new AtomLinkMetadata {
                    Title = title
                };
                metadata2.EditLink = metadata3;
                AtomStreamReferenceMetadata annotation = metadata2;
                value2.SetAnnotation<AtomStreamReferenceMetadata>(annotation);
                if (!string.IsNullOrEmpty(str))
                {
                    value2.ETag = str;
                }
            }
            return value2;
        }