Changeset 13218


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

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

Location:
trunk/sources
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/MultiObjectiveOptimizationSupportScript.cs

    r13183 r13218  
    3030  [StorableClass]
    3131  public sealed class MultiObjectiveOptimizationSupportScript : OptimizationSupportScript<IMultiObjectiveOptimizationSupport>, IMultiObjectiveOptimizationSupport {
    32 
    33     protected override string CodeTemplate {
    34       get { return Templates.CompiledMultiObjectiveOptimizationSupport; }
    35     }
    36 
    3732    [StorableConstructor]
    3833    private MultiObjectiveOptimizationSupportScript(bool deserializing) : base(deserializing) { }
    3934    private MultiObjectiveOptimizationSupportScript(MultiObjectiveOptimizationSupportScript original, Cloner cloner) : base(original, cloner) { }
    40     public MultiObjectiveOptimizationSupportScript() : base() { }
     35    public MultiObjectiveOptimizationSupportScript() : base(Templates.CompiledMultiObjectiveOptimizationSupport) { }
    4136
    4237    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/OptimizationSupportScript.cs

    r13183 r13218  
    4646    protected OptimizationSupportScript()
    4747      : base() {
     48      variableStore = new VariableStore();
     49    }
     50
     51    protected OptimizationSupportScript(string code)
     52      : base(code) {
    4853      variableStore = new VariableStore();
    4954    }
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/SingleObjectiveOptimizationSupportScript.cs

    r13183 r13218  
    3131  [StorableClass]
    3232  public sealed class SingleObjectiveOptimizationSupportScript : OptimizationSupportScript<ISingleObjectiveOptimizationSupport>, ISingleObjectiveOptimizationSupport {
    33 
    34     protected override string CodeTemplate {
    35       get { return Templates.CompiledSingleObjectiveOptimizationSupport; }
    36     }
    37 
    3833    [StorableConstructor]
    3934    private SingleObjectiveOptimizationSupportScript(bool deserializing) : base(deserializing) { }
    4035    private SingleObjectiveOptimizationSupportScript(SingleObjectiveOptimizationSupportScript original, Cloner cloner) : base(original, cloner) { }
    41     public SingleObjectiveOptimizationSupportScript() : base() { }
     36    public SingleObjectiveOptimizationSupportScript() : base(Templates.CompiledSingleObjectiveOptimizationSupport) { }
    4237
    4338    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r13212 r13218  
    3131    public string Filename { get; set; }
    3232
    33     protected override string CodeTemplate {
    34       get { return ScriptTemplates.CompiledMultiObjectiveProblemDefinition; }
    35     }
    36 
    3733    private new IMultiObjectiveProblemDefinition CompiledProblemDefinition {
    3834      get { return (IMultiObjectiveProblemDefinition)base.CompiledProblemDefinition; }
     
    4137    [StorableConstructor]
    4238    private MultiObjectiveProblemDefinitionScript(bool deserializing) : base(deserializing) { }
    43     private MultiObjectiveProblemDefinitionScript(MultiObjectiveProblemDefinitionScript original, Cloner cloner)
    44       : base(original, cloner) { }
    45 
    46     public MultiObjectiveProblemDefinitionScript() {
    47       Code = CodeTemplate;
    48     }
     39    private MultiObjectiveProblemDefinitionScript(MultiObjectiveProblemDefinitionScript original, Cloner cloner) : base(original, cloner) { }
     40    public MultiObjectiveProblemDefinitionScript() : base(ScriptTemplates.CompiledMultiObjectiveProblemDefinition) { }
    4941
    5042    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs

    r12012 r13218  
    5353    protected ProblemDefinitionScript()
    5454      : base() {
     55      variableStore = new VariableStore();
     56    }
     57    protected ProblemDefinitionScript(string code)
     58      : base(code) {
    5559      variableStore = new VariableStore();
    5660    }
  • trunk/sources/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r12012 r13218  
    3232    public string Filename { get; set; }
    3333
    34     protected override string CodeTemplate {
    35       get { return ScriptTemplates.CompiledSingleObjectiveProblemDefinition; }
    36     }
    37 
    3834    private new ISingleObjectiveProblemDefinition CompiledProblemDefinition {
    3935      get { return (ISingleObjectiveProblemDefinition)base.CompiledProblemDefinition; }
     
    4339    private SingleObjectiveProblemDefinitionScript(bool deserializing) : base(deserializing) { }
    4440    private SingleObjectiveProblemDefinitionScript(SingleObjectiveProblemDefinitionScript original, Cloner cloner) : base(original, cloner) { }
    45     public SingleObjectiveProblemDefinitionScript()
    46       : base() {
    47       Code = CodeTemplate;
    48     }
     41    public SingleObjectiveProblemDefinitionScript() : base(ScriptTemplates.CompiledSingleObjectiveProblemDefinition) { }
    4942
    5043    public override IDeepCloneable Clone(Cloner cloner) {
  • 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.