Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/17/15 14:19:44 (9 years ago)
Author:
jkarder
Message:

#2298: applied some of the changes suggested by mkommend in comment:14:ticket:2298

Location:
trunk/sources/HeuristicLab.Scripting/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Scripting/3.3/ExecutableScript.cs

    r13080 r13218  
    5252      executionTime = original.executionTime;
    5353    }
    54     public ExecutableScript()
     54    protected ExecutableScript()
    5555      : base() {
    5656      executionTime = TimeSpan.Zero;
    57       Code = CodeTemplate;
    5857    }
    59     public ExecutableScript(string code)
     58    protected ExecutableScript(string code)
    6059      : base(code) {
    6160      executionTime = TimeSpan.Zero;
     
    8584        timer.Elapsed -= timer_Elapsed;
    8685        timer.Stop();
     86        timer.Dispose();
    8787        ExecutionTime += DateTime.UtcNow - lastUpdateTime;
    8888        Running = false;
  • trunk/sources/HeuristicLab.Scripting/3.3/Script.cs

    r12616 r13218  
    3737namespace HeuristicLab.Scripting {
    3838  [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 {
    4440    #region Fields & Properties
    4541    public static new Image StaticItemImage {
     
    7773        compileErrors = new CompilerErrorCollection(original.compileErrors);
    7874    }
    79     public Script()
     75    protected Script()
    8076      : base("Script", "An empty script.") {
    81       code = CodeTemplate;
    8277    }
    83     public Script(string code)
     78    protected Script(string code)
    8479      : this() {
    8580      this.code = code;
    86     }
    87 
    88     public override IDeepCloneable Clone(Cloner cloner) {
    89       return new Script(this, cloner);
    9081    }
    9182    #endregion
    9283
    9384    #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 syntax
    99               });
    100       }
    101     }
    102 
    10385    protected virtual CompilerResults DoCompile() {
    10486      var parameters = new CompilerParameters {
     
    11496        .ToArray());
    11597
    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);
    117104    }
    118105
  • trunk/sources/HeuristicLab.Scripting/3.3/Scripts/CSharp/CSharpScript.cs

    r13080 r13218  
    3232  [StorableClass]
    3333  public class CSharpScript : ExecutableScript, IStorableContent {
    34     #region Constants
    35     protected override string CodeTemplate { get { return ScriptTemplates.CSharpScriptTemplate; } }
    36     #endregion
    37 
    3834    #region Fields & Properties
    3935    private CSharpScriptBase compiledScript;
     
    5652    }
    5753    public CSharpScript()
    58       : base() {
     54      : base(ScriptTemplates.CSharpScriptTemplate) {
    5955      variableStore = new VariableStore();
    6056    }
Note: See TracChangeset for help on using the changeset viewer.