예제 #1
0
        /// <summary>
        /// Handles the Loaded event of the AuthPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void AuthPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.Frame.BackStack.Clear();

            OAuthToken token = null;

            if (this.PageArguments.State == Arguments.States.UnAuthenticated ||
                (this.PageArguments.State == Arguments.States.Authenticated &&
                 !OAuthToken.TryGetValue(out token)))
            {
                this.LaunchBrowser();
            }
            else if (this.PageArguments.State == Arguments.States.Authenticating)
            {
                token = OAuthClient.Instance.GetAccessToken(this.PageArguments.AutheticationPayload);
                if (token == null && !OAuthToken.TryGetValue(out token))
                {
                    throw new InvalidOperationException("Unable to authenticate with the provided token payload.");
                }
            }

            if (token != null)
            {
                this.Frame.Navigate(typeof(MainPage), new MainPage.Arguments(this.PageArguments.LaunchArguments));
            }
        }