/// <summary> /// Sets ETag.Value /// </summary> /// <param name="Entity"></param> protected virtual string CalculateETag() { bool isHash; object metaData = this.GetMetaData(out isHash); string etag; if (metaData is Guid) { etag = ((Guid)metaData).ToString("N"); } else if (metaData is string) { if (isHash) { etag = (string)metaData; } else { etag = ETag.ComputeHash((string)metaData); } } else if (metaData is byte[]) { if (isHash) { etag = ETag.FormatBytes((byte[])metaData); } else { etag = ETag.ComputeHash((byte[])metaData); } } else if (metaData is Stream) { etag = ETag.ComputeHash((Stream)metaData); } else { throw new NotSupportedException("GetMetaData must return Guid, String, Byte[], or Stream"); } return("\"" + etag + "\""); }