actually, one just need an initialisation method for templates
This commit is contained in:
@ -10,8 +10,7 @@ namespace Yavsc.Abstract.Templates
|
||||
public abstract class Template
|
||||
{
|
||||
|
||||
StringBuilder _buffer = new StringBuilder();
|
||||
|
||||
StringBuilder _buffer ;
|
||||
|
||||
public virtual void Write(object 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 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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
||||
diagnostic.IsWarningAsError ||
|
||||
diagnostic.Severity == DiagnosticSeverity.Error);
|
||||
|
||||
foreach (Diagnostic diagnostic in failures)
|
||||
{
|
||||
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
|
||||
@ -142,12 +146,10 @@ namespace cli.Services
|
||||
|
||||
Type type = assembly.GetType(DefaultNamespace+"."+className);
|
||||
var generatedtemplate = (UserOrientedTemplate) Activator.CreateInstance(type);
|
||||
logger.LogInformation(generatedtemplate.ToString());
|
||||
foreach (var user in dbContext.ApplicationUser) {
|
||||
logger.LogInformation(user.ToString());
|
||||
|
||||
logger.LogInformation ("Generation for "+user.UserName);
|
||||
generatedtemplate.Init();
|
||||
generatedtemplate.User = user;
|
||||
generatedtemplate.ExecuteAsync().Wait();
|
||||
|
||||
logger.LogInformation (generatedtemplate.GeneratedText);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
||||
"Microsoft.AspNet.Identity.EntityFramework": "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.Logging.Debug": "1.0.0-rc1-final",
|
||||
"Microsoft.CodeAnalysis": "1.0.0-rc1"
|
||||
@ -46,4 +46,4 @@
|
||||
"frameworks": {
|
||||
"dnx451": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12024,7 +12024,7 @@
|
||||
"Microsoft.Extensions.Logging.Console >= 1.0.0-rc1-final",
|
||||
"Microsoft.AspNet.Identity.EntityFramework >= 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.Logging.Debug >= 1.0.0-rc1-final",
|
||||
"Microsoft.CodeAnalysis >= 1.0.0-rc1"
|
||||
|
Reference in New Issue
Block a user