public StorageBucketInfo GetInfo(int bucketId) { var storage = this.Storage; if (storage == null) { throw new InvalidOperationException("The Storage is null."); } var dictionary = storage.GetValue(GetBucketKey(bucketId)) as IDictionary; if (dictionary != null) { return(StorageBucketInfo.FromDictionary(dictionary)); } return(null); }
public StorageBucketInfo Create(int bucketId, string name, string title, string path) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } var storage = this.Storage; if (storage == null) { throw new InvalidOperationException("The Storage is null."); } var bucket = new StorageBucketInfo(bucketId) { Name = name, Path = path, Title = title, }; storage.SetValue(GetBucketKey(bucketId), bucket.ToDictionary()); var collection = storage.GetValue(GetBucketCollectionKey()) as ICollection <string>; if (collection != null) { collection.Add(bucketId.ToString()); } else { storage.SetValue(GetBucketCollectionKey(), new string[] { bucketId.ToString() }); } return(bucket); }