Exemple #1
0
        public static void BeginRequest <T>(string uri, T state, WebAPIRequestSend <T> send, WebAPIRequestReceive <T> receive)
        {
            try
            {
                CSOptions.ToConsole("Requesting: {0}", uri);

                var request = (HttpWebRequest)WebRequest.Create(uri);

                request.UserAgent = "VitaNexCore/" + VitaNexCore.Version + " " + CSOptions.Service.FullName;

                // ReSharper disable once AssignNullToNotNullAttribute
                request.Proxy       = null;
                request.Credentials = null;

                if (send != null)
                {
                    send(request, state);
                }

                if (RequestSend != null)
                {
                    RequestSend(request, state);
                }

                RequestUtility.BeginGetResponse(request, state, receive);
            }
            catch (Exception e)
            {
                CSOptions.ToConsole(e);
            }
        }
Exemple #2
0
        public static void BeginRequest <T>(string uri, T state, WebAPIRequestSend <T> send, WebAPIRequestReceive <T> receive)
        {
            VitaNexCore.TryCatch(
                () =>
            {
                CSOptions.ToConsole("Requesting: {0}", uri);

                var request = (HttpWebRequest)WebRequest.Create(uri);

                request.Proxy       = null;
                request.Credentials = null;

                if (send != null)
                {
                    send(request, state);
                }

                if (RequestSend != null)
                {
                    RequestSend(request, state);
                }

                RequestUtility.BeginGetResponse(request, state, receive);
            },
                CSOptions.ToConsole);
        }
Exemple #3
0
 public static void BeginRequest(
     string url,
     object state,
     WebAPIRequestSend <object> send,
     WebAPIRequestReceive <object> receive)
 {
     BeginRequest <object>(url, state, send, receive);
 }
Exemple #4
0
 public static void BeginRequest <T>(Uri uri, T state, WebAPIRequestSend <T> send, WebAPIRequestReceive <T> receive)
 {
     BeginRequest(uri.ToString(), state, send, receive);
 }