예제 #1
0
        private static ImgurFile ParseResponse(string response)
        {
            bool success = false;

            var json = Json.JsonDecode(response, ref success);

            if (success && json is Dictionary <string, object> )
            {
                var data   = json as Dictionary <string, object>;
                var upload = data["upload"] as Dictionary <string, object>;
                if (upload != null)
                {
                    var links = upload["links"] as Dictionary <string, object>;
                    if (links != null)
                    {
                        var original   = links["original"] as string;
                        var largethumb = links["large_thumbnail"] as string;
                        var smallthumb = links["small_square"] as string;

                        ImgurFile result = new ImgurFile {
                            Original       = new Uri(original, UriKind.Absolute),
                            LargeThumbnail = new Uri(largethumb, UriKind.Absolute),
                            SmallSquare    = new Uri(smallthumb, UriKind.Absolute)
                        };

                        return(result);
                    }
                }
            }

            return(null);
        }
예제 #2
0
        private static ImgurFile ParseResponse(string response)
        {
            bool success = false;

            var json = Json.JsonDecode(response, ref success);

            if (success && json is Dictionary<string, object>) {
                var data = json as Dictionary<string, object>;
                var upload = data["upload"] as Dictionary<string, object>;
                if (upload != null) {
                    var links = upload["links"] as Dictionary<string, object>;
                    if (links != null) {
                        var original = links["original"] as string;
                        var largethumb = links["large_thumbnail"] as string;
                        var smallthumb = links["small_square"] as string;

                        ImgurFile result = new ImgurFile {
                            Original = new Uri(original, UriKind.Absolute),
                            LargeThumbnail = new Uri(largethumb, UriKind.Absolute),
                            SmallSquare = new Uri(smallthumb, UriKind.Absolute)
                        };

                        return result;
                    }
                }
            }

            return null;
        }