TryGetUserValueDictionary
        (
            String sScreenName,
            RequestStatistics oRequestStatistics,
            Boolean bIgnoreWebAndJsonExceptions,
            out Dictionary <String, Object> oUserValueDictionary
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sScreenName));
            Debug.Assert(oRequestStatistics != null);
            AssertValid();

            oUserValueDictionary = null;

            String sUrl = String.Format(

                "{0}users/show.json?screen_name={1}&{2}"
                ,
                TwitterApiUrls.Rest,
                TwitterUtil.EncodeUrlParameter(sScreenName),
                TwitterApiUrlParameters.IncludeEntities
                );

            ReportProgress(String.Format(

                               "Getting information about \"{0}\"."
                               ,
                               sScreenName
                               ));

            try
            {
                oUserValueDictionary = (Dictionary <String, Object>)
                                           (new JavaScriptSerializer()).DeserializeObject(
                    GetTwitterResponseAsString(sUrl, oRequestStatistics));

                return(true);
            }
            catch (Exception oException)
            {
                if (!HttpSocialNetworkUtil.ExceptionIsWebOrJson(oException) ||
                    !bIgnoreWebAndJsonExceptions)
                {
                    throw oException;
                }

                return(false);
            }
        }
Exemple #2
0
        OnExceptionWhileEnumeratingJsonValues
        (
            Exception exception,
            Int32 iPage,
            Boolean bSkipMostPage1Errors
        )
        {
            Debug.Assert(exception != null);
            Debug.Assert(iPage > 0);

            if (!HttpSocialNetworkUtil.ExceptionIsWebOrJson(exception))
            {
                // This is an unknown exception.

                throw (exception);
            }

            if (
                exception is WebException
                &&
                WebExceptionIsDueToRateLimit((WebException)exception)
                )
            {
                throw (exception);
            }
            else if (iPage == 1)
            {
                if (bSkipMostPage1Errors)
                {
                    return;
                }
                else
                {
                    throw (exception);
                }
            }
            else
            {
                // Always skip non-rate-limit errors on page 2 and above.

                return;
            }
        }