/// <summary>
        ///     Return an HttpRequestMessage which represents the given seafile request
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serverUri"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public HttpRequestMessage CreateHttpRequestMessage <T>(Uri serverUri, SeafRequest <T> request)
        {
            var targetUri = new Uri(serverUri, request.CommandUri);

            switch (request.HttpAccessMethod)
            {
            case HttpAccessMethod.Custom:
                return(request.GetCustomizedRequest(serverUri));

            default:
                return(HttpUtils.CreateRequest(GetHttpMethod(request.HttpAccessMethod), targetUri, request.GetAdditionalHeaders(), request.GetBodyParameters()));
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Return an HttpRequestMessage which represents the given seafile request
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serverUri"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public HttpRequestMessage CreateHttpRequestMessage <T>(Uri serverUri, SeafRequest <T> request)
        {
            var targetUri = new Uri(serverUri, request.CommandUri);

            switch (request.HttpAccessMethod)
            {
            case HttpAccessMethod.Get:
                return(HttpUtils.CreateSimpleRequest(HttpMethod.Get, targetUri, request.GetAdditionalHeaders()));

            case HttpAccessMethod.Post:
                return(HttpUtils.CreatePostRequest(targetUri, request.GetAdditionalHeaders(),
                                                   request.GetPostParameters()));

            case HttpAccessMethod.Delete:
                return(HttpUtils.CreateSimpleRequest(HttpMethod.Delete, targetUri, request.GetAdditionalHeaders()));

            case HttpAccessMethod.Custom:
                return(request.GetCustomizedRequest(serverUri));

            default:
                throw new ArgumentException("Unsupported method: " + request.HttpAccessMethod);
            }
        }