private Task<QiniuBlock> MakeBlock(QiniuBlock qbLocal) { return InternalExtensions.OnSuccess<Tuple<HttpStatusCode, string>, QiniuBlock>( this.MakeBlock(qbLocal.Chunks.First.Value.ChunkData, qbLocal.BlockSize), (Func<Task<Tuple<HttpStatusCode, string>>, QiniuBlock>) (t => { Tuple<HttpStatusCode, IDictionary<string, object>> tuple = AVClient.ReponseResolve(t.Result, CancellationToken.None); long num1 = long.Parse(tuple.Item2["offset"].ToString()); string str1 = tuple.Item2["ctx"].ToString(); string str2 = tuple.Item2["host"].ToString(); string str3 = tuple.Item2["checksum"].ToString(); long num2 = long.Parse(tuple.Item2["crc32"].ToString()); qbLocal.Chunks.First.Value.Checksum = str3; qbLocal.Chunks.First.Value.Crc32 = num2; qbLocal.Chunks.First.Value.Ctx = str1; qbLocal.Chunks.First.Value.Offset = num1; qbLocal.Chunks.First.Value.Host = str2; if (qbLocal.Chunks.First.Next != null) { qbLocal.Chunks.First.Next.Value.Ctx = str1; qbLocal.Chunks.First.Next.Value.Offset = num1; } return qbLocal; })); }
private LinkedList<QiniuBlock> CuttingBlock(long fsize) { LinkedList<QiniuBlock> ll = new LinkedList<QiniuBlock>(); this.SetChunkStrategy(); int num = this.CalcBlockCount(this.dataStream.Length); for (int blockIndexInFile = 0; blockIndexInFile < num; ++blockIndexInFile) { long length1 = this.dataStream.Length; long length2 = (long) AVFile.BLOCKSIZE; if (blockIndexInFile == num - 1) length2 = length1 - (long) (blockIndexInFile*AVFile.BLOCKSIZE); byte[] numArray = new byte[length2]; this.dataStream.Seek((long) (AVFile.BLOCKSIZE*blockIndexInFile), SeekOrigin.Begin); this.dataStream.Read(numArray, 0, (int) length2); QiniuBlock qiniuBlock = new QiniuBlock(blockIndexInFile, numArray, this.chunkSize); InternalExtensions.Append<QiniuBlock>(ll, qiniuBlock); } return ll; }