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


C# IObservable.DistinctUntilChanged方法代码示例

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


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

示例1: register_slider

	public RxUIAdapter register_slider(Slider slider, IObservable<float> rx_get, Action<float> rx_set){
		subscriptions.Add(
			rx_get
				.DistinctUntilChanged()
				.Subscribe ((value) => {
					slider.value = value;
		}));
		slider.OnValueChangedAsObservable().Subscribe(rx_set);
		return this;
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:10,代码来源:RxUIAdapter.cs

示例2: register_toggle

	public RxUIAdapter register_toggle(Toggle toggle, IObservable<bool> rx_get, Action<bool> rx_set){
		subscriptions.Add(
			rx_get
				.DistinctUntilChanged()
				.Subscribe ((value) => {
					toggle.isOn = value;
		}));
		subscriptions.Add(toggle.OnValueChangedAsObservable().Subscribe(rx_set));
		return this;
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:10,代码来源:RxUIAdapter.cs

示例3: ObservableCommand

        public ObservableCommand(IObservable<bool> canExecute)
        {
            canExecute
                .DistinctUntilChanged()
                .Subscribe(x =>
                {
                    _canExecute = x;

                    CanExecuteChanged.SafeInvoke(this);
                });

            _canExecute = false;
        }
开发者ID:ganesum,项目名称:Naru,代码行数:13,代码来源:ObservableCommand.cs

示例4: register_input_float

	public RxUIAdapter register_input_float(InputField field, IObservable<float> rx_get, Action<float> rx_set){
		subscriptions.Add(
			rx_get
				.DistinctUntilChanged()
				.Subscribe ((value) => {
					field.text = value.ToString();
		}));
		subscriptions.Add(
			field.OnValueChangeAsObservable()
				.Where(text=>{
					float sink; //No pun intended.
					return float.TryParse(text, out sink);
				}).Select(text=>float.Parse(text))
				.Subscribe(rx_set));
		return this;
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:16,代码来源:RxUIAdapter.cs

示例5: AddObservable

        /// <summary>
        /// Adds the observable to the CombinedObservationState
        /// </summary>
        /// <param name="observableToAdd">The ObservationState observable.</param>
        public void AddObservable(IObservable<ObservationState> observableToAdd)
        {
            if (_combinedObservationStateObservableHelperSubscription != null)
                _combinedObservationStateObservableHelperSubscription.Dispose();

            //Combine the last _combinedObservationStateObservableHelper with the new observableToAdd
            _combinedObservationStateObservableHelper = _combinedObservationStateObservableHelper.CombineLatest(observableToAdd,
                           (a, b) =>
                           {
                               //If any of the states are active, return true
                               var state = a == ObservationState.Active || b == ObservationState.Active
                                               ? ObservationState.Active
                                               : ObservationState.Suspended;
                               return state;  //Return the combined state
                           });

            //Whenever the _lastCombinedObservationStateObservable updates, update the _combinedObservationStateObservable
            _combinedObservationStateObservableHelperSubscription = 
                _combinedObservationStateObservableHelper.DistinctUntilChanged().Subscribe(t => _combinedObservationStateObservable.OnNext(t));
        }
开发者ID:FoundOPS,项目名称:server,代码行数:24,代码来源:ObservationState.cs

示例6: 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


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