Exemplo n.º 1
0
        public Stream GetPhotoWriteStream(StreamingServicePhotoBase photo, string contentType)
        {
            PhotoWriteStream stream = new PhotoWriteStream(photo, contentType);

            this.pendingChanges.Add(new PendingChange()
            {
                ChangeType = ChangeType.UpdateStream, List = null, Resource = stream
            });
            return(stream);
        }
Exemplo n.º 2
0
        public System.IO.Stream GetWriteStream(object entity, string etag, bool?checkETagForEquality, DataServiceOperationContext operationContext)
        {
            if (operationContext.RequestHeaders["Content-Type"] == "test/fail-this-request")
            {
                throw new InvalidOperationException("Request failed for test reasons.");
            }
            StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase;

            if (photo == null)
            {
                throw new ArgumentException("The specified entity is not a photo entity.", "entity");
            }
            return(((StreamingServiceContext)this.CurrentDataSource).GetPhotoWriteStream(photo, operationContext.RequestHeaders["Content-Type"]));
        }
Exemplo n.º 3
0
        public string GetStreamContentType(object entity, DataServiceOperationContext operationContext)
        {
            StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders;

            if (headers != null)
            {
                return("text/plain");
            }

            StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase;

            if (photo == null)
            {
                throw new ArgumentException("The specified entity is not a photo entity.", "entity");
            }

            return(photo.GetContentType());
        }
Exemplo n.º 4
0
        public Uri GetReadStreamUri(object entity, DataServiceOperationContext operationContext)
        {
            StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders;

            if (headers == null)
            {
                StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase;
                if (photo == null)
                {
                    throw new ArgumentException("The specified entity is not a photo entity.", "entity");
                }

                StreamingServicePhoto photoV2 = photo as StreamingServicePhoto;
                if (photoV2 != null && photoV2.AlternativeUri && contentServiceUri != null)
                {
                    return(new Uri(contentServiceUri.ToString() + "PhotoContent?id=" + photoV2.ID.ToString(), UriKind.Absolute));
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        public System.IO.Stream GetReadStream(object entity, string etag, bool?checkETagForEquality, DataServiceOperationContext operationContext)
        {
            if (GetReadStreamOverride != null)
            {
                return(GetReadStreamOverride(entity, etag, checkETagForEquality, operationContext));
            }

            StreamingServiceRequestHeaders headers = entity as StreamingServiceRequestHeaders;

            if (headers != null)
            {
                return(new MemoryStream(Encoding.UTF8.GetBytes(headers.Headers.ToString())));
            }

            StreamingServicePhotoBase photo = entity as StreamingServicePhotoBase;

            if (photo == null)
            {
                throw new ArgumentException("The specified entity is not a photo entity.", "entity");
            }

            return(new MemoryStream(photo.GetContent()));
        }
Exemplo n.º 6
0
 public PhotoWriteStream(StreamingServicePhotoBase photo, string contentType)
 {
     this.photo       = photo;
     this.stream      = new MemoryStream();
     this.contentType = contentType;
 }