Exemplo n.º 1
0
        internal B2Bucket(B2Client b2Client, B2BucketObject bucket)
        {
            _b2Client = b2Client;
            _bucket = bucket;

            State = B2BucketState.Present;
        }
Exemplo n.º 2
0
        public async Task<bool> UpdateAsync(B2BucketType newType)
        {
            ThrowIfNot(B2BucketState.Present);

            B2BucketObject result = await _b2Client.Communicator.UpdateBucket(AccountId, BucketId, newType);
            _bucket = result;

            return true;
        }
Exemplo n.º 3
0
        public B2BucketObject RecordBucket(B2BucketObject bucket)
        {
            B2BucketObject item = GetById(bucket.BucketId, true);

            item.BucketId = bucket.BucketId;
            item.BucketName = bucket.BucketName;

            return item;
        }
Exemplo n.º 4
0
 private B2BucketObject GetById(string id, bool create)
 {
     lock (_cache)
     {
         B2BucketObject item = _cache.SingleOrDefault(s => s.BucketId == id);
         if (item == null && create)
             _cache.Add(item = new B2BucketObject { BucketId = id });
         return item;
     }
 }
Exemplo n.º 5
0
        public async Task<bool> DeleteAsync()
        {
            ThrowIfNot(B2BucketState.Present);

            B2BucketObject result = await _b2Client.Communicator.DeleteBucket(AccountId, BucketId);
            State = B2BucketState.Deleted;

            _b2Client.BucketCache.RemoveBucket(_bucket);
            _bucket = result;

            return true;
        }
Exemplo n.º 6
0
 public void RemoveBucket(B2BucketObject bucket)
 {
     lock (_cache)
         _cache.RemoveAll(s => s.BucketId == bucket.BucketId);
 }