public override void GetTokenResponseCallback(HttpWebRequestCallbackState state)
        {
            base.GetTokenResponseCallback(state);
            object token = null;

            try
            {
                token = DeSerializeToJson <AdmAccessToken>(state.ResponseStream);
            }
            catch
            {
            }
            OnTokenArrived(token);
        }
Ejemplo n.º 2
0
        static void BeginGetResponseCallback(IAsyncResult asyncResult)
        {
            WebResponse webResponse             = null;
            Stream      responseStream          = null;
            HttpWebRequestAsyncState asyncState = null;

            try
            {
                asyncState  = (HttpWebRequestAsyncState)asyncResult.AsyncState;
                webResponse = asyncState.HttpWebRequest.EndGetResponse(asyncResult);

                responseStream = webResponse.GetResponseStream();
                var webRequestCallbackState = new HttpWebRequestCallbackState(responseStream, asyncState.State);
                asyncState.ResponseCallback(webRequestCallbackState);
                responseStream.Close();
                responseStream = null;
                webResponse.Close();
                webResponse = null;
            }
            catch (Exception ex)
            {
                if (asyncState != null)
                {
                    asyncState.ResponseCallback(new HttpWebRequestCallbackState(ex));
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (responseStream != null)
                {
                    responseStream.Close();
                }
                if (webResponse != null)
                {
                    webResponse.Close();
                }
            }
        }