Created
August 25, 2011 10:58
-
-
Save vietnt/1170434 to your computer and use it in GitHub Desktop.
_new real-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITemplate Compile (string path, string id, string input, List<string> usings) | |
<- assembly.CreateInstance (typeName) | |
typeName = "Templates_Template_{0}_{1}".FormatWith (id, DateTime.Now.Ticks) | |
assembly = results.CompiledAssembly | |
results = provider.CompileAssemblyFromSource (options, code) | |
provider = new CSharpProvider | |
<- new Dictionary<string, string> | |
<- {"CompilerVersion", "v4.0"} | |
options = new CompilerParameters | |
.ReferenceAssemblies.Add | |
"System.dll" | |
"System.Core.dll" | |
"Microsoft.CSharp.dll" | |
path + "Zero.Web.dll" | |
path + "Zero.Core.dll" | |
.GenerateInMemory = true | |
code = inputs.Join("") | |
inputs = new[] | |
<- usingsStr | |
<- "@constant #1...." | |
<- "@constant #2...." | |
<- input | |
usingsStr = builder.ToString() | |
builder = new StringBuilder() | |
.AppendFormat ("using {0};", u) | |
u in usings | |
.Errors.HasErrors ? | |
throw new Exception(code + "\n Compiler error: " + b) | |
b = new StringBuilder() | |
.Append (e) | |
e in results.Errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
c# source https://gist.github.com/1170443