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); } }
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); }