Esempio n. 1
0
 void ThrowIfContainerNotFound()
 {
     if (!_file.Directory.Exists)
     {
         throw StreamErrors.ContainerNotFound(this);
     }
 }
Esempio n. 2
0
 void ThrowIfItemNotFound()
 {
     if (!_file.Exists)
     {
         throw StreamErrors.ItemNotFound(this);
     }
 }
Esempio n. 3
0
 public IEnumerable<string> ListAllNestedItems()
 {
     try
     {
         return _root.GetFiles().Select(f => f.Name).ToArray();
     }
     catch (DirectoryNotFoundException e)
     {
         throw StreamErrors.ContainerNotFound(this, e);
     }
 }
Esempio n. 4
0
 public IEnumerable<StreamItemDetail> ListAllNestedItemsWithDetail()
 {
     try
     {
         return _root.GetFiles("*", SearchOption.AllDirectories).Select(f => new StreamItemDetail()
             {
                 LastModifiedUtc = f.LastWriteTimeUtc,
                 Length = f.Length,
                 Name = f.Name
             }).ToArray();
     }
     catch (DirectoryNotFoundException e)
     {
         throw StreamErrors.ContainerNotFound(this, e);
     }
 }
Esempio n. 5
0
        public IEnumerable <string> ListItems()
        {
            try
            {
                return(_directory.ListBlobs()
                       .Select(item => _directory.Uri.MakeRelativeUri(item.Uri).ToString())
                       .ToArray());
            }
            catch (StorageClientException e)
            {
                switch (e.ErrorCode)
                {
                case StorageErrorCode.ContainerNotFound:
                    throw StreamErrors.ContainerNotFound(this, e);

                default:
                    throw;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Removes the item, ensuring that the specified condition is met.
        /// </summary>
        public void Delete()
        {
            try
            {
                _blob.Delete();
            }
            catch (StorageClientException ex)
            {
                switch (ex.ErrorCode)
                {
                case StorageErrorCode.ContainerNotFound:
                    throw StreamErrors.ContainerNotFound(this, ex);

                case StorageErrorCode.BlobNotFound:
                case StorageErrorCode.ConditionFailed:
                    return;

                default:
                    throw;
                }
            }
        }