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()); }
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); }
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())); }