public static List <T> GetResponseAsList <T>(this HttpWebResponse webResponse)
        {
            var payload        = webResponse.GetBody();
            var collectionPage = JsonSerializer.Deserialize <CollectionPage <T> >(payload);

            return(collectionPage.values);
        }
        private static void HandleException(string url, Exception e, out Exception resultException)
        {
            resultException = null;
            string         message    = null;
            HttpStatusCode statusCode = HttpStatusCode.OK;
            string         type       = null;

            if (e is WebException)
            {
                WebException    webException = (WebException)e;
                HttpWebResponse response     = (HttpWebResponse)webException.Response;

                message    = response.GetBody();
                statusCode = response.StatusCode;

                dynamic jsonResult = JsonConvert.DeserializeObject(message);
                if (jsonResult != null && jsonResult.error != null)
                {
                    if (jsonResult.error.type != null)
                    {
                        type = jsonResult.error.type;
                    }
                    else
                    {
                        type = jsonResult.error;
                    }
                }

                switch (type)
                {
                case "OAuthException":
                case "190":
                    resultException = new FacebookOAuthException(type, message);
                    break;

                default:
                    resultException = new FacebookApiException(type, message);
                    break;
                }
            }
            else
            {
                message = e.Message;
            }

            // replacing ; character since it's our delimiter
            url     = url.Replace(";", "%3b");
            message = message.Replace(";", "%3b");

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0};{1};{2};{3}", (int)statusCode, statusCode, url, message);

            Logger.Current.Error("GraphAPI.HandleException", sb.ToString(), e);
        }
        public static T GetResponseAsObject <T>(this HttpWebResponse webResponse)
        {
            var payload = webResponse.GetBody();

            return(JsonSerializer.Deserialize <T>(payload));
        }
        public static CollectionPage <T> GetResponsePage <T>(this HttpWebResponse webResponse)
        {
            var payload = webResponse.GetBody();

            return(JsonSerializer.Deserialize <CollectionPage <T> >(payload));
        }