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


C# ObservableAsPropertyHelper类代码示例

本文整理汇总了C#中ObservableAsPropertyHelper的典型用法代码示例。如果您正苦于以下问题:C# ObservableAsPropertyHelper类的具体用法?C# ObservableAsPropertyHelper怎么用?C# ObservableAsPropertyHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: OAPHShouldRethrowErrors

        public void OAPHShouldRethrowErrors()
        {
            var input = new Subject<int>();
            var sched = new TestScheduler();

            var fixture = new ObservableAsPropertyHelper<int>(input,
                _ => { }, -5, sched);

            Assert.AreEqual(-5, fixture.Value);
            (new[] { 1, 2, 3, 4 }).Run(x => input.OnNext(x));

            sched.Run();

            Assert.AreEqual(4, fixture.Value);

            input.OnError(new Exception("Die!"));

            sched.Run();

            try {
                Assert.AreEqual(4, fixture.Value);
            } catch {
                return;
            }
            Assert.Fail("We should've threw there");
        }
开发者ID:charles-cai,项目名称:ReactiveXaml,代码行数:26,代码来源:ObservableAsPropertyHelperTest.cs

示例2: LoginRouteViewModel

 public LoginRouteViewModel(IScreen hostScreen)
 {
     HostScreen = hostScreen;
     var authentication = new Authentication();
     var canLogin = this.WhenAny(x => x.LoginName,
         x => x.Password,
         (l, p) => !String.IsNullOrWhiteSpace(l.Value) && !String.IsNullOrWhiteSpace(p.Value));
     LoginCommand = new ReactiveCommand(canLogin);
     var loggedIn = LoginCommand.RegisterAsync(_ => Observable.Start(() =>
     {
         var authenticationResult = authentication.AuthenticateAsync(LoginName,
             Password).
                                                   Result;
         return authenticationResult == AuthenticationResult.Authenticated
             ? "Přihlášen"
             : "Nepřihlášen";
     }));
     loggedIn.Subscribe(s =>
     {
         if (s == "Přihlášen")
             HostScreen.Router.Navigate.Execute(new PersonListViewModel(HostScreen));
     });
     message = new ObservableAsPropertyHelper<string>(loggedIn,
         s => raisePropertyChanged("Message"));
 }
开发者ID:jiravanet,项目名称:Prezentace-ReactiveUI,代码行数:25,代码来源:LoginRouteViewModel.cs

示例3: CountryViewModel

 public CountryViewModel(string name, float population, Task<IBitmap> countryFlag, double longitude, double latitude)
     : base(name, population, longitude, latitude)
 {
     this.countryFlag = countryFlag
         .ToObservable()
         .ToProperty(this, x => x.CountryFlag);
 }
开发者ID:dotnetcurry,项目名称:wpf-items-control,代码行数:7,代码来源:MainWindow.xaml.cs

示例4: IndexViewModel

        public IndexViewModel(IRepository repo)
        {
            this.repo = repo;
            this.refreshCommand = ReactiveCommand.Create();

            this.repositoryStatus = this.refreshCommand.Select(u =>
            {
                return repo.RetrieveStatus(new StatusOptions() { Show = StatusShowOption.IndexAndWorkDir });
            }).ToProperty(this, vm => vm.RepositoryStatus);

            this.statusEntries = this
                .WhenAny(vm => vm.RepositoryStatus, change =>
                {
                    var status = change.GetValue();

                    return status.CreateDerivedCollection(s => s, null, null, null, this.refreshCommand);
                }).ToProperty(this, vm => vm.StatusEntries);

            var resetSignal = this.WhenAny(vm => vm.StatusEntries, change =>
             {
                 return 0;
             });

            var allEntries = this.WhenAny(vm => vm.StatusEntries, change => change.GetValue());

            this.unstagedEntries = allEntries.Select(s =>
            {
                return s.CreateDerivedCollection(i => i, i => Unstaged(i.State), null, resetSignal);
            }).ToProperty(this, vm => vm.UnstagedEntries);

            this.stagedEntries = allEntries.Select(s =>
            {
                return s.CreateDerivedCollection(i => i, i => Staged(i.State), null, resetSignal);
            }).ToProperty(this, vm => vm.StagedEntries);
        }
开发者ID:abbottdev,项目名称:gitreminder,代码行数:35,代码来源:IndexViewModel.cs

示例5: MainViewModel

        public MainViewModel()
        {
            _multiEngine = this.ObservableToProperty(
                Engines.Changed.Select(_ => Engines.Count > 1),
                vm => vm.MultiEngine);
            _singleEngine = this.ObservableToProperty(
                Engines.Changed.Select(_ => Engines.Count == 1),
                vm => vm.SingleEngine);
            _languages = this.ObservableToProperty(
                this.ObservableForProperty(vm => vm.SelectedEngine)
                    .Select(_ => SelectedEngine.Value.Languages),
                vm => vm.Languages);
            _languages.Subscribe(_ => EnsureLanguage());
            Engines.Changed.Subscribe(_ => EnsureEngine());

            Observable.Merge(
                this.ObservableForProperty(vm => vm.DesignTimeMode).IgnoreValues(),
                this.ObservableForProperty(vm => vm.SelectedEngine).IgnoreValues(),
                this.ObservableForProperty(vm => vm.SelectedLanguage).IgnoreValues(),
                this.ObservableForProperty(vm => vm.RazorCode).IgnoreValues())
                .ObserveOn(RxApp.DeferredScheduler)
                .Subscribe(_ => Regenerate());

            this.PropertyChanged += MainViewModel_PropertyChanged;
        }
开发者ID:Kathy2013,项目名称:RazorSpy,代码行数:25,代码来源:MainViewModel.cs

示例6: VisualTreeViewModel

 public VisualTreeViewModel(Control root)
 {
     Nodes = VisualTreeNode.Create(root);
     _details = this.WhenAnyValue(x => x.SelectedNode)
         .Select(x => x != null ? new ControlDetailsViewModel(x.Control) : null)
         .ToProperty(this, x => x.Details);
 }
开发者ID:Arlorean,项目名称:Perspex,代码行数:7,代码来源:VisualTreeViewModel.cs

示例7: MiniMainWindowViewModel

        public MiniMainWindowViewModel(ITrayMainWindowViewModel trayMainWindowViewModel) {
            TrayViewModel = trayMainWindowViewModel;
            _taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.TrayViewModel.Status,
                trayMainWindowViewModel.FormatTaskbarToolTip)
                .ToProperty(this, x => x.TaskbarToolTip);
            OpenPopup = ReactiveCommand.Create();
            ShowNotification = ReactiveCommand.CreateAsyncTask(async x => (ITrayNotificationViewModel) x);
            Deactivate = ReactiveCommand.Create().DefaultSetup("Deactivate");
            Deactivate.Subscribe(x => {
                if (TrayViewModel.MainArea is IWelcomeViewModel)
                    return;
                Close.Execute(null);
            });

            OpenPopup
                .Take(1)
                .Delay(TimeSpan.FromSeconds(20))
                .ObserveOnMainThread()
                .Subscribe(x => TrayViewModel.RemoveUpdatedState());

            // TODO: Make this a setting?
            /*            Listen<ApiUserActionStarted>()
                .ObserveOnMainThread()
                .InvokeCommand(OpenPopup);*/
            Listen<AppStateUpdated>()
                .Where(x => x.UpdateState == AppUpdateState.Updating)
                .ObserveOnMainThread()
                .InvokeCommand(OpenPopup);
            Listen<ShowTrayNotification>()
                .Select(x => new TrayNotificationViewModel(x.Subject, x.Text, x.CloseIn, x.Actions))
                .ObserveOnMainThread()
                .InvokeCommand(ShowNotification);
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:33,代码来源:MiniMainWindowViewModel.cs

示例8: ClientAnnotationViewModel

 public ClientAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) : base(sharedDataService, meeting)
 {
     // create the client annotations property, a mapped version of the agent's properties based on the screen sizes.
     _annotationsChangedSub = _clientAnnotations = AnnotationsModel
                                                       .WhenAnyValue(v => v.Annotations, v => v.Select(p => CreateAnnotationViewModel(p)))
                                                       .ToProperty(this, v => v.Annotations);
 }
开发者ID:reactiveui-forks,项目名称:VirtualSales,代码行数:7,代码来源:ClientAnnotationViewModel.cs

示例9: MainWindowViewModel

        public MainWindowViewModel()
        {
            var whenAnyColorChanges = this.WhenAny(x => x.Red, x => x.Green, x => x.Blue,
                    (r, g, b) => Tuple.Create(r.Value, g.Value, b.Value))
                .Select(intsToColor);

            _FinalColor = whenAnyColorChanges
                .Where(x => x != null)
                .Select(x => x.Value)
                .ToProperty(this, x => x.FinalColor);

            Ok = ReactiveCommand.Create(whenAnyColorChanges.Select(x => x != null));

            _Images = this.WhenAny(x => x.FinalColor, x => x.Value)
                .Throttle(TimeSpan.FromSeconds(0.7), RxApp.MainThreadScheduler)
                .Do(_ => IsBusy = true)
                .Select(x => imagesForColor(x))
                .Switch()
                .SelectMany(imageListToImages)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Do(_ => IsBusy = false)
                .ToProperty(this, x => x.Images);

            _Images.ThrownExceptions.Subscribe(ex => this.Log().WarnException("Can't load images", ex));
        }
开发者ID:modulexcite,项目名称:RxUI_QCon,代码行数:25,代码来源:MainWindowViewModel.cs

示例10: SoundCloudSongViewModel

 public SoundCloudSongViewModel(SoundCloudSong model)
     : base(model)
 {
     this.hasThumbnail = this.WhenAnyValue(x => x.Thumbnail)
         .Select(x => x != null)
         .ToProperty(this, x => x.HasThumbnail);
 }
开发者ID:reactiveui-forks,项目名称:Espera,代码行数:7,代码来源:SoundCloudSongViewModel.cs

示例11: GistCreationViewModel

        public GistCreationViewModel(
            IRepositoryHost repositoryHost,
            ISelectedTextProvider selectedTextProvider,
            IGistPublishService gistPublishService,
            IUsageTracker usageTracker)
        {
            Title = Resources.CreateGistTitle;
            apiClient = repositoryHost.ApiClient;
            this.gistPublishService = gistPublishService;
            this.usageTracker = usageTracker;

            FileName = VisualStudio.Services.GetFileNameFromActiveDocument() ?? Resources.DefaultGistFileName;
            SelectedText = selectedTextProvider.GetSelectedText();

            // This class is only instantiated after we are logged into to a github account, so we should be safe to grab the first one here as the defaut.
            account = repositoryHost.ModelService.GetAccounts()
                .FirstAsync()
                .Select(a => a.First())
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToProperty(this, vm => vm.Account);

            var canCreateGist = this.WhenAny( 
                x => x.FileName,
                fileName => !String.IsNullOrEmpty(fileName.Value));

            CreateGist = ReactiveCommand.CreateAsyncObservable(canCreateGist, OnCreateGist);
        }
开发者ID:github,项目名称:VisualStudio,代码行数:27,代码来源:GistCreationViewModel.cs

示例12: MyIssuesViewModel

        public MyIssuesViewModel(ISessionService sessionService)
            : base(sessionService)
        {
            _sessionService = sessionService;

            Title = "My Issues";
            Filter = MyIssuesFilterModel.CreateOpenFilter();

            _selectedFilter = this.WhenAnyValue(x => x.Filter)
                .Select(x =>
                {
                    if (x == null || _openFilter.Equals(x))
                        return 0;
                    return _closedFilter.Equals(x) ? 1 : -1;
                })
                .ToProperty(this, x => x.SelectedFilter);

            this.WhenAnyValue(x => x.Filter).Skip(1).Subscribe(filter => {
                InternalItems.Clear();
                LoadCommand.ExecuteIfCan();
                CustomFilterEnabled = !(filter == _closedFilter || filter == _openFilter);
            });

            GoToFilterCommand = ReactiveCommand.Create();
            GoToFilterCommand.Subscribe(_ => {
                var vm = this.CreateViewModel<MyIssuesFilterViewModel>();
                vm.Init(Filter);
                vm.SaveCommand.Subscribe(filter => Filter = filter);
                NavigateTo(vm);
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:31,代码来源:MyIssuesViewModel.cs

示例13: Threshold

        public Threshold(IObservable<int> thresholdState)
        {
            //this.WhenAny(vm => vm.Good, vm => vm.Bad, vm => vm.OK, (g, b, o) =>
            //{

            //});

            this.Good = new Range();
            this.Bad = new Range();
            this.OK = new Range();

            var obs = thresholdState.Select(value =>
               {
                   if (value.Between(this.Good.Min, this.Good.Max))
                       return "Good";

                   if (value.Between(this.OK.Min, this.ok.Max))
                       return "OK";

                   if (value.Between(this.Bad.Min, this.bad.Max))
                       return "Bad";

                   return "";
               });

            this.state = obs.ToProperty(this, vm => vm.State);
            obs.Subscribe(_ =>
            {
                Trace.WriteLine(_);
            });
        }
开发者ID:abbottdev,项目名称:gitreminder,代码行数:31,代码来源:Threshold.cs

示例14: OAuthFlowLoginViewModel

        public OAuthFlowLoginViewModel(
            IAccountsRepository accountsRepository,
            IActionMenuFactory actionMenuService,
            IAlertDialogFactory alertDialogService)
        {
            _accountsRepository = accountsRepository;
            _alertDialogService = alertDialogService;

            Title = "Login";

            var oauthLogin = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<OAuthTokenLoginViewModel>()));

            var canLogin = this.WhenAnyValue(x => x.Code).Select(x => !string.IsNullOrEmpty(x));
            var loginCommand = ReactiveCommand.CreateAsyncTask(canLogin,_ => Login(Code));
            loginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
            LoginCommand = loginCommand;

            ShowLoginOptionsCommand = ReactiveCommand.CreateAsyncTask(sender =>
            {
                var actionMenu = actionMenuService.Create();
                actionMenu.AddButton("Login via Token", oauthLogin);
                return actionMenu.Show(sender);
            });

            _loginUrl = this.WhenAnyValue(x => x.WebDomain)
                .IsNotNull()
                .Select(x => x.TrimEnd('/'))
                .Select(x => 
                    string.Format(x + "/login/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", 
                    ClientId, Uri.EscapeDataString(RedirectUri), Uri.EscapeDataString(string.Join(",", OctokitClientFactory.Scopes))))
                .ToProperty(this, x => x.LoginUrl);

            WebDomain = DefaultWebDomain;
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:35,代码来源:OAuthFlowLoginViewModel.cs

示例15: SettingsViewModel

        public SettingsViewModel(
            IScreen screen,
            ISettingsProvider settingsProvider,
            IFolderHelper folderHelper, 
            IAppContext appContext)
        {
            HostScreen = screen;

            BackCommand = new ReactiveAsyncCommand();
            BackCommand.RegisterAsyncAction(_ => HostScreen.Router.NavigateBack.Execute(null));

            SelectFolder = new ReactiveAsyncCommand();
            SelectFolder.RegisterAsyncAction(_ =>
            {
                var result = folderHelper.SelectFolder();
                if (result.Result == true) {
                    UpdateLocation = result.Folder;
                }
            }, appContext.DispatcherScheduler);

            UpdateLocation = settingsProvider.UpdateLocation;

            _IsError = this.WhenAny(vm => vm.UpdateLocation, vm => vm.Value)
                           .DistinctUntilChanged()
                           .Throttle(TimeSpan.FromMilliseconds(500))
                           .ObserveOn(appContext.DispatcherScheduler)
                           .Select(text => !IsUrlOrFolder(text))
                           .Do(error => {
                                if (!error) {
                                    settingsProvider.UpdateLocation = UpdateLocation;
                                }
                            })
                            .ToProperty(this, vm => vm.IsError, setViaReflection: false);
        }
开发者ID:rzhw,项目名称:Squirrel.Samples,代码行数:34,代码来源:SettingsViewModel.cs


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