public ImagesController(IWebHostEnvironment env, ImagePresenter imagePresenter, ErrorPresenter basicPresenter, IUploadedFileRepository uploadedFileRepository) { _env = env; _imagePresenter = imagePresenter; _basicPresenter = basicPresenter; _uploadedFileRepository = uploadedFileRepository; }
protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { dvm.Save(sender, e); if (dvm.Errors != null && dvm.Errors.HasErrors()) { return; } PersonInfo userInfo = dvm.ServiceProvider.GetService <IPersonService>().Read(authObj.EmailProperty.Value).Result; ClaimsIdentity ci = SecurityManager.CreateIdentity(AuthenticationTypes.Password, userInfo); Thread.CurrentPrincipal = new ClaimsPrincipal(ci); MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (System.Diagnostics.Debugger.IsAttached) { return; } e.Handled = true; ErrorPresenter.Show(e.ExceptionObject); }
public VsFileDiffProvider( IVsDifferenceService vsDifferenceService, string solutionPath, SolutionSelectionContainer <ISolutionSelection> selectionContainer, ErrorPresenter errorPresenter, GitFileDiffController gitFileDiffController) { this.vsDifferenceService = vsDifferenceService; this.solutionPath = solutionPath; this.errorPresenter = errorPresenter; this.gitFileDiffController = gitFileDiffController; this.DocumentPath = selectionContainer.FullName; this.OldDocumentPath = selectionContainer.OldFullName; }
public static bool ValidateSolution(string solutionDirectory, string solutionFile) { // We set solution info from solution load event on the filter, and display the filter button at the same time, // so just to be safe, check if info was set before user clicked the button if (string.IsNullOrEmpty(solutionDirectory) || string.IsNullOrEmpty(solutionFile)) { ErrorPresenter.ShowError( "Unable to get Solution from Visual Studio services.\n" + "If the error persists, please restart Visual Studio with this solution as the start-up solution."); return(false); } return(true); }
protected async Task InitializeAsync(IGitBranchDifferPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); this.package = package ?? throw new ArgumentNullException(nameof(package)); this.dte = await package.GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE ?? throw new ArgumentNullException(nameof(dte)); this.vsUIShell = await package.GetServiceAsync(typeof(SVsUIShell)) as IVsUIShell ?? throw new ArgumentNullException(nameof(vsUIShell)); // Dependencies that can be moved to constructor and resolved via IoC... this.vsDifferenceService = await package.GetServiceAsync(typeof(SVsDifferenceService)) as IVsDifferenceService ?? throw new ArgumentNullException(nameof(vsDifferenceService)); this.commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as IMenuCommandService ?? throw new ArgumentNullException(nameof(commandService)); this.errorPresenter = VsDIContainer.Instance.GetService(typeof(ErrorPresenter)) as ErrorPresenter ?? throw new ArgumentNullException(nameof(errorPresenter)); this.gitFileDiffController = DIContainer.Instance.GetService(typeof(GitFileDiffController)) as GitFileDiffController ?? throw new ArgumentNullException(nameof(gitFileDiffController)); }
private void SaveDocument() { RavenJObject doc; RavenJObject metadata; try { doc = RavenJObject.Parse(document.JsonData); metadata = RavenJObject.Parse(document.JsonMetadata); if (document.Key != null && Seperator != null && metadata.Value <string>(Constants.RavenEntityName) == null) { var entityName = document.Key.Split(new[] { Seperator }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); if (entityName != null && entityName.Length > 1) { metadata[Constants.RavenEntityName] = char.ToUpper(entityName[0]) + entityName.Substring(1); } else { metadata[Constants.RavenEntityName] = entityName; } } } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message); return; } document.UpdateMetadata(metadata); ApplicationModel.Current.AddNotification(new Notification("Saving document " + document.Key + " ...")); var url = new UrlParser(UrlUtil.Url); var docId = url.GetQueryParam("id"); Guid?etag = string.Equals(docId, document.Key, StringComparison.InvariantCultureIgnoreCase) ? document.Etag : Guid.Empty; DatabaseCommands.PutAsync(document.Key, etag, doc, metadata) .ContinueOnSuccess(result => { ApplicationModel.Current.AddNotification(new Notification("Document " + result.Key + " saved")); document.Etag = result.ETag; document.SetCurrentDocumentKey(result.Key, dontOpenNewTag: true); }) .ContinueOnSuccess(() => new RefreshDocumentCommand(document).Execute(null)) .Catch(exception => ApplicationModel.Current.AddNotification(new Notification(exception.Message))); }
public override void Execute(object parameter) { RavenJObject metadata; try { metadata = RavenJObject.Parse(editableDocumentModel.JsonMetadata); editableDocumentModel.JsonData = RavenJObject.Parse(editableDocumentModel.JsonData).ToString(Formatting.Indented); editableDocumentModel.JsonMetadata = metadata.ToString(Formatting.Indented); } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message, string.Empty); return; } editableDocumentModel.UpdateMetadata(metadata); }
public BranchDiffFilter( IGitBranchDifferPackage package, string solutionPath, IVsHierarchyItemCollectionProvider vsHierarchyItemCollectionProvider) { this.package = package; this.solutionDirectory = solutionPath; this.vsHierarchyItemCollectionProvider = vsHierarchyItemCollectionProvider; this.Initialized += BranchDiffFilter_Initialized; // Dependencies that can be moved to constructor and resolved via IoC... this.branchDiffWorker = DIContainer.Instance.GetService(typeof(GitBranchDiffController)) as GitBranchDiffController; this.branchDiffValidator = VsDIContainer.Instance.GetService(typeof(BranchDiffFilterValidator)) as BranchDiffFilterValidator; this.errorPresenter = VsDIContainer.Instance.GetService(typeof(ErrorPresenter)) as ErrorPresenter; Assumes.Present(this.branchDiffWorker); Assumes.Present(this.branchDiffValidator); Assumes.Present(this.errorPresenter); }
private void SaveDocument() { RavenJObject doc; RavenJObject metadata; try { doc = RavenJObject.Parse(document.JsonData); metadata = RavenJObject.Parse(document.JsonMetadata); if (document.Key != null && document.Key.Contains("/") && metadata.Value <string>(Constants.RavenEntityName) == null) { var entityName = document.Key.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); if (entityName != null && entityName.Length > 1) { metadata[Constants.RavenEntityName] = char.ToUpper(entityName[0]) + entityName.Substring(1); } else { metadata[Constants.RavenEntityName] = entityName; } } } catch (JsonReaderException ex) { ErrorPresenter.Show(ex.Message, string.Empty); return; } document.UpdateMetadata(metadata); ApplicationModel.Current.AddNotification(new Notification("Saving document " + document.Key + " ...")); DatabaseCommands.PutAsync(document.Key, document.Etag, doc, metadata) .ContinueOnSuccess(result => { ApplicationModel.Current.AddNotification(new Notification("Document " + result.Key + " saved")); document.Etag = result.ETag; document.SetCurrentDocumentKey(result.Key); }) .ContinueOnSuccess(() => new RefreshDocumentCommand(document).Execute(null)) .Catch(exception => ApplicationModel.Current.AddNotification(new Notification(exception.Message))); }
public static bool ValidateBranch(IGitBranchDifferPackage package) { if (package is null) { MessageBox.Show( "Unable to load Git Branch Differ plug-in. It is possible Visual Studio is still initializing, please wait and try again.", "Git Branch Differ"); return(false); } if (package.BranchToDiffAgainst is null || package.BranchToDiffAgainst == string.Empty) { ErrorPresenter.ShowError("Branch to diff against is not set. Go to Options -> Git Branch Differ -> Set \"Branch To Diff Against\""); return(false); } return(true); }
protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { authObj.Validate(true); authObj.GetValidationErrors().AbortIfHasErrors(); WcfServices.Authenticate(authObj.EmailProperty.Value, authObj.PasswordProperty.Value); authObj.TrackModifications = false; // to prevent confirmation on closing of the login view MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }
public void ShowFileDiffWithBaseBranch(string baseBranchToDiffAgainst) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var fileDiffController = DIContainer.Instance.GetService(typeof(GitFileDiffController)) as GitFileDiffController; Assumes.Present(fileDiffController); // Get branch pairs to diff and Get the revision of file in the branch-to-diff-against try { var branchPairs = fileDiffController.GetDiffBranchPair(this.solutionPath, baseBranchToDiffAgainst); var baseBranchFilePath = string.IsNullOrEmpty(this.OldDocumentPath) ? this.DocumentPath : this.OldDocumentPath; var leftFileMoniker = fileDiffController.GetBaseBranchRevisionOfFile(this.solutionPath, baseBranchToDiffAgainst, baseBranchFilePath); var rightFileMoniker = this.DocumentPath; this.PresentComparisonWindow(branchPairs, leftFileMoniker, rightFileMoniker); } catch (GitOperationException e) { ErrorPresenter.ShowError(e.Message); } }
protected override async void Save(object sender, EventArgs e) { try { SaveButton.IsEnabled = false; var user = await Authenticate(); principalProvider.CurrentPrincipal = user; MainMenu.M_Sales_Visible = user.IsEmployee() || user.IsStoreContact() || user.IsIndividualCustomer(); MainView.Start(); Close(); } catch (Exception ex) { ErrorList errors = Model.ErrorParser.FromException(ex); ErrorPresenter.Show(errors); } finally { SaveButton.IsEnabled = true; } }
protected override async Task <IReadOnlyObservableSet> GetIncludedItemsAsync(IEnumerable <IVsHierarchyItem> rootItems) { if (BranchDiffFilterValidator.ValidateBranch(this.package)) { // Create new tag tables everytime the filter is applied BranchDiffFilterProvider.TagManager.CreateTagTables(); IVsHierarchyItem root = HierarchyUtilities.FindCommonAncestor(rootItems); if (BranchDiffFilterValidator.ValidateSolution(this.solutionDirectory, this.solutionFile)) { try { // TODO: The solution directory path may not always be the Git repo path! // Git repo could be setup higher up. Write a service to find the Git repo upwards in the heirarchy and pass that here. this.changeSet = this.branchDiffWorker.GenerateDiff(this.solutionDirectory, this.package.BranchToDiffAgainst); } catch (GitOperationException e) { ErrorPresenter.ShowError(e.Message); return(null); } IReadOnlyObservableSet <IVsHierarchyItem> sourceItems = await this.vsHierarchyItemCollectionProvider.GetDescendantsAsync( root.HierarchyIdentity.NestedHierarchy, CancellationToken); IFilteredHierarchyItemSet includedItems = await this.vsHierarchyItemCollectionProvider.GetFilteredHierarchyItemsAsync( sourceItems, ShouldIncludeInFilter, CancellationToken); return(includedItems); } } return(null); }
public ErrorForm(ErrorPresenter presenter) { InitializeComponent(); FormDecraptifier.Decraptify(this); Presenter = presenter; }
public BranchDiffFilterValidator(ErrorPresenter errorPresenter) { this.errorPresenter = errorPresenter; }
public GameState(ClientRunner clientRunner, ErrorPresenter errorPresenter, Canvas inGameDebugConsoleCanvas) { this.clientRunner = clientRunner; this.errorPresenter = errorPresenter; this.inGameDebugConsoleCanvas = inGameDebugConsoleCanvas; }
public GameState(UnityMain unityMain, ErrorPresenter errorPresenter, Canvas inGameDebugConsoleCanvas) { this.unityMain = unityMain; this.errorPresenter = errorPresenter; this.inGameDebugConsoleCanvas = inGameDebugConsoleCanvas; }
// If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { e.Handled = true; ErrorPresenter.Show(e.Exception); }
public GameState(UnityMain unityMain, ErrorPresenter errorPresenter) { this.unityMain = unityMain; this.errorPresenter = errorPresenter; }
// If an error occurs during navigation, show an error window private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { e.Handled = true; ErrorPresenter.Show(e.Exception, null, string.Format("Could not load page: {0}", e.Uri)); }