public bool IsValid() { var isValid = false; ArgumentError = false; var isValidDirectory = Directory.Exists(TemplateRoot); patchApplicationService = new PatchApplicationService(TemplateRoot); SourceProjectName = patchApplicationService.GetSourceProjectName(TemplateId, TemplateRoot); var hasProjectFile = !string.IsNullOrEmpty(SourceProjectName); var totalTemplates = TemplateData.AllTemplates.Count; var isValidTemplate = TemplateId > 0 && TemplateId <= totalTemplates; isValid = isValidDirectory && isValidTemplate && hasProjectFile && !ArgumentError; if (!isValidDirectory) { ErrorMessage = "The directory of your project is required."; } if (!hasProjectFile) { ErrorMessage = $"A project could not be located at: {TemplateRoot}"; } if (!isValidTemplate) { ErrorMessage = "A template id is required."; } return(isValid); }
static IOUtils() { patchApplicationService = new PatchApplicationService(AssemblyDirectory); }
public AddTemplateCommand() { patchApplicationService = new PatchApplicationService(Utils.IOUtils.AssemblyDirectory); }