Добавлена возможность получать доступ к шаблонам через встроенный ресурс

This commit is contained in:
2025-03-24 10:37:19 +03:00
parent b58bddc1a3
commit 012619a92c
10 changed files with 58 additions and 8 deletions
+22
View File
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>BasicDemo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\mROA.CodegenTools\mROA.CodegenTools.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="exampleTemplate.cstmpl" />
<EmbeddedResource Include="exampleTemplate.cstmpl">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
// See https://aka.ms/new-console-template for more information
using mROA.CodegenTools;
// var doc = new TemplateDocument();
// doc.Parts = new List<ITemplateSection>
// {
// new LiteralTemplateSection("teset text", doc),
// new DefineTemplateSection(" another text which is dinided, bun not placed ", "text define", doc),
// new LinkTemplateSection("text define", doc),
// new LinkTemplateSection("text define", doc),
// new LinkTemplateSection("text define", doc),
// new LiteralTemplateSection(" = = = ", doc),
// new InsertTemplatePart("insert", doc),
// new LinkTemplateSection("post", doc)
// };
//
// doc.Insert("insert", "inserted text by insert template => ");
// doc.Parts.Add(new DefineTemplateSection("post added", "post", doc));
// Console.WriteLine(doc.Compile());
var doc = TemplateReader.FromEmbeddedResource("exampleTemplate.cstmpl");
doc.Insert("ctorInserting", "test inserting");
Console.WriteLine(doc.Compile());
Console.WriteLine(doc.Parts.Count);
+19
View File
@@ -0,0 +1,19 @@
public class A
{
<!L linkTagA>
<!L linkTag>
<!L linkTag>
Some literal for test
<!D linkTagA>test text with definition in template<!D>
<!I ctorInserting>
<!I methodInserting R>
<!T MethodTemplate>
public void <!L methodName>()
{
Console.WriteLine("<!L printText>");
}
<!T>
}