コード例 #1
0
        public async Task <HttpResponseMessage> SendRequest(CodeActivityContext context, HttpClient client, int method, StringContent content)
        {
            OptionSetValue syncMode = this.SynchronousMode.Get <OptionSetValue>(context);

            if (syncMode != null && syncMode.Value == ASYNC)
            {
                switch (method)
                {
                case GET:
                    client.GetAsync(RequestUrl.Get <string>(context));
                    return(null);

                case PATCH:
                    client.PatchAsync(RequestUrl.Get <string>(context), content);
                    return(null);

                case PUT:
                    client.PutAsync(RequestUrl.Get <string>(context), content);
                    return(null);

                case DELETE:
                    client.DeleteAsync(RequestUrl.Get <string>(context));
                    return(null);

                case POST:
                    client.PostAsync(RequestUrl.Get <string>(context), content);
                    return(null);

                default:
                    throw new InvalidPluginExecutionException("The Request Method supplied is not supported. Try using GET, PATCH, PUT, DELETE or POST");
                }
            }
            else
            {
                switch (method)
                {
                case GET:
                    return(await client.GetAsync(RequestUrl.Get <string>(context)));

                case PATCH:
                    return(await client.PatchAsync(RequestUrl.Get <string>(context), content));

                case PUT:
                    return(await client.PutAsync(RequestUrl.Get <string>(context), content));

                case DELETE:
                    return(await client.DeleteAsync(RequestUrl.Get <string>(context)));

                case POST:
                    return(await client.PostAsync(RequestUrl.Get <string>(context), content));

                default:
                    throw new InvalidPluginExecutionException("The Request Method supplied is not supported. Try using GET, PATCH, PUT, DELETE or POST");
                }
            }
        }
コード例 #2
0
        private async Task <HttpResponseMessage> SendRequest(CodeActivityContext context, HttpClient client, RequestMethodEnum requestMethod, StringContent content)
        {
            switch (requestMethod)
            {
            case RequestMethodEnum.GET:
                return(await client.GetAsync(RequestUrl.Get <string>(context)));

            case RequestMethodEnum.PATCH:
                return(await client.PatchAsync(RequestUrl.Get <string>(context), content));

            case RequestMethodEnum.PUT:
                return(await client.PutAsync(RequestUrl.Get <string>(context), content));

            case RequestMethodEnum.DELETE:
                return(await client.DeleteAsync(RequestUrl.Get <string>(context)));

            case RequestMethodEnum.POST:
                return(await client.PostAsync(RequestUrl.Get <string>(context), content));

            default:
                throw new InvalidPluginExecutionException("The Request Method supplied is not supported. Try using GET, PATCH, PUT, DELETE or POST");
            }
        }