Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }