Changeset 13218 for trunk/sources/HeuristicLab.Scripting
- Timestamp:
- 11/17/15 14:19:44 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Scripting/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Scripting/3.3/ExecutableScript.cs
r13080 r13218 52 52 executionTime = original.executionTime; 53 53 } 54 p ublicExecutableScript()54 protected ExecutableScript() 55 55 : base() { 56 56 executionTime = TimeSpan.Zero; 57 Code = CodeTemplate;58 57 } 59 p ublicExecutableScript(string code)58 protected ExecutableScript(string code) 60 59 : base(code) { 61 60 executionTime = TimeSpan.Zero; … … 85 84 timer.Elapsed -= timer_Elapsed; 86 85 timer.Stop(); 86 timer.Dispose(); 87 87 ExecutionTime += DateTime.UtcNow - lastUpdateTime; 88 88 Running = false; -
trunk/sources/HeuristicLab.Scripting/3.3/Script.cs
r12616 r13218 37 37 namespace HeuristicLab.Scripting { 38 38 [StorableClass] 39 public class Script : NamedItem, IProgrammableItem { 40 protected virtual string CodeTemplate { 41 get { return string.Empty; } 42 } 43 39 public abstract class Script : NamedItem, IProgrammableItem { 44 40 #region Fields & Properties 45 41 public static new Image StaticItemImage { … … 77 73 compileErrors = new CompilerErrorCollection(original.compileErrors); 78 74 } 79 p ublicScript()75 protected Script() 80 76 : base("Script", "An empty script.") { 81 code = CodeTemplate;82 77 } 83 p ublicScript(string code)78 protected Script(string code) 84 79 : this() { 85 80 this.code = code; 86 }87 88 public override IDeepCloneable Clone(Cloner cloner) {89 return new Script(this, cloner);90 81 } 91 82 #endregion 92 83 93 84 #region Compilation 94 protected virtual CSharpCodeProvider CodeProvider {95 get {96 return new CSharpCodeProvider(97 new Dictionary<string, string> {98 {"CompilerVersion", "v4.0"}, // support C# 4.0 syntax99 });100 }101 }102 103 85 protected virtual CompilerResults DoCompile() { 104 86 var parameters = new CompilerParameters { … … 114 96 .ToArray()); 115 97 116 return CodeProvider.CompileAssemblyFromSource(parameters, code); 98 var codeProvider = new CSharpCodeProvider( 99 new Dictionary<string, string> { 100 { "CompilerVersion", "v4.0"} // support C# 4.0 syntax 101 }); 102 103 return codeProvider.CompileAssemblyFromSource(parameters, code); 117 104 } 118 105 -
trunk/sources/HeuristicLab.Scripting/3.3/Scripts/CSharp/CSharpScript.cs
r13080 r13218 32 32 [StorableClass] 33 33 public class CSharpScript : ExecutableScript, IStorableContent { 34 #region Constants35 protected override string CodeTemplate { get { return ScriptTemplates.CSharpScriptTemplate; } }36 #endregion37 38 34 #region Fields & Properties 39 35 private CSharpScriptBase compiledScript; … … 56 52 } 57 53 public CSharpScript() 58 : base( ) {54 : base(ScriptTemplates.CSharpScriptTemplate) { 59 55 variableStore = new VariableStore(); 60 56 }
Note: See TracChangeset
for help on using the changeset viewer.