Skip to content

Commit

Permalink
warning ordre
Browse files Browse the repository at this point in the history
  • Loading branch information
gideruette committed Oct 5, 2023
1 parent 7417eed commit 078d81f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions TopModel.Generator.Core/TemplateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ private static IEnumerable<Match> ExtractVariables(this string input)
return regex.Matches(input).Cast<Match>();
}

private static string ResolveVariable(this string input, Domain domain, GeneratorConfigBase config, string? tag = null)
{
var transform = input.GetTransformation();
var variable = input.Split(':').First();

return input.Split(':').First() switch
{
"mediaType" => transform(domain.MediaType ?? string.Empty),
"length" => transform(domain.Length?.ToString() ?? string.Empty),
"scale" => transform(domain.Scale?.ToString() ?? string.Empty),
"name" => transform(domain.Name ?? string.Empty),
"type" => transform(domain.Implementations.GetValueOrDefault(config.Language)?.Type ?? string.Empty),
var i => config.ResolveVariables(config.ResolveGlobalVariables($@"{{{i}}}").Trim('{', '}'), tag: tag)
};
}

private static string ResolveVariable(this string input, IProperty c, string[] parameters, GeneratorConfigBase config, string? tag = null)
{
switch (c)
Expand Down Expand Up @@ -376,22 +392,6 @@ private static string ResolveVariable(this string input, Endpoint e, string[] pa
return result;
}

private static string ResolveVariable(this string input, Domain domain, GeneratorConfigBase config, string? tag = null)
{
var transform = input.GetTransformation();
var variable = input.Split(':').First();

return input.Split(':').First() switch
{
"mediaType" => transform(domain.MediaType ?? string.Empty),
"length" => transform(domain.Length?.ToString() ?? string.Empty),
"scale" => transform(domain.Scale?.ToString() ?? string.Empty),
"name" => transform(domain.Name ?? string.Empty),
"type" => transform(domain.Implementations.GetValueOrDefault(config.Language)?.Type ?? string.Empty),
var i => config.ResolveVariables(config.ResolveGlobalVariables($@"{{{i}}}").Trim('{', '}'), tag: tag)
};
}

private static string ResolveVariable(this string input, Domain domainFrom, Domain domainTo, GeneratorConfigBase config, string? tag = null)
{
if (input.StartsWith("from."))
Expand Down

0 comments on commit 078d81f

Please sign in to comment.