コード例 #1
0
        /// <summary>
        /// Loads the user profile data into the app.
        /// </summary>
        /// <param name="account">The user account.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task LoadUserData(Account account)
        {
            // Get the profile data from the Web application
            UserProfile userController = new UserProfile(account);

            try
            {
                User apiResponse = await userController.CallEndpointAsObjectAsync().ConfigureAwait(false);

                account.Username = apiResponse.Email;

                // TODO: remove when the OAuth introspection RFC is implemented

                /* AccountStore.Create(this.Context).Save(
                 *  account,
                 *  App.AppName); */

                App.OAuth2Account = account;
                App.User          = apiResponse;
                App.SuccessfulLogOnAction.Invoke();
            }
            catch (UnsuccessfulApiCallException)
            {
                App.LogOnApiCallErrorAction.Invoke();
            }
            catch (Exception e)
                when(e is JsonSerializationException || e is JsonReaderException)
                {
                    App.LogOnApiJsonExceptionAction.Invoke();
                }
        }