private void WithHammock <T>(IRestClient restClient, WebMethod method, Action <T, TwitterResponse> action, MediaFile media, string path) where T : class
        {
            var request = PrepareHammockQuery(path);

            request.Method = method;
            request.AddFile("media", media.FileName, media.Content);

            WithHammockImpl(restClient, request, action);
        }
        private Task <TwitterAsyncResult <T1> > WithHammockTask <T1>(RestClient client, WebMethod method, string path, MediaFile media, params object[] segments) where T1 : class
        {
            var tcs = new TaskCompletionSource <TwitterAsyncResult <T1> >();

            try
            {
                WithHammock <T1>(client, method,
                                 (Action <T1, TwitterResponse>)((v, r) =>
                {
                    try
                    {
                        tcs.SetResult(new TwitterAsyncResult <T1>(v, r));
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                }),
                                 media,
                                 ResolveUrlSegments(path, segments.ToList())
                                 );
            }
            catch (Exception ex)
            {
                tcs.SetException(ex);
            }

            return(tcs.Task);
        }
        private IAsyncResult BeginWithHammock <T>(RestClient client, WebMethod method, string path, MediaFile media, params object[] segments)
        {
            var url     = ResolveUrlSegments(path, segments.ToList());
            var request = PrepareHammockQuery(url);

            request.Method        = method;
            request.QueryHandling = QueryHandling.AppendToParameters;
            request.AddFile("media", media.FileName, media.Content);
            var result = _client.BeginRequest <T>(request);

            return(result);
        }
 private IAsyncResult WithHammock <T>(RestClient client, WebMethod method, Action <T, TwitterResponse> action, string path, MediaFile media, params object[] segments) where T : class
 {
     return(WithHammock(client, method, action, media, ResolveUrlSegments(path, segments.ToList())));
 }
Beispiel #5
0
        private Task WithHammockNoResponseTask(RestClient client, WebMethod method, string path, MediaFile media, params object[] segments)
        {
            var tcs = new TaskCompletionSource <object>();

            try
            {
                WithHammockNoResponse(client, method,
                                      (Action <TwitterResponse>)((r) =>
                {
                    try
                    {
                        if (r.InnerException == null)
                        {
                            tcs.SetResult(r);
                        }
                        else
                        {
                            tcs.SetException(r.InnerException);
                        }
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                }),
                                      media,
                                      ResolveUrlSegments(path, segments.ToList())
                                      );
            }
            catch (Exception ex)
            {
                tcs.SetException(ex);
            }

            return(tcs.Task);
        }
Beispiel #6
0
        private void WithHammockNoResponse(RestClient client, WebMethod method, string path, MediaFile media, params object[] segments)
        {
            var url     = ResolveUrlSegments(path, segments.ToList());
            var request = PrepareHammockQuery(url);

            request.Method        = method;
            request.QueryHandling = QueryHandling.AppendToParameters;

            request.AddFile("media", media.FileName, media.Content);
            WithHammockNoResponseImpl(client, request);
        }
Beispiel #7
0
        private IAsyncResult WithHammockNoResponse(RestClient client, WebMethod method, Action <TwitterResponse> action, MediaFile media, string path)
        {
            var request = PrepareHammockQuery(path);

            request.Method = method;
            request.AddFile("media", media.FileName, media.Content);

            return(WithHammockNoResponseImpl(client, request, action));
        }