Changeset 11657 for trunk/sources/HeuristicLab.Scripting
- Timestamp:
- 12/04/14 17:14:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Scripting/3.3/Script.cs
r11477 r11657 24 24 using System.CodeDom.Compiler; 25 25 using System.Collections.Generic; 26 using System.Diagnostics;27 26 using System.Drawing; 28 27 using System.IO; … … 80 79 public Script() 81 80 : base("Script", "An empty script.") { 82 code = string.Empty;81 code = CodeTemplate; 83 82 } 84 83 public Script(string code) … … 109 108 WarningLevel = 4 110 109 }; 110 111 111 parameters.ReferencedAssemblies.AddRange( 112 112 GetAssemblies() 113 113 .Select(a => a.Location) 114 114 .ToArray()); 115 var unit = CreateCompilationUnit(); 116 var writer = new StringWriter(); 117 CodeProvider.GenerateCodeFromCompileUnit( 118 unit, 119 writer, 120 new CodeGeneratorOptions { 121 ElseOnClosing = true, 122 IndentString = " ", 123 }); 124 return CodeProvider.CompileAssemblyFromDom(parameters, unit); 115 116 return CodeProvider.CompileAssemblyFromSource(parameters, code); 125 117 } 126 118 … … 135 127 .AppendLine(error.ErrorText); 136 128 } 137 throw new Exception(string.Format("Compilation of \"{0}\" failed:{1}{2}",129 throw new InvalidOperationException(string.Format("Compilation of \"{0}\" failed:{1}{2}", 138 130 Name, Environment.NewLine, sb.ToString())); 139 131 } else { … … 143 135 144 136 public virtual IEnumerable<Assembly> GetAssemblies() { 145 var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList(); 137 var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList(); 146 138 assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality 147 139 return assemblies;
Note: See TracChangeset
for help on using the changeset viewer.