public ExtensionInfo(IGitHelperExtensionFile extensionFile, Action <string, string> showDialog) { Name = extensionFile.Name; Description = extensionFile.Description; ShortDescription = extensionFile.ShortDescription; Features = extensionFile.Features; _filePath = extensionFile.FilePath; _workingDirectory = extensionFile.WorkingDirectory; _showDialog = showDialog; ExecuteCommand = new RelayCommand(RunFile); }
public static List <IGitHelperExtensionFile> GetExtensionFiles(List <string> extensionPaths, bool showWariningIfFileIsNotFound = false) { var extensions = new List <IGitHelperExtensionFile>(); if (Utility.IsNullOrEmpty(extensionPaths)) { return(extensions); } var currentPath = FilePathHelper.GetCurrentDirectory(); var showedErrorMessage = new List <string>(); foreach (var f in extensionPaths) { var filePath = f; var useRelativePath = !FilePathHelper.IsFullPath(filePath); if (useRelativePath) { filePath = FilePathHelper.GetAbsolutePath(filePath, currentPath); } if (!File.Exists(filePath)) { if (showWariningIfFileIsNotFound) { MessageBox.Show($"Cannot find file \"{filePath}\""); } continue; } try { IGitHelperExtensionFile extension = null; var ext = Path.GetExtension(filePath)?.ToLower(); switch (ext) { case ".bat": extension = new GitHelperScriptFile(filePath); break; } if (extension != null) { if (extension.IsValid(out var extensionError)) { if (useRelativePath) { extension.ToRelatvePath(); } extensions.Add(extension); } else { MessageBox.Show(string.Join(", ", extensionError)); } } } catch (Exception e) { if (!showedErrorMessage.Contains(e.Message)) { showedErrorMessage.Add(e.Message); MessageBox.Show(e.Message); } } } return(extensions); }