예제 #1
0
 private async void SingInout_Click(object sender, EventArgs e)
 {
     try
     {
         this.btnSingInout.Enabled = false;
         if (this.signedInuser != null)
         {
             ToolAuthentication.SignOut();
             this.signedInuser = null;
         }
         else
         {
             DevAccountSource accountSource = DevAccountSource.WindowsDevCenter;
             this.signedInuser = await ToolAuthentication.SignInAsync(accountSource, null);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error");
     }
     finally
     {
         this.UpdateAccountPanel();
         this.btnSingInout.Enabled = true;
     }
 }
예제 #2
0
        private static async Task <int> OnSignIn(SignInOptions signInOptions)
        {
            try
            {
                var devAccount = await ToolAuthentication.SignInAsync((DevAccountSource)signInOptions.AccountSource, signInOptions.UserName);

                Console.WriteLine($"Developer account {devAccount.Name} has successfully signed in.");
                DisplayDevAccount(devAccount, "\t");
                return(0);
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine("Error: signin failed");
                if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Unauthorized)))
                {
                    Console.WriteLine("Unable to authorize this account with Xbox Live. Please check your account.");
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }

                return(-1);
            }
        }
예제 #3
0
        /// <inheritdoc/>
        protected override void Process()
        {
            if (!Enum.TryParse(this.AccountSource, out AccountSourceOption source))
            {
                throw new ArgumentException("Invalid account source. Must be either 'WindowsDevCenter'.", nameof(this.AccountSource));
            }

            DevAccount devAccount = ToolAuthentication.SignInAsync((DevAccountSource)source, this.UserName).Result;

            this.WriteObject($"Developer account {devAccount.Name} has successfully signed in.");
            this.WriteObject(devAccount);
        }
 private async Task <DevAccount> SignInAsync(DevAccountSource accountSource, string userName)
 {
     return(await ToolAuthentication.SignInAsync(accountSource, userName, this.authMock.Object));
 }