示例#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);
        }
示例#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);
        }
		/// <summary>
		/// 修改指定的文件容器信息。
		/// </summary>
		/// <param name="bucket">指定要修改的文件容器信息实体对象。</param>
		public void Put(StorageBucketInfo bucket)
		{
			if(bucket == null)
				throw new ArgumentNullException("bucket");

			if(bucket.BucketId < 1)
				throw new ArgumentOutOfRangeException("Bucket.BucketId");

			this.Bucket.Modify(bucket.BucketId, bucket.Name, bucket.Title, bucket.Path, bucket.ModifiedTime);
		}
		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;
		}
		/// <summary>
		/// 新增一个文件容器。
		/// </summary>
		/// <param name="bucket">新增的文件容器实体对象。</param>
		public int Post(StorageBucketInfo bucket)
		{
			if(bucket == null)
				throw new ArgumentNullException("bucket");

			if(bucket.BucketId < 1)
				bucket.BucketId = (int)this.Sequence.GetSequenceNumber("Zongsoft.IO.StorageBucket.Id");

			this.Bucket.Create(bucket.BucketId, bucket.Name, bucket.Title, bucket.Path);

			//返回新增文件容器的编号
			return (int)bucket.BucketId;
		}