本文整理汇总了C#中ReactiveList.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.Select方法的具体用法?C# ReactiveList.Select怎么用?C# ReactiveList.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveList
的用法示例。
在下文中一共展示了ReactiveList.Select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AlbumViewModel
public AlbumViewModel(Album album)
{
_events = IoC.Get<IEventAggregator>();
_windowManager = IoC.Get<IWindowManager>();
Model = album;
Tracks = new ReactiveList<TrackViewModel>();
Tracks.AddRange(album.Tracks.Select(x => new TrackViewModel(x)));
AddAlbumToPlaylistCommand = new ReactiveCommand();
AddAlbumToPlaylistCommand.Subscribe(param => _events.Publish(Tracks.Select(x => x.Track).ToList()));
EditorEditAlbumsCommand = new ReactiveCommand();
EditorEditAlbumsCommand.Subscribe(
param => _windowManager.ShowDialog(new AlbumTagEditorViewModel(Tracks.Select(x => x.Track.Model).ToList())));
}
示例2: IssueLabelsViewModel
public IssueLabelsViewModel(
Func<Task<IReadOnlyList<Label>>> loadAllLabelsFunc,
Func<Task<IReadOnlyList<Label>>> loadSelectedFunc,
Func<IEnumerable<Label>, Task> saveLabelsFunc)
{
var labels = new ReactiveList<Label>();
var selected = new ReactiveList<Label>();
Labels = labels.CreateDerivedCollection(x =>
{
var vm = new IssueLabelItemViewModel(x);
vm.IsSelected = selected.Any(y => y.Url == x.Url);
return vm;
});
SaveCommand = ReactiveCommand.CreateAsyncTask(_ =>
{
var currentlySelected = Labels.Where(x => x.IsSelected).ToList();
var selectedLabelsUrl = currentlySelected.Select(x => x.Label.Url).ToArray();
var prevSelectedLabelsUrl = selected.Select(x => x.Url).ToArray();
var intersect = selectedLabelsUrl.Intersect(prevSelectedLabelsUrl).ToArray();
var different = selectedLabelsUrl.Length != prevSelectedLabelsUrl.Length || intersect.Length != selectedLabelsUrl.Length;
return different ? saveLabelsFunc(currentlySelected.Select(x => x.Label)) : Task.FromResult(0);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
selected.Clear();
selected.AddRange((await loadSelectedFunc()) ?? Enumerable.Empty<Label>());
labels.Reset(await loadAllLabelsFunc());
});
}
示例3: RxSpyObservableModel
public RxSpyObservableModel(IOperatorCreatedEvent createdEvent)
{
Id = createdEvent.Id;
Name = createdEvent.Name;
OperatorMethod = createdEvent.OperatorMethod;
CallSite = createdEvent.CallSite;
IsActive = true;
Created = TimeSpan.FromMilliseconds(createdEvent.EventTime);
Subscriptions = new ReactiveList<RxSpySubscriptionModel>();
Parents = new ReactiveList<RxSpyObservableModel>();
Children = new ReactiveList<RxSpyObservableModel>();
ObservedValues = new ReactiveList<RxSpyObservedValueModel>();
this.WhenAnyValue(x => x.Error)
.Select(x => x == null ? false : true)
.ToProperty(this, x => x.HasError, out _hasError);
this.WhenAnyValue(x => x.Children.Count)
.Select(_ => Observable.CombineLatest(Children.Select(c => c.WhenAnyValue(x => x.Descendants))))
.Switch()
.Select(x => x.Sum() + Children.Count)
.ToProperty(this, x => x.Descendants, out _descendants);
this.WhenAnyValue(x => x.Parents.Count)
.Select(_ => Observable.CombineLatest(Parents.Select(c => c.WhenAnyValue(x => x.Ancestors))))
.Switch()
.Select(x => x.Sum() + Parents.Count)
.ToProperty(this, x => x.Ancestors, out _ancestors);
Status = "Active";
}
示例4: IssueLabelsViewModel
public IssueLabelsViewModel(Func<Task<IReadOnlyList<Label>>> loadLabels)
{
var labels = new ReactiveList<Label>();
Selected = new ReactiveList<Label>();
Labels = labels.CreateDerivedCollection(x =>
{
var vm = new IssueLabelItemViewModel(x);
vm.IsSelected = Selected.Any(y => string.Equals(y.Name, x.Name));
// vm.GoToCommand
// .Select(_ => x)
// .Where(y => vm.IsSelected)
// .Where(y => Selected.All(l => l.Url != y.Url))
// .Subscribe(Selected.Add);
// vm.GoToCommand
// .Select(_ => x)
// .Where(y => !vm.IsSelected)
// .Select(y => Selected.Where(l => l.Url == y.Url).ToArray())
// .Subscribe(Selected.RemoveAll);
return vm;
});
SelectLabelsCommand = ReactiveCommand.CreateAsyncTask(t => {
var selectedLabelsUrl = Selected.Select(x => x.Url).ToArray();
var prevSelectedLabelsUrl = _previouslySelectedLabels.Select(x => x.Url).ToArray();
var intersect = selectedLabelsUrl.Intersect(prevSelectedLabelsUrl).ToArray();
var different = selectedLabelsUrl.Length != prevSelectedLabelsUrl.Length || intersect.Length != selectedLabelsUrl.Length;
return Task.FromResult(0); //different ? updateIssue(new ReadOnlyCollection<Label>(Selected)) : Task.FromResult(0);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
labels.Reset(await loadLabels());
});
}
示例5: IssueLabelsViewModel
public IssueLabelsViewModel(IApplicationService applicationService)
{
Labels = new ReactiveCollection<LabelModel>();
SelectedLabels = new ReactiveList<LabelModel>();
SelectLabelsCommand = new ReactiveCommand();
SelectLabelsCommand.RegisterAsyncTask(async t =>
{
var selectedLabels = t as IEnumerable<LabelModel>;
if (selectedLabels != null)
SelectedLabels.Reset(selectedLabels);
//If nothing has changed, dont do anything...
if (OriginalLabels != null && OriginalLabels.Count() == SelectedLabels.Count() &&
OriginalLabels.Intersect(SelectedLabels).Count() == SelectedLabels.Count())
{
DismissCommand.ExecuteIfCan();
return;
}
if (SaveOnSelect)
{
try
{
var labels = (SelectedLabels != null && SelectedLabels.Count > 0)
? SelectedLabels.Select(y => y.Name).ToArray() : null;
var updateReq =
applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId]
.UpdateLabels(labels);
await applicationService.Client.ExecuteAsync(updateReq);
}
catch (Exception e)
{
throw new Exception("Unable to save labels! Please try again.", e);
}
}
DismissCommand.ExecuteIfCan();
});
LoadCommand.RegisterAsyncTask(t =>
Labels.SimpleCollectionLoad(
applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Labels.GetAll(),
t as bool?));
}