本文整理汇总了C#中INotificationService.ShowError方法的典型用法代码示例。如果您正苦于以下问题:C# INotificationService.ShowError方法的具体用法?C# INotificationService.ShowError怎么用?C# INotificationService.ShowError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INotificationService
的用法示例。
在下文中一共展示了INotificationService.ShowError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PullRequestCreationViewModel
public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ILocalRepositoryModel activeRepo,
IPullRequestService service, INotificationService notifications)
{
Extensions.Guard.ArgumentNotNull(repositoryHost, nameof(repositoryHost));
Extensions.Guard.ArgumentNotNull(activeRepo, nameof(activeRepo));
Extensions.Guard.ArgumentNotNull(service, nameof(service));
Extensions.Guard.ArgumentNotNull(notifications, nameof(notifications));
this.repositoryHost = repositoryHost;
var obs = repositoryHost.ApiClient.GetRepository(activeRepo.Owner, activeRepo.Name)
.Select(r => new RemoteRepositoryModel(r))
.PublishLast();
disposables.Add(obs.Connect());
githubObs = obs;
githubRepository = githubObs.ToProperty(this, x => x.GitHubRepository);
this.WhenAnyValue(x => x.GitHubRepository)
.WhereNotNull()
.Subscribe(r =>
{
TargetBranch = r.IsFork ? r.Parent.DefaultBranch : r.DefaultBranch;
});
SourceBranch = activeRepo.CurrentBranch;
service.GetPullRequestTemplate(activeRepo)
.Subscribe(x => Description = x ?? String.Empty, () => Description = Description ?? String.Empty);
this.WhenAnyValue(x => x.Branches)
.WhereNotNull()
.Where(_ => TargetBranch != null)
.Subscribe(x =>
{
if (!x.Any(t => t.Equals(TargetBranch)))
TargetBranch = GitHubRepository.IsFork ? GitHubRepository.Parent.DefaultBranch : GitHubRepository.DefaultBranch;
});
SetupValidators();
var whenAnyValidationResultChanges = this.WhenAny(
x => x.TitleValidator.ValidationResult,
x => x.BranchValidator.ValidationResult,
x => x.IsBusy,
(x, y, z) => (x.Value?.IsValid ?? false) && (y.Value?.IsValid ?? false) && !z.Value);
this.WhenAny(x => x.BranchValidator.ValidationResult, x => x.GetValue())
.WhereNotNull()
.Where(x => !x.IsValid && x.DisplayValidationError)
.Subscribe(x => notifications.ShowError(BranchValidator.ValidationResult.Message));
createPullRequest = ReactiveCommand.CreateAsyncObservable(whenAnyValidationResultChanges,
_ => service
.CreatePullRequest(repositoryHost, activeRepo, TargetBranch.Repository, SourceBranch, TargetBranch, PRTitle, Description ?? String.Empty)
.Catch<IPullRequestModel, Exception>(ex =>
{
log.Error(ex);
//TODO:Will need a uniform solution to HTTP exception message handling
var apiException = ex as ApiValidationException;
var error = apiException?.ApiError?.Errors?.FirstOrDefault();
notifications.ShowError(error?.Message ?? ex.Message);
return Observable.Empty<IPullRequestModel>();
}))
.OnExecuteCompleted(pr =>
{
notifications.ShowMessage(String.Format(CultureInfo.CurrentCulture, Resources.PRCreatedUpstream, SourceBranch.DisplayName, TargetBranch.Repository.Owner + "/" + TargetBranch.Repository.Name + "#" + pr.Number,
TargetBranch.Repository.CloneUrl.ToRepositoryUrl().Append("pull/" + pr.Number)));
});
isExecuting = CreatePullRequest.IsExecuting.ToProperty(this, x => x.IsExecuting);
this.WhenAnyValue(x => x.Initialized, x => x.GitHubRepository, x => x.Description, x => x.IsExecuting)
.Select(x => !(x.Item1 && x.Item2 != null && x.Item3 != null && !x.Item4))
.Subscribe(x => IsBusy = x);
}