Пример #1
0
        private static IHttpAddress AddListingParameters(IHttpAddress source, ListingFlags mode)
        {
            int modeInt = (int)mode;

            if ((modeInt & (int)ListingFlags.IncludeFiles) != 0)
            {
                source = source.WithParameter("include_files", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeFolders) != 0)
            {
                source = source.WithParameter("include_folders", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeProperties) != 0)
            {
                source = source.WithParameter("include_properties", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeSubFolders) != 0)
            {
                source = source.WithParameter("full_tree", true);
            }

            return(source);
        }
Пример #2
0
        private static Dictionary<string, object> AddListingParameters(Dictionary<string, object> parameters, ListingFlags mode)
        {
            Dictionary<string, object> result = new Dictionary<string, object>(parameters);
            int modeInt = (int)mode;

            if ((modeInt & (int)ListingFlags.IncludeFiles) != 0)
            {
                result.Add("include_files", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeFolders) != 0)
            {
                result.Add("include_folders", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeProperties) != 0)
            {
                result.Add("include_properties", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeSubFolders) != 0)
            {
                result.Add("full_tree", true);
            }

            return result;
        }
Пример #3
0
        public async Task<IEnumerable<StorageResource>> GetResourcesAsync(ListingFlags flags)
        {
            SqlQuery query = new SqlQuery();
            query.CustomParameters = AddListingParameters(query.CustomParameters, flags);

            ResourceWrapper<StorageResource> response = await base.RequestAsync<ResourceWrapper<StorageResource>>(
                method: HttpMethod.Get,
                resource: string.Empty, 
                query: query
                );

            return response.Records;
        }
Пример #4
0
        public async Task <IEnumerable <StorageResource> > GetResourcesAsync(ListingFlags flags)
        {
            SqlQuery query = new SqlQuery();

            query.CustomParameters = AddListingParameters(query.CustomParameters, flags);

            ResourceWrapper <StorageResource> response = await base.RequestAsync <ResourceWrapper <StorageResource> >(
                method : HttpMethod.Get,
                resource : string.Empty,
                query : query
                );

            return(response.Records);
        }
Пример #5
0
        public async Task<ContainerResponse> GetContainerAsync(string container, ListingFlags flags)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            IHttpAddress address = baseAddress.WithResource( container, string.Empty);
            address = AddListingParameters(address, flags);
            IHttpRequest request = new HttpRequest(HttpMethod.Get, address.Build(), baseHeaders);

            IHttpResponse response = await httpFacade.RequestAsync(request);
            HttpUtils.ThrowOnBadStatus(response, contentSerializer);

            return contentSerializer.Deserialize<ContainerResponse>(response.Body);
        }
        public Task<FolderResponse> GetFolderAsync(string path, ListingFlags flags)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            SqlQuery query = new SqlQuery { Fields = null };
            query.CustomParameters = AddListingParameters(query.CustomParameters, flags);

            return base.RequestAsync<FolderResponse>(
                method: HttpMethod.Get,
                resource: path, 
                resourceIdentifier: string.Empty, 
                query: query
                );
        }
Пример #7
0
        public async Task <ContainerResponse> GetContainerAsync(string container, ListingFlags flags)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            IHttpAddress address = baseAddress.WithResource(container, string.Empty);

            address = AddListingParameters(address, flags);
            IHttpRequest request = new HttpRequest(HttpMethod.Get, address.Build(), baseHeaders);

            IHttpResponse response = await httpFacade.RequestAsync(request);

            HttpUtils.ThrowOnBadStatus(response, contentSerializer);

            return(contentSerializer.Deserialize <ContainerResponse>(response.Body));
        }
        public Task <FolderResponse> GetFolderAsync(string path, ListingFlags flags)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            SqlQuery query = new SqlQuery {
                Fields = null
            };

            query.CustomParameters = AddListingParameters(query.CustomParameters, flags);

            return(base.RequestAsync <FolderResponse>(
                       method: HttpMethod.Get,
                       resource: path,
                       resourceIdentifier: string.Empty,
                       query: query
                       ));
        }
Пример #9
0
        private static IHttpAddress AddListingParameters(IHttpAddress source, ListingFlags mode)
        {
            int modeInt = (int)mode;

            if ((modeInt & (int)ListingFlags.IncludeFiles) != 0)
            {
                source = source.WithParameter("include_files", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeFolders) != 0)
            {
                source = source.WithParameter("include_folders", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeProperties) != 0)
            {
                source = source.WithParameter("include_properties", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeSubFolders) != 0)
            {
                source = source.WithParameter("full_tree", true);
            }

            return source;
        }
Пример #10
0
        private static Dictionary <string, object> AddListingParameters(Dictionary <string, object> parameters, ListingFlags mode)
        {
            Dictionary <string, object> result = new Dictionary <string, object>(parameters);
            int modeInt = (int)mode;

            if ((modeInt & (int)ListingFlags.IncludeFiles) != 0)
            {
                result.Add("include_files", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeFolders) != 0)
            {
                result.Add("include_folders", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeProperties) != 0)
            {
                result.Add("include_properties", true);
            }

            if ((modeInt & (int)ListingFlags.IncludeSubFolders) != 0)
            {
                result.Add("full_tree", true);
            }

            return(result);
        }