コード例 #1
0
        private IResult ServeOriginal(string path, IStorageFile storageFile, IFormatInfo outputFormat)
        {
            var stream = storageFile.GetStream();

            IAddToCacheResult cacheResult;

            if (MediaCache.TryAddToCache(path, stream, outputFormat, out cacheResult))
            {
                return(new CopyToOutputStreamResult(cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream));
            }

            return(storageFile);
        }
コード例 #2
0
ファイル: StorageFile.cs プロジェクト: yanyitec/Yanyitec
 public bool CopyTo(IStorageFile target) {
     var srcStream = this.GetStream();
     if (srcStream == null) return false;
     using (srcStream) {
         using (var targetStream = target.GetStream(true))
         {
             const int bufferSize = 1024 * 2;
             byte[] buffer = new byte[bufferSize];
             int readCount = 0;
             while ((readCount = srcStream.Read(buffer, 0, bufferSize)) > 0) {
                 targetStream.Write(buffer, 0, readCount);
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: StorageFile.cs プロジェクト: yanyitec/Yanyitec
 public async Task<bool> CopyToAsync(IStorageFile target)
 {
     var srcStream = this.GetStream();
     if (srcStream == null) return false;
     using (srcStream)
     {
         using (var targetStream = target.GetStream(true))
         {
             const int bufferSize = 1024 * 2;
             byte[] buffer = new byte[bufferSize];
             int readCount = 0;
             while ((readCount =await srcStream.ReadAsync(buffer, 0, bufferSize)) > 0)
             {
                 await targetStream.WriteAsync(buffer, 0, readCount);
             }
         }
     }
     return true;
 }
コード例 #4
0
        private IResult ServeOriginal( string path, IStorageFile storageFile, IFormatInfo outputFormat )
        {
            var stream = storageFile.GetStream();

            IAddToCacheResult cacheResult;
            if ( MediaCache.TryAddToCache( path, stream, outputFormat, out cacheResult ) )
            {
                return new CopyToOutputStreamResult( cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream );
            }

            return storageFile;
        }