示例#1
0
        /// <summary>
        /// Gets an account from the existing ones.
        /// </summary>
        /// <returns></returns>
        public static Account GetAccount( )
        {
            Console.WriteLine("What email address should we use to search for local accounts?");
            var email = Console.ReadLine();

            try
            {
                return(LocalContext.GetDefaultAccount());
            }
            catch
            {
                var accounts = LocalContext.GetAccountsByEmail(email);
                if (accounts.Count == 0)
                {
                    Console.WriteLine("No account found. Please try again!");
                    return(GetAccount());
                }

                Console.WriteLine(String.Format("Found {0} accounts. Which one should we use? (0 - {0})", accounts.Count));
                int i = 0;
                foreach (var acc in accounts)
                {
                    Console.WriteLine(String.Format("{0} : {1} at {2}", i++, acc.Email, acc.RestApi));
                }

                var selIndex = System.Convert.ToInt32(Console.ReadLine());
                return(accounts[selIndex]);
            }
        }