From 078d81f7ea08f949246c0f7f7ad0f078b0d4b798 Mon Sep 17 00:00:00 2001 From: Gilderic DERUETTE Date: Thu, 5 Oct 2023 14:32:22 +0200 Subject: [PATCH] warning ordre --- TopModel.Generator.Core/TemplateExtensions.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/TopModel.Generator.Core/TemplateExtensions.cs b/TopModel.Generator.Core/TemplateExtensions.cs index 550e6c05..0513dd01 100644 --- a/TopModel.Generator.Core/TemplateExtensions.cs +++ b/TopModel.Generator.Core/TemplateExtensions.cs @@ -136,6 +136,22 @@ private static IEnumerable ExtractVariables(this string input) return regex.Matches(input).Cast(); } + 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) @@ -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."))