string IDataServiceStreamProvider.GetStreamETag(object entity, DataServiceOperationContext host) { if (entity is ExternalPicture) { ExternalPicture pict = entity as ExternalPicture; return(pict.BlobETag); } if (entity is InternalPicture) { InternalPicture pict = entity as InternalPicture; // ETag value is timestamp of the storage file if (this.GetEntityState(pict) != EntityState.Added) { this.LoadFileStorageIfItsNotLoaded(pict, "PT.FK_FileStorage_InternalPictures1", "FileStorage"); if (pict.FileStorage == null) { return(null); } var creationTime = System.Data.Test.Astoria.FullTrust.TrustedMethods.GetFileCreationTime(DataPath(pict.FileStorage.Location)); return(string.Concat("\"", creationTime.ToString("dd MMMM yyyy hh:mm:ss.ffffff", System.Globalization.DateTimeFormatInfo.InvariantInfo), "\"")); } } return(null); }
/// <summary> /// Create a new ExternalPicture object. /// </summary> /// <param name="ID">Initial value of Id.</param> /// <param name="uRL">Initial value of URL.</param> public static ExternalPicture CreateExternalPicture(int ID, string uRL) { ExternalPicture externalPicture = new ExternalPicture(); externalPicture.Id = ID; externalPicture.URL = uRL; return(externalPicture); }
Uri IDataServiceStreamProvider.GetReadStreamUri(object entity, DataServiceOperationContext host) { Uri uri = null; if (entity is ExternalPicture) { ExternalPicture pict = entity as ExternalPicture; if (!string.IsNullOrEmpty(pict.URL)) { string url = pict.URL; if (url.Contains("${")) { url = replaceParams(url, GetParamsTable(host)); } uri = new Uri(url, UriKind.RelativeOrAbsolute); } } return(uri); }
string IDataServiceStreamProvider.GetStreamContentType(object entity, DataServiceOperationContext host) { if (entity is InternalPicture) { InternalPicture pict = entity as InternalPicture; this.LoadFileStorageIfItsNotLoaded(pict, "PT.FK_FileStorage_InternalPictures1", "FileStorage"); return(pict.FileStorage.ContentType); } else if (entity is ExternalPicture) { ExternalPicture pict = entity as ExternalPicture; return(string.IsNullOrEmpty(pict.ContentType) ? "text/plain" : pict.ContentType); } else { throw new NotSupportedException("Unexpected entity type!"); } }
/// <summary> /// Create a new ExternalPicture object. /// </summary> /// <param name="ID">Initial value of Id.</param> /// <param name="uRL">Initial value of URL.</param> public static ExternalPicture CreateExternalPicture(int ID, string uRL) { ExternalPicture externalPicture = new ExternalPicture(); externalPicture.Id = ID; externalPicture.URL = uRL; return externalPicture; }