コード例 #1
0
        private static async Task GetContactDataAsync(string email)
        {
            IFullContactApi api = new FullContactApi(); // Dependency injection here, in a full implementation.

            try
            {
                var fullContactPerson = await api.LookupPersonByEmailAsync(email);

                if (fullContactPerson == null)
                {
                    Console.WriteLine("No contact info found.");
                }
                else
                {
                    Output(fullContactPerson);
                }
            }
            catch (HttpRequestException)
            {
                //Handel exception
                Console.WriteLine("Friendly error message.");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Xgor/FullContact
        static async Task MainAsync(string[] args)
        {
            int    i      = 0;
            string choice = "y";

            while (choice[0] == 'y')
            {
                Console.Write("Enter E-mail: ");



                string         email  = Console.ReadLine();
                FullContactApi search = new FullContactApi();

                Task <FullContactPerson> task = search.LookupPersonByEmailAsync(email);
                Console.Write("Loading email");
                CursorTopLoad = Console.CursorTop + 1;

                Timer timer = new Timer(50);
                timer.Elapsed += async(sender, e) => await WriteLoadingSpinner();

                timer.Start();
                timerOn = true;


                FullContactPerson p = await task;
                timer.Stop();
                timerOn = false;
                Console.WriteLine("\nMail Loaded!");
                search.printLatestPersonInfo();

                Console.WriteLine("Want to check another mail (y/n)");
                choice = Console.ReadLine();
                //          Console.Clear();
            }
        }