Imgur.FormSettings.buttonAuthenticate_Click C# (CSharp) Method

buttonAuthenticate_Click() private method

private buttonAuthenticate_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void buttonAuthenticate_Click(object sender, EventArgs e)
        {
            if (this.buttonAuthenticate.Text == "Authenticate") {
                this.mainClass.oauth.Authorize();

                if (this.mainClass.oauth.AccessToken != "") {
                    this.mainClass.authenticated = true;

                    string result = this.mainClass.oauth.AuthenticatedWebClient().DownloadString("https://" + "api.imgur.com/2/account");
                    XmlReader resultReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(result)));

                    while (resultReader.Read()) {
                        switch (resultReader.NodeType) {
                            case XmlNodeType.Element:
                                switch (resultReader.Name) {
                                    case "url":
                                        resultReader.Read();
                                        this.mainClass.username = resultReader.Value;
                                        break;

                                    case "is_pro":
                                        resultReader.Read();
                                        this.mainClass.isPro = bool.Parse(resultReader.Value);
                                        break;
                                }
                                break;
                        }
                    }
                }
            } else {
                this.mainClass.authenticated = false;
                this.mainClass.username = "";
                this.mainClass.isPro = false;
                this.mainClass.oauth.AccessToken = "";
                this.mainClass.oauth.AccessTokenSecret = "";

                this.buttonAuthenticate.Text = "Authenticate";
            }

            AuthedMessage();
        }