static async Task <Calendar.Calendar> GetCalendarAsync(string url, Func <HttpClient> getClient = null)
        {
            try
            {
                var response = await ApiClient.GetRawAsync(url, getClient);

                if (!string.IsNullOrWhiteSpace(response))
                {
                    var calendar = Parser.FromString(response);
                    return(calendar);
                }
            }
            catch (Exception ex) when(DebugHelper.IsHandled <CalendarService>(ex))
            {
                // Do nothing...
            }

            return(await TaskCache <Calendar.Calendar> .Value(() => Empty));
        }
        async Task <IEnumerable <RawEmotion> > CaptureEmotionAsync()
        {
            RawEmotion[] result = null;

            try
            {
                var photoFile = await _photoService.CreateAsync();

                var imageProperties = ImageEncodingProperties.CreateBmp();
                await _mediaManager.CapturePhotoToStorageFileAsync(imageProperties, photoFile);

                result = await _emotionClient.RecognizeAsync(await photoFile.OpenStreamForReadAsync());
            }
            finally
            {
                await _photoService.CleanupAsync();
            }

            return(result.IsNullOrEmpty()
                ? await TaskCache <IEnumerable <RawEmotion> > .Value(() => Enumerable.Empty <RawEmotion>())
                : result);
        }
        async Task <IEnumerable <Calendar.Calendar> > ICalendarService.GetCalendarsAsync()
        {
            var settings = Settings.Instance;

            var getCalendarTasks =
                settings
                ?.Calendars
                ?.Select(
                    cal =>
                    Do.WithRetry(() =>
                                 GetCalendarAsync(cal.Url,
                                                  cal.IsUsingCredentials
                                               ? () => new HttpClient(new HttpClientHandler
            {
                Credentials =
                    new NetworkCredential(cal.Username, cal.Password)
            })
                                               : null as Func <HttpClient>)));

            return(getCalendarTasks?.Any() ?? false
                ? await Task.WhenAll(getCalendarTasks)
                : await TaskCache <Calendar.Calendar[]> .Value(() => new[] { Empty }));
        }