/// <summary> /// 最新のまとめ記事より前のまとめ記事を読み込みます。 /// </summary> /// <returns>非同期操作を示す <see cref="System.Threading.Tasks.Task"/>。</returns> public Task LoadPreviousAsync() { this.Dispatcher.BeginInvoke(() => this.RaiseAsyncStarted()); var repository = new MatomeEntryRepository(); var max = this.Items.LastOrDefault(); return(repository.GetAsync(maxId: max == null ? (Guid?)null : max.EntryId) .ContinueWith( task => this.Dispatcher.BeginInvoke( parameter => { if (parameter != null) { this.Items.AddRangeIf(parameter.OrderByDescending(x => x.CreatedAt), x => x.CreatedAt); this.RaiseAsyncCompleted(); } else { this.RaiseAsyncError(null); } }, task.Result), TaskContinuationOptions.OnlyOnRanToCompletion) .ContinueWith( task => this.Dispatcher.BeginInvoke(() => this.RaiseAsyncError(task.Exception)), TaskContinuationOptions.NotOnRanToCompletion)); }
/// <summary> /// 最新のまとめ記事を読み込みます。 /// </summary> /// <returns>非同期操作を示す <see cref="System.Threading.Tasks.Task"/>。</returns> public Task LoadLatestAsync() { this.Dispatcher.BeginInvoke(() => this.RaiseAsyncStarted()); var repository = new MatomeEntryRepository(); return(repository.GetAsync() .ContinueWith( task => this.Dispatcher.BeginInvoke( parameter => { if (parameter != null) { this.Items.InsertRangeIf(0, parameter.OrderByDescending(x => x.CreatedAt), x => x.CreatedAt); this.RaiseAsyncCompleted(); } else { this.RaiseAsyncError(null); } }, task.Result), TaskContinuationOptions.OnlyOnRanToCompletion) .ContinueWith( task => this.Dispatcher.BeginInvoke(() => this.RaiseAsyncError(task.Exception)), TaskContinuationOptions.NotOnRanToCompletion)); }
/// <summary> /// <see cref="Karamem0.Kanpuchi.Services.MatomeEntryService"/> クラスの新しいインスタンスを初期化します。 /// </summary> private MatomeEntryService() { this.deviceRepository = new DeviceRepository(); this.settingsRepository = new SettingsRepository(); this.matomeEntryRepository = new MatomeEntryRepository(); }