本文整理汇总了C#中ReactiveList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.IndexOf方法的具体用法?C# ReactiveList.IndexOf怎么用?C# ReactiveList.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveList
的用法示例。
在下文中一共展示了ReactiveList.IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PullRequestsViewModel
public PullRequestsViewModel(IApplicationService applicationService)
{
PullRequests = new ReactiveList<PullRequestModel>();
GoToPullRequestCommand = ReactiveCommand.Create();
GoToPullRequestCommand.OfType<PullRequestModel>().Subscribe(pullRequest =>
{
var vm = CreateViewModel<PullRequestViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
vm.PullRequestId = pullRequest.Number;
vm.PullRequest = pullRequest;
vm.WhenAnyValue(x => x.PullRequest).Skip(1).Subscribe(x =>
{
var index = PullRequests.IndexOf(pullRequest);
if (index < 0) return;
PullRequests[index] = x;
PullRequests.Reset();
});
ShowViewModel(vm);
});
this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan());
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
{
var state = SelectedFilter == 0 ? "open" : "closed";
var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests.GetAll(state: state);
return PullRequests.SimpleCollectionLoad(request, t as bool?);
});
}
示例2: RecentViewModel
public RecentViewModel(Guid id, string metaDataSlug, IEnumerable<RecentItemViewModel> recentItems) {
_id = id;
RecentItems = new ReactiveList<RecentItemViewModel>(recentItems);
// TODO: This is a tab, and tabs are only active while shown
// but we want to receive these events regardless of being active or not, otherwise we are not uptodate when the user switches to us.
// Or we need to find a different approach!
Listen<ContentUsed>()
.Where(x => {
var contentId = GetId(x.Content);
lock (RecentItems)
return _id == x.Content.GameId && RecentItems.All(r => r.Id != contentId);
})
.Select(x => {
var ri = x.Content.MapTo<RecentItemViewModel>();
if (x.Token != null)
ri.UpdateExecute(x.Token);
return ri;
})
.ObserveOnMainThread()
.Subscribe(x => {
lock (RecentItems)
RecentItems.Insert(0, x);
});
Listen<RecentItemRemoved>()
.ObserveOnMainThread()
.Subscribe(x => {
lock (RecentItems) {
RecentItems.RemoveAll(r => r.Id == x.Content.Id);
}
});
// TODO: Stop manually moving, start auto sorting in View (ICollectionView or ReactiveDerivedCollection)...
// Then remove this event
Listen<ContentUsed>()
.Select(x => {
var contentId = GetId(x.Content);
lock (RecentItems)
return RecentItems.FirstOrDefault(r => r.Id == contentId);
})
.Where(x => x != null)
.ObserveOnMainThread()
.Subscribe(x => {
lock (RecentItems)
RecentItems.Move(RecentItems.IndexOf(x), 0);
});
AddContent =
ReactiveCommand.CreateAsyncTask(
async x => await RequestAsync(new OpenWebLink(ViewType.Browse, metaDataSlug)).ConfigureAwait(false));
this.WhenActivated(d => {
RefreshUpdated();
d(new TimerWithoutOverlap(TimeSpan.FromMinutes(1),
() => RxApp.MainThreadScheduler.Schedule(RefreshUpdated)));
});
}