public async Task <string> ProcessRazorTemplate(string content) { var className = "GeneratedClass"; var classNamespace = "Generated"; var assemblyName = "Generated"; var preprocessResult = PreprocessRazorTemplate(content, className, classNamespace); var compiler = new RoslynCompilationService(_libraryExporter, _host); var assembly = compiler.Compile(assemblyName, preprocessResult); var instanceType = assembly.GetType(classNamespace + "." + className); var instance = (TemplateBase)Activator.CreateInstance(instanceType); return(await instance.GenerateCodeAsync()); }
public string ProcessT4Template(string content) { var className = "GeneratedClass"; var classNamespace = "Generated"; var assemblyName = "Generated"; var preResult = PreprocessT4Template(content, className, classNamespace); var compiler = new RoslynCompilationService(_libraryExporter, _host); var transformationAssembly = compiler.Compile(assemblyName, preResult); var transformationType = transformationAssembly.GetType(classNamespace + "." + className); var transformation = (TextTransformationBase)Activator.CreateInstance(transformationType); transformation.Host = _host; return(transformation.TransformText()); }