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


C# ReplaySubject.CombineLatest方法代码示例

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


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

示例1: SettingsViewModel

        public SettingsViewModel(IBiometricsService biometricsService, IApplicationStateService applicationStateService, IBandService bandService, IShell shell)
        {
            Guard.NotNull(biometricsService, nameof(biometricsService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(bandService, nameof(bandService));

            this._biometricsService = biometricsService;
            this._applicationStateService = applicationStateService;
            this._bandService = bandService;
            this._shell = shell;

            var hasUser = new ReplaySubject<bool>(1);
            hasUser.OnNext(this._applicationStateService.GetCurrentUser() != null);
            var deviceAvailable = this._biometricsService.BiometricAuthDeviceIsAvailableAsync().ToObservable();
            var canRememberLogin = hasUser.CombineLatest(deviceAvailable, (hasUsr, deviceAvail) => hasUsr && deviceAvail);
            this.RememberLogin = UwCoreCommand.Create(canRememberLogin, this.RememberLoginImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.RememberedLogin"))
                .HandleExceptions()
                .TrackEvent("SetupRememberLogin");

            var canToggleTile = this.WhenAnyValue(f => f.State, state => state != BandState.NotConnected);
            this.ToggleBandTile = UwCoreCommand.Create(canToggleTile, this.ToggleTileImpl)
                .ShowLoadingOverlay(() => this.State == BandState.Installed
                    ? CTime2Resources.Get("Loading.RemoveTileFromBand")
                    : CTime2Resources.Get("Loading.AddTileToBand"))
                .HandleExceptions()
                .TrackEvent("ToggleBandTile");

            this.Reload = UwCoreCommand.Create(this.ReloadImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.Settings"))
                .HandleExceptions()
                .TrackEvent("ReloadSettings");

            this.Theme = this._applicationStateService.GetApplicationTheme();
            this.SelectedWorkTime = this._applicationStateService.GetWorkDayHours();
            this.SelectedBreakTime = this._applicationStateService.GetWorkDayBreak();
            this.CompanyId = this._applicationStateService.GetCompanyId();

            this.WhenAnyValue(f => f.Theme)
                .Subscribe(theme =>
                {
                    this._shell.Theme = theme;
                    this._applicationStateService.SetApplicationTheme(theme);
                });

            this.WhenAnyValue(f => f.SelectedWorkTime)
                .Subscribe(workTime =>
                {
                    this._applicationStateService.SetWorkDayHours(workTime);
                });

            this.WhenAnyValue(f => f.SelectedBreakTime)
                .Subscribe(breakTime =>
                {
                    this._applicationStateService.SetWorkDayBreak(breakTime);
                });

            this.WhenAnyValue(f => f.CompanyId)
                .Subscribe(companyId =>
                {
                    this._applicationStateService.SetCompanyId(companyId);
                });

            this.DisplayName = CTime2Resources.Get("Navigation.Settings");

            this.WorkTimes = new ReactiveList<TimeSpan>(Enumerable
                .Repeat((object)null, 4 * 24)
                .Select((_, i) => TimeSpan.FromHours(0.25 * i)));

            this.BreakTimes = new ReactiveList<TimeSpan>(Enumerable
                .Repeat((object)null, 4 * 24)
                .Select((_, i) => TimeSpan.FromHours(0.25 * i)));
        }
开发者ID:haefele,项目名称:CTime2,代码行数:73,代码来源:SettingsViewModel.cs


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