当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveList.Select方法代码示例

本文整理汇总了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())));
        }
开发者ID:gfdittmer,项目名称:MiSharp,代码行数:15,代码来源:AlbumViewModel.cs

示例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());
            });
	    }
开发者ID:runt18,项目名称:CodeHub,代码行数:30,代码来源:IssueLabelsViewModel.cs

示例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";
        }
开发者ID:niik,项目名称:RxSpy,代码行数:34,代码来源:RxSpyObservableModel.cs

示例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());
            });
	    }
开发者ID:zdd910,项目名称:CodeHub,代码行数:33,代码来源:IssueLabelsViewModel.cs

示例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?));
	    }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:45,代码来源:IssueLabelsViewModel.cs


注:本文中的ReactiveList.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。