Prepare getone template

This commit is contained in:
CodeLiturgy 2022-09-05 02:01:17 +01:00
parent fa3dfc8e86
commit 1de6350c7d
1 changed files with 14 additions and 12 deletions

View File

@ -50,20 +50,13 @@ namespace MapTo
private static void AddGeneratedExtensions(GeneratorExecutionContext context, Compilation compilation, IEnumerable<TypeDeclarationSyntax> candidateMembers, SourceGenerationOptions options)
{
string addSourceTemplate = GetCsxMethodTemplate(context, "AddToEntityTemplate");
string updateSourceTemplate = GetCsxMethodTemplate(context, "UpdateEntityTemplate");
string getOneByTemplate = GetCsxMethodTemplate(context, "GetOneByTemplate");
foreach (var candidateMember in candidateMembers)
{
string addSourceTemplate = context.AdditionalFiles
.FirstOrDefault(x => x.Path.Contains("AddToEntityTemplate"))?
.GetText()?
.ToString() ?? string.Empty;
string updateSourceTemplate = context.AdditionalFiles
.FirstOrDefault(x => x.Path.Contains("UpdateEntityTemplate"))?
.GetText()?
.ToString() ?? string.Empty;
var mappingContext = EfGeneratorContext.Create(compilation, options, candidateMember);
mappingContext.Diagnostics.ForEach(context.ReportDiagnostic);
@ -82,5 +75,14 @@ namespace MapTo
context.AddSource(hintName, source);
}
}
private static string GetCsxMethodTemplate(GeneratorExecutionContext context, string templateName)
{
return context.AdditionalFiles
.FirstOrDefault(x => x.Path.Contains(templateName))?
.GetText()?
.ToString() ?? string.Empty;
}
}
}