public YelpAPIClient(IntPtr pointer)
        {
            nativePointer = pointer;

            if(CurrentRequest != null)
            {
                CurrentRequest.AbortRequest();
                CurrentRequest = this;
            }

            var mainWindow = (MainWindow)Application.Current.MainWindow;
            m_dispatcher = mainWindow.Dispatcher;
        }
        public YelpAPIClient(IntPtr pointer)
        {
            nativePointer = pointer;

            if (CurrentRequest != null)
            {
                CurrentRequest.AbortRequest();
                CurrentRequest = this;
            }

            var mainWindow = (MainWindow)Application.Current.MainWindow;

            m_dispatcher = mainWindow.Dispatcher;
        }
        private void PerformRequest(string consumerKey, string consumerSecret, string oAuthToken, string oAuthTokenSecret, string baseURL, Dictionary <string, string> queryParams = null)
        {
            var query = System.Web.HttpUtility.ParseQueryString(String.Empty);

            if (queryParams == null)
            {
                queryParams = new Dictionary <string, string>();
            }

            foreach (var queryParam in queryParams)
            {
                query[queryParam.Key] = queryParam.Value;
            }

            var uriBuilder = new UriBuilder(baseURL);

            uriBuilder.Query = query.ToString();

            m_request        = WebRequest.Create(uriBuilder.ToString());
            m_request.Method = "GET";

            m_request.SignRequest(
                new Tokens
            {
                ConsumerKey       = consumerKey,
                ConsumerSecret    = consumerSecret,
                AccessToken       = oAuthToken,
                AccessTokenSecret = oAuthTokenSecret
            }
                ).WithEncryption(EncryptionMethod.HMACSHA1).InHeader();

            DoWithResponse(m_request as HttpWebRequest, (response) => {
                string body = string.Empty;

                if (response != null)
                {
                    body = new StreamReader(response.GetResponseStream()).ReadToEnd();
                }

                m_dispatcher.BeginInvoke(webRequestCallback, body, nativePointer);
                CurrentRequest = null;
            });
        }
        private void PerformRequest(string consumerKey, string consumerSecret, string oAuthToken, string oAuthTokenSecret, string baseURL, Dictionary<string, string> queryParams = null)
        {
            var query = System.Web.HttpUtility.ParseQueryString(String.Empty);

            if (queryParams == null)
            {
                queryParams = new Dictionary<string, string>();
            }

            foreach (var queryParam in queryParams)
            {
                query[queryParam.Key] = queryParam.Value;
            }

            var uriBuilder = new UriBuilder(baseURL);
            uriBuilder.Query = query.ToString();

            m_request = WebRequest.Create(uriBuilder.ToString());
            m_request.Method = "GET";

            m_request.SignRequest(
                new Tokens
                {
                    ConsumerKey = consumerKey,
                    ConsumerSecret = consumerSecret,
                    AccessToken = oAuthToken,
                    AccessTokenSecret = oAuthTokenSecret
                }
            ).WithEncryption(EncryptionMethod.HMACSHA1).InHeader();

            DoWithResponse(m_request as HttpWebRequest, (response) => {

                string body = string.Empty;

                if (response != null)
                {
                    body = new StreamReader(response.GetResponseStream()).ReadToEnd();
                }

                m_dispatcher.BeginInvoke(webRequestCallback, body, nativePointer);
                CurrentRequest = null;
            });
        }