[WONT RUN] RazorEngine
This commit is contained in:
parent
1a9fc24ba9
commit
5f188c99a8
7 changed files with 292 additions and 9237 deletions
7
cli/Modules/IModule.cs
Normal file
7
cli/Modules/IModule.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace cli.Modules
|
||||
{
|
||||
public interface IModule
|
||||
{
|
||||
void Run (string[] args);
|
||||
}
|
||||
}
|
||||
29
cli/Modules/MonthlyEMailGenerator.cs
Normal file
29
cli/Modules/MonthlyEMailGenerator.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using RazorEngine.Templating;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
|
||||
namespace cli.Modules
|
||||
{
|
||||
public class MonthlyEMailGenerator : IModule
|
||||
{
|
||||
IRazorEngineService engine;
|
||||
IEmailSender emailSender;
|
||||
|
||||
ApplicationDbContext dbContext;
|
||||
public MonthlyEMailGenerator(ApplicationDbContext context, IRazorEngineService res, IEmailSender sender)
|
||||
{
|
||||
dbContext = context;
|
||||
engine = res;
|
||||
emailSender = sender;
|
||||
// engine.AddTemplate(new Tem)
|
||||
}
|
||||
public void Run(string[] args)
|
||||
{
|
||||
Console.WriteLine($"Hello from second module using {engine}");
|
||||
string template = "Hello @Model.Name, welcome to RazorEngine!";
|
||||
var result = engine.RunCompile(template, "templateKey", null, new { Name = "World" });
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
cli/Modules/MyGenerator.cs
Normal file
25
cli/Modules/MyGenerator.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RazorEngine.Configuration;
|
||||
using RazorEngine.Templating;
|
||||
|
||||
namespace cli.Modules
|
||||
{
|
||||
public class MyGenerator : IModule
|
||||
{
|
||||
|
||||
ILogger logger;
|
||||
public MyGenerator(ILoggerFactory loggerfactory)
|
||||
{
|
||||
logger = loggerfactory.CreateLogger<MyGenerator>();
|
||||
}
|
||||
|
||||
public void Run(string[] args)
|
||||
{
|
||||
logger.LogInformation(nameof(MyGenerator));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue