[WONT RUN] RazorEngine
parent
5d75f3a226
commit
7244dcd5e1
@ -1,22 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
public class InteractiveConsoleMiddleWare
|
||||
{
|
||||
public InteractiveConsoleMiddleWare(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
readonly RequestDelegate _next;
|
||||
|
||||
public async Task Invoke(HttpContext context, IHostingEnvironment hostingEnviroment)
|
||||
{
|
||||
//do something
|
||||
System.Console.WriteLine("kjhnlkhkl");
|
||||
await _next.Invoke(context);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace cli.Modules
|
||||
{
|
||||
public interface IModule
|
||||
{
|
||||
void Run (string[] args);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue