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


C# IObservable.SelectMany方法代码示例

本文整理汇总了C#中IObservable.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.SelectMany方法的具体用法?C# IObservable.SelectMany怎么用?C# IObservable.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObservable的用法示例。


在下文中一共展示了IObservable.SelectMany方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LongPressAsObservable

 private static IObservable<KeyAndState> LongPressAsObservable(IObservable<KeyAndState> press, IObservable<KeyAndState> release, TimeSpan delay, IScheduler scheduler)
 {
     return press.SelectMany(
         pressed =>
         Observable
             .Return(pressed)
             .Delay(delay, scheduler)
             .TakeUntil(release.Where(released => pressed.Key == released.Key)));
 }
开发者ID:HaKDMoDz,项目名称:shooter,代码行数:9,代码来源:ReactiveKeyboardExtensions.cs

示例2: OrganizationTileViewModel

        public OrganizationTileViewModel(GitHubOrgInfo model, IObservable<List<GitHubRepo>> repositories)
        {
            Model = model;
            Repositories = new ReactiveCollection<RepoTileViewModel>();

            repositories
                .SelectMany(x => x.ToObservable())
                .ObserveOn(RxApp.DeferredScheduler)
                .Where(x => model.login == x.owner.login)
                .Subscribe(x => Repositories.Add(new RepoTileViewModel() { Model = x }));
        }
开发者ID:jaohaohsuan,项目名称:ReactiveUI.Sample,代码行数:11,代码来源:RepoSelectionViewModel.cs

示例3: downloadAnalyses

        public IObservable<Unit> downloadAnalyses(IObservable<IdentificationUnit> unit_future)
        {
            var insertion_future =
                unit_future
                    .SelectMany(iu => Service.GetAnalysesForIU(iu.CollectionUnitID.Value).SelectMany(ans => ans)
                        .Do(an =>
                        {
                            an.UnitID = iu.UnitID;
                            Storage.add(an);
                        })
                    )
                    .Select(_ => Unit.Default)
                    .Replay()
                    .RefCount();

            return insertion_future;
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:17,代码来源:EventHierarchyLoader.cs

示例4: downloadUnits

        public IObservable<IdentificationUnit> downloadUnits(IObservable<Specimen> specimen_future)
        {
            var insertion_future =
                specimen_future
                .SelectMany(spec => Service.GetIdentificationUnitsForSpecimen(spec.CollectionSpecimenID.Value)
                    .Select(ius =>
                    {
                        var unitList = ius.ToList();
                        foreach (var iu in unitList)
                        {
                            iu.SpecimenID = spec.SpecimenID;
                        }

                        return unitList;
                    })
                    .Select(ius => ius.ToLookup(iu => iu.RelatedUnitID))
                    .SelectMany(tree => insertUnitsHierarchical(tree).ToObservable(ThreadPool))
                ).Replay()
                .RefCount();

            return insertion_future;
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:22,代码来源:EventHierarchyLoader.cs

示例5: downloadSpecimen

        public IObservable<Specimen> downloadSpecimen(IObservable<Event> event_future)
        {
            var insertion_future =
                event_future
                .SelectMany(ev => Service.GetSpecimenForEvent(ev.CollectionEventID.Value)
                    .SelectMany(specimen => specimen.ToObservable(ThreadPool))
                )
                .CombineLatest(event_future,
                    (spec, ev) =>
                    {
                        spec.EventID = ev.EventID;
                        Storage.add(spec);
                        return spec;
                    }).Replay()
                    .RefCount();

            return insertion_future;
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:18,代码来源:EventHierarchyLoader.cs

示例6: downloadProperties

        public IObservable<Unit> downloadProperties(IObservable<Event> event_future)
        {
            var insertion_future =
            event_future
                .SelectMany(ev => Service.GetEventProperties(ev.CollectionEventID.Value)
                    .Do(props =>
                    {
                        foreach (var prop in props)
                        {
                            prop.EventID = ev.EventID;
                            Storage.add(prop);
                        }
                    })
                )
                .Select(_ => Unit.Default)
                .Replay()
                .RefCount();

            return insertion_future;
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:20,代码来源:EventHierarchyLoader.cs

示例7: ModificationViewModel

        public ModificationViewModel(IScreen screen, ICredentialStore store, IObservable<RepositoryModel> repository)
        {
            this.disposables = new List<IDisposable>();
            this.fileSystem = new FileSystemObservable();

            this.refreshCommand = ReactiveCommand.Create();

            var samples =
                Observable.Interval(TimeSpan.FromSeconds(60))
                .Select(i => new object())
                .Merge(this.refreshCommand.Select(i => new object()))
                .Merge(repository.Delay(TimeSpan.FromSeconds(1)).Select(i => new object()));

            var distinctRepository = repository.DistinctUntilChanged(r => r.Path);

            distinctRepository.MapToMember(this, vm => vm.currentRepositoryModel);
            distinctRepository.Select(_ => _.Path).MapToMember(this, vm => vm.fileSystem.Path);

            var activeBranch = repository
                .SelectMany(rm => rm.WhenAny(vm => vm.CurrentBranch, change => change.GetValue()))
                .SampleEx(samples);

            activeBranch
                .ObserveOn(System.Reactive.Concurrency.TaskPoolScheduler.Default)
                .SubscribeOn(System.Reactive.Concurrency.TaskPoolScheduler.Default)
                .Subscribe(branch =>
                {
                    if (branch.IsTracking)
                    {
                        //Fetch repository status.
                        var currentRemote = branch.Remote;

                        var refSpecs = this.currentRepositoryModel.Repository.Network.Remotes.Select(r =>
                                    new
                                    {
                                        FetchRefSpecs = r.FetchRefSpecs
                                                            .Where(frs => frs.Direction == RefSpecDirection.Fetch)
                                                            .Select(frs => frs.Specification),
                                        Remote = r
                                    }
                                );
                        var credentialProvider = new CredentialProvider(screen, store);

                        foreach (var item in refSpecs)
                        {
                            FetchOptions options = new FetchOptions() { CredentialsProvider = credentialProvider.CredentialHandler };
                            try
                            {
                                this.currentRepositoryModel.Repository.Network.Fetch(item.Remote, item.FetchRefSpecs, options);
                            }
                            catch { }
                        }
                    }
                });

            activeBranch
                .Select(b => b.TrackingDetails).Subscribe(_ =>
                {
                    this.Ahead = (_.AheadBy.HasValue) ? _.AheadBy.Value : 0;
                    this.Behind = (_.BehindBy.HasValue) ? _.BehindBy.Value : 0;
                });

            var activeBranchFileStatus =
                activeBranch.AnonymousMerge(fileSystem, 0)
                .AnonymousMerge(this.refreshCommand.AsObservable(), 0)
                .Throttle(TimeSpan.FromSeconds(5))
                .Select(branch =>
                {
                    var opts = new LibGit2Sharp.StatusOptions();

                    opts.DetectRenamesInIndex = true;
                    opts.DetectRenamesInWorkDir = true;
                    opts.Show = StatusShowOption.IndexAndWorkDir;

                    return this.currentRepositoryModel.Repository.RetrieveStatus(opts);
                });

            this.files = new DeltaViewModel<int>
            (
                activeBranchFileStatus.Select(s => s.Modified.Count()),
                activeBranchFileStatus.Select(s => s.Added.Count() + s.Untracked.Count()),
                activeBranchFileStatus.Select(s => s.Removed.Count())
            );

            ConfigureLineChanges(activeBranch);

            ConfigureCommitCommands();

            this.thresholds = new Thresholds(
                this.ObservableForProperty(vm => vm.Behind, false, false).Select(change => change.GetValue()),
                this.ObservableForProperty(vm => vm.Ahead).Select(change => change.GetValue()),
                this.ObservableForProperty(vm => vm.LinesAdded).Select(change => change.GetValue()),
                this.ObservableForProperty(vm => vm.LinesRemoved).Select(change => change.GetValue()),
                this.Files.ObservableForProperty(vm => vm.Added).Select(change => change.GetValue()),
                this.Files.ObservableForProperty(vm => vm.Removed).Select(change => change.GetValue()));
        }
开发者ID:abbottdev,项目名称:gitreminder,代码行数:96,代码来源:ModificationViewModel.cs

示例8: Start

	void Start () {
		rx_valid_data = rx_data.Where(data=>data != null);
		adapter.register_input_float(target, rx_valid_data.SelectMany(d=>d.rx_target), (value)=>{ //Target
			if (data != null)
				data.target = value;
		}).register_toggle(lower_limit, rx_valid_data.SelectMany(d=>d.rx_limit_lower), (value)=>{ //Lower Limit
			if (data != null)
				data.limit_lower = value;
		}).register_toggle(upper_limit, rx_valid_data.SelectMany(d=>d.rx_limit_upper), (value)=>{ //Upper Limit
			if (data != null)
				data.limit_upper = value;
		}).register_input_float(min_accept, rx_valid_data.SelectMany(d=>d.rx_min_accept), (value)=>{ //Min Accept
			if (data != null)
				data.min_accept = value;
		}).register_input_float(max_accept, rx_valid_data.SelectMany(d=>d.rx_max_accept), (value)=>{ //Max Accept
			if (data != null)
				data.max_accept = value;
		}).register_input_float(min_close, rx_valid_data.SelectMany(d=>d.rx_min_close), (value)=>{ //Min Close
			if (data != null)
				data.min_close = value;
		}).register_input_float(max_close, rx_valid_data.SelectMany(d=>d.rx_max_close), (value)=>{ //Max Close
			if (data != null)
				data.max_close = value;
		}).register_input_float(flat_bonus, rx_valid_data.SelectMany(d=>d.rx_flat_bonus), (value)=>{ //Flat Bonus
			if (data != null)
				data.flat_bonus = value;
		}).register_input_float(flat_penalty, rx_valid_data.SelectMany(d=>d.rx_flat_penalty), (value)=>{ //Flat Penalty
			if (data != null)
				data.flat_penalty = value;
		}).register_input_float(range_bonus, rx_valid_data.SelectMany(d=>d.rx_max_close), (value)=>{ //Range Bonus
			if (data != null)
				data.range_bonus = value;
		}).register_input_float(range_penalty, rx_valid_data.SelectMany(d=>d.rx_max_close), (value)=>{ //Range Penalty
			if (data != null)
				data.range_penalty = value;
		});
		rx_valid_data.SelectMany(d=>d.rx_is_limited)
		.DistinctUntilChanged().Subscribe((limited)=>{
			if (hide_when_unlimited != null)
				hide_when_unlimited.visible = limited;
		});
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:42,代码来源:ScoreTargetUI.cs


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