Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ITemplate Compile (string path, string id, string input, List<string> usings)
  2.     <- assembly.CreateInstance (typeName)
  3.    
  4.         typeName = "Templates_Template_{0}_{1}".FormatWith (id, DateTime.Now.Ticks)
  5.         assembly = results.CompiledAssembly
  6.         results = provider.CompileAssemblyFromSource (options, code)
  7.        
  8.             provider = new CSharpProvider
  9.                 <- new Dictionary<string, string>
  10.                     <- {"CompilerVersion", "v4.0"}
  11.                    
  12.             options = new CompilerParameters
  13.                 .ReferenceAssemblies.Add
  14.                     "System.dll"
  15.                     "System.Core.dll"
  16.                     "Microsoft.CSharp.dll"
  17.                     path + "Zero.Web.dll"
  18.                     path + "Zero.Core.dll"
  19.                 .GenerateInMemory = true
  20.                
  21.             code = inputs.Join("")
  22.                 inputs = new[]
  23.                     <- usingsStr
  24.                     <- "@constant #1...."
  25.                     <- "@constant #2...."                
  26.                     <- input
  27.                         usingsStr = builder.ToString()
  28.                             builder = new StringBuilder()
  29.                                 .AppendFormat ("using {0};", u)
  30.                                     u in usings
  31.                                    
  32.             .Errors.HasErrors ?
  33.                 throw new Exception(code + "\n Compiler error: " + b)
  34.                     b = new StringBuilder()
  35.                         .Append (e)
  36.                             e in results.Errors