예제 #1
0
        public static void DoRequest(Action <System.Net.WebClient> actor, RequestParams request)
        {
            using (var client = new WebClientTimeouted(request.Caller))
            {
                if (request.HasCredentials)
                {
                    client.Credentials = request.GetCredentials();
                }

                client.Headers     = request.GetHeaders();
                client.QueryString = request.GetQueryString();
                actor(client);
            }
        }
예제 #2
0
        public static T DoRequest <T>(Func <System.Net.WebClient, T> actor, RequestParams request)
        {
            using (var client = new WebClientTimeouted(request.Caller))
            {
                if (request.HasCredentials)
                {
                    client.Credentials = request.GetCredentials();
                }

                client.Headers     = request.GetHeaders();
                client.QueryString = request.GetQueryString();
                return(actor(client));
            }
        }
예제 #3
0
        public static Task DoRequest(Func <System.Net.WebClient, Task> actor, RequestParams request)
        {
            var client = new WebClientTimeouted(request.Caller);

            if (request.HasCredentials)
            {
                client.Credentials = request.GetCredentials();
            }

            client.Headers     = request.GetHeaders();
            client.QueryString = request.GetQueryString();
            return(actor(client).ContinueWith((antecedent) =>
            {
                client.Dispose();
                return antecedent;
            }));
        }