コード例 #1
0
        public override void Execute(List <CommandParameter> parameters)
        {
            var path        = GetStringParameterValue(parameters, CommandPathParameter.Name);
            var name        = GetStringParameterValue(parameters, CommandNameParameter.Name);
            var description = GetStringParameterValue(parameters, CommandDescriptionParameter.Name);

            if (StoredDataService.ExistsTemplate(name))
            {
                throw new TemplateNameRepeatedException();
            }
            if (!FileService.ExistsDirectory(path))
            {
                throw new PathNotFoundException(path);
            }
            if (!FileService.ExistsTemplateConfigFile(path))
            {
                throw new TemplateConfigFileNotFoundException(path);
            }
            if (!StringFormats.IsValidLogicalName(name))
            {
                throw new InvalidStringFormatException("Name can only contains alphanumeric characters");
            }

            StoredDataService.AddTemplate(path, name, description);

            Log($"Template stored!");
        }
コード例 #2
0
        public override void Execute(List <CommandParameter> parameters)
        {
            var name = GetStringParameterValue(parameters, CommandNameParameter.Name);

            if (!StoredDataService.ExistsTemplate(name))
            {
                throw new TemplateNotFoundException();
            }
            StoredDataService.DeleteTemplate(name);
            Log($"Template deleted!");
        }