actually, one just need an initialisation method for templates
This commit is contained in:
parent
7e646afea1
commit
8a44da588a
5 changed files with 16 additions and 20 deletions
|
|
@ -10,8 +10,7 @@ namespace Yavsc.Abstract.Templates
|
||||||
public abstract class Template
|
public abstract class Template
|
||||||
{
|
{
|
||||||
|
|
||||||
StringBuilder _buffer = new StringBuilder();
|
StringBuilder _buffer ;
|
||||||
|
|
||||||
|
|
||||||
public virtual void Write(object value)
|
public virtual void Write(object value)
|
||||||
{ WriteLiteral(value); }
|
{ WriteLiteral(value); }
|
||||||
|
|
@ -25,7 +24,9 @@ namespace Yavsc.Abstract.Templates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Task ExecuteAsync();
|
public virtual void Init() {
|
||||||
|
_buffer = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,5 @@ namespace Yavsc.Templates
|
||||||
public class UserOrientedTemplate: Template
|
public class UserOrientedTemplate: Template
|
||||||
{
|
{
|
||||||
public ApplicationUser User { get; set; }
|
public ApplicationUser User { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public override async Task ExecuteAsync ()
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,17 +122,21 @@ namespace cli.Services
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
EmitResult result = compilation.Emit(ms);
|
EmitResult result = compilation.Emit(ms);
|
||||||
|
foreach (Diagnostic diagnostic in result.Diagnostics.Where(diagnostic =>
|
||||||
|
diagnostic.Severity < DiagnosticSeverity.Error && !diagnostic.IsWarningAsError))
|
||||||
|
{
|
||||||
|
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
||||||
|
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
||||||
|
}
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
{
|
{
|
||||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
||||||
diagnostic.IsWarningAsError ||
|
diagnostic.IsWarningAsError ||
|
||||||
diagnostic.Severity == DiagnosticSeverity.Error);
|
diagnostic.Severity == DiagnosticSeverity.Error);
|
||||||
|
|
||||||
foreach (Diagnostic diagnostic in failures)
|
foreach (Diagnostic diagnostic in failures)
|
||||||
{
|
{
|
||||||
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
||||||
logger.LogDebug("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -142,12 +146,10 @@ namespace cli.Services
|
||||||
|
|
||||||
Type type = assembly.GetType(DefaultNamespace+"."+className);
|
Type type = assembly.GetType(DefaultNamespace+"."+className);
|
||||||
var generatedtemplate = (UserOrientedTemplate) Activator.CreateInstance(type);
|
var generatedtemplate = (UserOrientedTemplate) Activator.CreateInstance(type);
|
||||||
logger.LogInformation(generatedtemplate.ToString());
|
|
||||||
foreach (var user in dbContext.ApplicationUser) {
|
foreach (var user in dbContext.ApplicationUser) {
|
||||||
logger.LogInformation(user.ToString());
|
logger.LogInformation ("Generation for "+user.UserName);
|
||||||
|
generatedtemplate.Init();
|
||||||
generatedtemplate.User = user;
|
generatedtemplate.User = user;
|
||||||
generatedtemplate.ExecuteAsync().Wait();
|
|
||||||
|
|
||||||
logger.LogInformation (generatedtemplate.GeneratedText);
|
logger.LogInformation (generatedtemplate.GeneratedText);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
||||||
"Microsoft.AspNet.Identity": "3.0.0-rc1-*",
|
"Microsoft.AspNet.Identity": "3.0.0-rc1-*",
|
||||||
"Yavsc": "1.0.5-rc12",
|
"Yavsc": "1.0.5-rc13",
|
||||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
|
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
|
||||||
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
||||||
"Microsoft.CodeAnalysis": "1.0.0-rc1"
|
"Microsoft.CodeAnalysis": "1.0.0-rc1"
|
||||||
|
|
|
||||||
|
|
@ -12024,7 +12024,7 @@
|
||||||
"Microsoft.Extensions.Logging.Console >= 1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Console >= 1.0.0-rc1-final",
|
||||||
"Microsoft.AspNet.Identity.EntityFramework >= 3.0.0-rc1-*",
|
"Microsoft.AspNet.Identity.EntityFramework >= 3.0.0-rc1-*",
|
||||||
"Microsoft.AspNet.Identity >= 3.0.0-rc1-*",
|
"Microsoft.AspNet.Identity >= 3.0.0-rc1-*",
|
||||||
"Yavsc >= 1.0.5-rc12",
|
"Yavsc >= 1.0.5-rc13",
|
||||||
"Microsoft.Extensions.DependencyInjection.Abstractions >= 1.0.0-rc1-final",
|
"Microsoft.Extensions.DependencyInjection.Abstractions >= 1.0.0-rc1-final",
|
||||||
"Microsoft.Extensions.Logging.Debug >= 1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Debug >= 1.0.0-rc1-final",
|
||||||
"Microsoft.CodeAnalysis >= 1.0.0-rc1"
|
"Microsoft.CodeAnalysis >= 1.0.0-rc1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue