public static Blob ToBlob(string containerName, BlobHierarchyItem bhi) { string GetFullName(string name) => containerName == null ? name : StoragePath.Combine(containerName, name); if (bhi.IsBlob) { var blob = new Blob(GetFullName(bhi.Blob.Name), BlobItemKind.File); blob.MD5 = bhi.Blob.Properties.ContentHash.ToHexString(); blob.Size = bhi.Blob.Properties.ContentLength; blob.LastModificationTime = bhi.Blob.Properties.LastModified; AddProperties(blob, bhi.Blob.Properties); blob.Metadata.MergeRange(bhi.Blob.Metadata); return(blob); } if (bhi.IsPrefix) { var blob = new Blob(GetFullName(bhi.Prefix), BlobItemKind.Folder); //nothing else we know about prefix return(blob); } throw new NotImplementedException(); }
/// <summary> /// increment the counter /// </summary> /// <param name="count">blob count counter</param> /// <param name="bytes">blob bytes counter</param> /// <param name="bhi">blob hierarchy item</param> private void InterlockedAdd(ref long count, ref long bytes, BlobHierarchyItem bhi) { Interlocked.Add(ref count, 1); Interlocked.Add(ref bytes, bhi.Blob.Properties.ContentLength.GetValueOrDefault()); }