private async void ValidateKey() { if (apiKeyFormat.IsMatch(txtApiKey.Text)) { txtApiKey.IsEnabled = false; var connection = new Connection(txtApiKey.Text); var client = new Gw2Client(connection); var tokeninfo = await client.WebApi.V2.TokenInfo.GetAsync(); var hasAccount = false; var hasCharacters = false; var hasGuilds = false; //Set all to bad imgAccount.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444524.png")); imgCharacters.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444524.png")); imgGuilds.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444524.png")); //Check Permissions if (HasPermission(tokeninfo, TokenPermission.Account)) { hasAccount = true; imgAccount.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444520.png")); } if (HasPermission(tokeninfo, TokenPermission.Characters)) { hasCharacters = true; imgCharacters.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444520.png")); } if (HasPermission(tokeninfo, TokenPermission.Guilds)) { hasGuilds = true; imgGuilds.Source = new BitmapImage(new Uri("pack://application:,,,/Assets/1444520.png")); } ValidKey = (hasAccount && hasCharacters && hasGuilds); client.Dispose(); txtApiKey.IsEnabled = true; } }
public void Dispose() { _client.Dispose(); }