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


C# IReactiveCommand.Subscribe方法代码示例

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


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

示例1: EditSourceViewModel

	    public EditSourceViewModel(IApplicationService applicationService)
	    {
            SaveCommand = new ReactiveCommand();
	        SaveCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<CommitMessageViewModel>();
	            vm.SaveCommand.RegisterAsyncTask(async t =>
	            {
                    var request = applicationService.Client.Users[Username].Repositories[Repository]
                        .UpdateContentFile(Path, vm.Message, Text, BlobSha, Branch);
                    var response = await applicationService.Client.ExecuteAsync(request);
	                Content = response.Data;
                    DismissCommand.ExecuteIfCan();
	            });
                ShowViewModel(vm);
	        });

	        LoadCommand.RegisterAsyncTask(async t =>
	        {
	            var path = Path;
                if (!path.StartsWith("/", StringComparison.Ordinal))
                    path = "/" + path;

	            var request = applicationService.Client.Users[Username].Repositories[Repository].GetContentFile(path, Branch ?? "master");
			    request.UseCache = false;
			    var data = await applicationService.Client.ExecuteAsync(request);
			    BlobSha = data.Data.Sha;
			    Text = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(data.Data.Content));
	        });
	    }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:30,代码来源:EditSourceViewModel.cs

示例2: EditSourceViewModel

	    public EditSourceViewModel(IApplicationService applicationService)
	    {
            SaveCommand = ReactiveCommand.Create();
	        SaveCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<CommitMessageViewModel>();
                vm.Username = Username;
                vm.Repository = Repository;
                vm.Path = Path;
                vm.Text = Text;
                vm.BlobSha = BlobSha;
                vm.Branch = Branch;
                vm.ContentChanged.Subscribe(x => Content = x);
                ShowViewModel(vm);
	        });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
	        {
	            var path = Path;
                if (!path.StartsWith("/", StringComparison.Ordinal))
                    path = "/" + path;

	            var request = applicationService.Client.Users[Username].Repositories[Repository].GetContentFile(path, Branch ?? "master");
			    request.UseCache = false;
			    var data = await applicationService.Client.ExecuteAsync(request);
			    BlobSha = data.Data.Sha;
	            var content = Convert.FromBase64String(data.Data.Content);
                Text = System.Text.Encoding.UTF8.GetString(content, 0, content.Length);
	        });
	    }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:30,代码来源:EditSourceViewModel.cs

示例3: IssueEditViewModel

	    public IssueEditViewModel(IApplicationService applicationService)
	    {
	        _applicationService = applicationService;

            GoToDescriptionCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Issue, x => x != null));
	        GoToDescriptionCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<ComposerViewModel>();
	            vm.Text = Issue.Body;
	            vm.SaveCommand.Subscribe(__ =>
	            {
	                Issue.Body = vm.Text;
                    vm.DismissCommand.ExecuteIfCan();
	            });
	            ShowViewModel(vm);
	        });

	        this.WhenAnyValue(x => x.Issue).Where(x => x != null).Subscribe(x =>
	        {
                Title = x.Title;
                AssignedTo = x.Assignee;
                Milestone = x.Milestone;
                Labels = x.Labels.ToArray();
                Content = x.Body;
                IsOpen = string.Equals(x.State, "open");
	        });
	    }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:27,代码来源:IssueEditViewModel.cs

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

示例5: UserGistsViewModel

        public UserGistsViewModel(ISessionService sessionService)
            : base(sessionService)
        {
            _sessionService = sessionService;
            Username = _sessionService.Account.Username;

            GoToCreateGistCommand = ReactiveCommand.Create();
            GoToCreateGistCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<GistCreateViewModel>();
                vm.SaveCommand
                    .Delay(TimeSpan.FromMilliseconds(200))
                    .ObserveOn(RxApp.MainThreadScheduler)
                    .Subscribe(x => InternalItems.Insert(0, x));
                NavigateTo(vm);
            });

            this.WhenAnyValue(x => x.Username).Subscribe(x =>
            {
                if (IsMine)
                    Title = "My Gists";
                else if (x == null) 
                    Title = "Gists";
                else if (x.EndsWith("s", StringComparison.OrdinalIgnoreCase))
                    Title = x + "' Gists";
                else
                    Title = x + "'s Gists";
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:29,代码来源:UserGistsViewModel.cs

示例6: GistFileModifyViewModel

 protected GistFileModifyViewModel(Func<Tuple<string, string>, Task> saveFunc)
 {
     var validObservable = this.WhenAnyValue(x => x.Filename, x => x.Description, (x, y) => 
         !string.IsNullOrEmpty(x) && !string.IsNullOrEmpty(y));
     SaveCommand = ReactiveCommand.CreateAsyncTask(validObservable, 
         async _ => await saveFunc(Tuple.Create(Filename, Description)));
     SaveCommand.Subscribe(_ => Dismiss());
 }
开发者ID:runt18,项目名称:CodeHub,代码行数:8,代码来源:GistFileModifyViewModel.cs

示例7: OrganizationViewModel

        public OrganizationViewModel(IApplicationService applicationService)
        {
            GoToMembersCommand = new ReactiveCommand();
            GoToMembersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<OrganizationMembersViewModel>();
                vm.OrganizationName = Name;
                ShowViewModel(vm);
            });

            GoToTeamsCommand = new ReactiveCommand();
            GoToTeamsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<TeamsViewModel>();
                vm.OrganizationName = Name;
                ShowViewModel(vm);
            });

            GoToFollowersCommand = new ReactiveCommand();
            GoToFollowersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserFollowersViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToEventsCommand = new ReactiveCommand();
            GoToEventsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserEventsViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToGistsCommand = new ReactiveCommand();
            GoToGistsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserGistsViewModel>();
                vm.Username = Name;
                ShowViewModel(vm);
            });

            GoToRepositoriesCommand = new ReactiveCommand();
            GoToRepositoriesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<OrganizationRepositoriesViewModel>();
                vm.Name = Name;
                ShowViewModel(vm);
            });

            LoadCommand.RegisterAsyncTask(t =>
                this.RequestModel(applicationService.Client.Organizations[Name].Get(), t as bool?,
                    response => Organization = response.Data));
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:54,代码来源:OrganizationViewModel.cs

示例8: EnterpriseSupportViewModel

        public EnterpriseSupportViewModel()
        {
            Title = "Support";
            SubmitFeedbackCommand = ReactiveCommand.Create();

            GoToGitHubCommand = ReactiveCommand.Create();
            GoToGitHubCommand.Subscribe(_ => {
                var vm = this.CreateViewModel<WebBrowserViewModel>();
                vm.Init("https://github.com/thedillonb/CodeHub");
                NavigateTo(vm);
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:12,代码来源:EnterpriseSupportViewModel.cs

示例9: AboutViewModel

        public AboutViewModel(IEnvironmentalService environmentService)
        {
            _environmentService = environmentService;

            GoToSourceCodeCommand = new ReactiveCommand();
            GoToSourceCodeCommand.Subscribe(x =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = "thedillonb";
                vm.RepositoryName = "codehub";
                ShowViewModel(vm);
            });
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:13,代码来源:AboutViewModel.cs

示例10: IntelliSensePopupViewModel

    public IntelliSensePopupViewModel(NitraTextEditorViewModel editor)
    {
      Items = new ReactiveList<PopupItemViewModel>();

      var canSelect = this.WhenAny(v => v.SelectedPopupItem, item => item.Value != null);

      Select = ReactiveCommand.Create(canSelect);
      Select.Subscribe(_ => {
        editor.SelectText(SelectedPopupItem.File, SelectedPopupItem.Span);

        IsVisible = false;
        SelectedPopupItem = null;
      });
    }
开发者ID:rsdn,项目名称:nitra,代码行数:14,代码来源:IntelliSensePopupViewModel.cs

示例11: EventItemViewModel

        public EventItemViewModel(
            EventModel eventModel, 
            IReadOnlyCollection<BaseEventsViewModel.TextBlock> headerBlocks, 
            IReadOnlyCollection<BaseEventsViewModel.TextBlock> bodyBlocks,
            Action gotoAction = null)
        {
            Event = eventModel;
            HeaderBlocks = headerBlocks ?? new BaseEventsViewModel.TextBlock[0];
            BodyBlocks = bodyBlocks ?? new BaseEventsViewModel.TextBlock[0];
            GoToCommand = ReactiveCommand.Create();

            if (gotoAction != null)
                GoToCommand.Subscribe(x => gotoAction());
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:14,代码来源:EventItemViewModel.cs

示例12: NewAccountViewModel

        public NewAccountViewModel()
        {
            GoToDotComLoginCommand = new ReactiveCommand();
            GoToDotComLoginCommand.Subscribe(_ => 
                CreateAndShowViewModel<LoginViewModel>());

            GoToEnterpriseLoginCommand = new ReactiveCommand();
            GoToEnterpriseLoginCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<AddAccountViewModel>();
                vm.IsEnterprise = true;
                ShowViewModel(vm);
            });

        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:15,代码来源:NewAccountViewModel.cs

示例13: RepositoryCloneViewModel

        public RepositoryCloneViewModel(
            IRepositoryHost repositoryHost,
            IRepositoryCloneService cloneService,
            IOperatingSystem operatingSystem,
            INotificationService notificationService)
        {
            this.repositoryHost = repositoryHost;
            this.cloneService = cloneService;
            this.operatingSystem = operatingSystem;
            this.notificationService = notificationService;

            Title = string.Format(CultureInfo.CurrentCulture, Resources.CloneTitle, repositoryHost.Title);
            Repositories = new ReactiveList<IRepositoryModel>();
            loadRepositoriesCommand = ReactiveCommand.CreateAsyncObservable(OnLoadRepositories);
            isLoading = this.WhenAny(x => x.LoadingFailed, x => x.Value)
                .CombineLatest(loadRepositoriesCommand.IsExecuting, (failed, loading) => !failed && loading)
                .ToProperty(this, x => x.IsLoading);
            loadRepositoriesCommand.Subscribe(Repositories.AddRange);
            filterTextIsEnabled = this.WhenAny(x => x.Repositories.Count, x => x.Value > 0)
                .ToProperty(this, x => x.FilterTextIsEnabled);
            noRepositoriesFound = this.WhenAny(x => x.FilterTextIsEnabled, x => x.IsLoading, x => x.LoadingFailed
                , (any, loading, failed) => !any.Value && !loading.Value && !failed.Value)
                .ToProperty(this, x => x.NoRepositoriesFound);

            var filterResetSignal = this.WhenAny(x => x.FilterText, x => x.Value)
                .DistinctUntilChanged(StringComparer.OrdinalIgnoreCase)
                .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler);

            FilteredRepositories = Repositories.CreateDerivedCollection(
                x => x,
                filter: FilterRepository,
                signalReset: filterResetSignal
            );

            BaseRepositoryPathValidator = this.CreateBaseRepositoryPathValidator();

            var canCloneObservable = this.WhenAny(
                x => x.SelectedRepository,
                x => x.BaseRepositoryPathValidator.ValidationResult.IsValid,
                (x, y) => x.Value != null && y.Value);
            canClone = canCloneObservable.ToProperty(this, x => x.CanClone);
            CloneCommand = ReactiveCommand.CreateAsyncObservable(canCloneObservable, OnCloneRepository);

            browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog());
            this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value)
                .Subscribe();
            BaseRepositoryPath = cloneService.DefaultClonePath;
        }
开发者ID:uQr,项目名称:VisualStudio,代码行数:48,代码来源:RepositoryCloneViewModel.cs

示例14: IssueAddViewModel

        public IssueAddViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            GoToDescriptionCommand = ReactiveCommand.Create();
            GoToDescriptionCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<MarkdownComposerViewModel>();
                vm.Text = Content;
                vm.SaveCommand.Subscribe(__ =>
                {
                    Content = vm.Text;
                    vm.DismissCommand.ExecuteIfCan();
                });
                ShowViewModel(vm);
            });
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:17,代码来源:IssueAddViewModel.cs

示例15: ReadmeViewModel

        public ReadmeViewModel(IApplicationService applicationService, IMarkdownService markdownService, IShareService shareService)
        {
            ShareCommand = new ReactiveCommand(this.WhenAnyValue(x => x.ContentModel, x => x != null));
            ShareCommand.Subscribe(_ => shareService.ShareUrl(ContentModel.HtmlUrl));

            GoToGitHubCommand = new ReactiveCommand(this.WhenAnyValue(x => x.ContentModel, x => x != null));
            GoToGitHubCommand.Subscribe(_ => GoToUrlCommand.ExecuteIfCan(ContentModel.HtmlUrl));

            GoToLinkCommand = new ReactiveCommand();
            GoToLinkCommand.OfType<string>().Subscribe(x => GoToUrlCommand.ExecuteIfCan(x));

            LoadCommand.RegisterAsyncTask(x => 
                this.RequestModel(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReadme(), x as bool?, r =>
                {
                    ContentModel = r.Data;
                    ContentText = markdownService.Convert(Encoding.UTF8.GetString(Convert.FromBase64String(ContentModel.Content)));
                }));
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:18,代码来源:ReadmeViewModel.cs


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