Tweak template key
This commit is contained in:
Родитель
69cd5896df
Коммит
f726bee207
|
@ -181,9 +181,9 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
|
|||
var path = Path.Join(templatePath, "2.4", frameworkName);
|
||||
foreach (var dir in new DirectoryInfo(path).EnumerateDirectories())
|
||||
{
|
||||
var dotnetTemplate = dir.Name;
|
||||
var template = dir.Name;
|
||||
var mustacheTemplateSetting = new MustacheTemplateSettings(_logger, dir.FullName);
|
||||
_templateSettings.Add(new TemplateKey(dotnetTemplate, framework), mustacheTemplateSetting);
|
||||
_templateSettings.Add(new TemplateKey(framework, template), mustacheTemplateSetting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,9 +67,9 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
|
|||
|
||||
public async Task<List<KeyValuePair<string, string>>> GenerateProjectFiles(GeneratorModel model)
|
||||
{
|
||||
var template = string.IsNullOrEmpty(model.Template) ? DefaultTemplateName : model.Template;
|
||||
var framework = DotNetFrameworkParser.Parse(model.TargetFramework);
|
||||
var templateKey = new TemplateKey(template, framework);
|
||||
var template = string.IsNullOrEmpty(model.Template) ? DefaultTemplateName : model.Template;
|
||||
var templateKey = new TemplateKey(framework, template);
|
||||
if (!_mustacheConfig.GetTemplateKeys().Contains(templateKey))
|
||||
{
|
||||
throw new InvalidDataException($"Template with Name[{template}] and Framework[{model.TargetFramework}] doesn't exist");
|
||||
|
@ -108,9 +108,9 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
|
|||
return _mustacheConfig.GetTemplateKeys()
|
||||
.Select(templateKey => new TemplateViewModel
|
||||
{
|
||||
Name = templateKey.Name,
|
||||
ShortName = templateKey.Name,
|
||||
DotnetFramework = templateKey.Version,
|
||||
Name = templateKey.Template,
|
||||
ShortName = templateKey.Template,
|
||||
DotnetFramework = templateKey.Framework,
|
||||
Language = "C#",
|
||||
Tags = "Web/Microservice",
|
||||
})
|
||||
|
@ -129,8 +129,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
|
|||
}
|
||||
|
||||
// var templatePath = _templatePath + Path.DirectorySeparatorChar + selectedTemplate.Name;
|
||||
var config = _mustacheConfig.GetSchema(new TemplateKey(selectedTemplate.Name, framework));
|
||||
|
||||
var config = _mustacheConfig.GetSchema(new TemplateKey(framework, selectedTemplate.Name));
|
||||
return config.Params
|
||||
.Where(p => p.Description.ToLower().Contains("steeltoe"))
|
||||
.Select(p => new ProjectDependency
|
||||
|
|
|
@ -18,25 +18,24 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
|
|||
{
|
||||
public class TemplateKey
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Template { get; }
|
||||
|
||||
public DotnetFramework Version { get; }
|
||||
public DotnetFramework Framework { get; }
|
||||
|
||||
// public TemplateKey(DotnetFramework framework, string template)
|
||||
public TemplateKey(string template, DotnetFramework framework)
|
||||
public TemplateKey(DotnetFramework framework, string template)
|
||||
{
|
||||
Version = framework;
|
||||
Name = template;
|
||||
Framework = framework;
|
||||
Template = template;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Name.GetHashCode() ^ Version.GetHashCode();
|
||||
return Template.GetHashCode() ^ Framework.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is TemplateKey key && (Name.Equals(key.Name) && Version.Equals(key.Version));
|
||||
return obj is TemplateKey key && (Template.Equals(key.Template) && Framework.Equals(key.Framework));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Steeltoe.Initializr.WebApp.Controllers
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HttpContext.Response.StatusCode = (int) HttpStatusCode.BadRequest;
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
|
||||
var message = ex.Message;
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче