Changeset 4838
- Timestamp:
- 11/18/10 16:47:16 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators.Programmable/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
r4828 r4838 193 193 [StorableHook(HookType.AfterDeserialization)] 194 194 private void AfterDeserialization() { 195 // ensure default namespaces and assemblies are present if deserializing old operators 196 namespaces.Add("HeuristicLab.Operators.Programmable"); 197 Assemblies[typeof(HeuristicLab.Operators.Operator).Assembly] = true; 198 Assemblies[typeof(HeuristicLab.Operators.Programmable.ProgrammableOperator).Assembly] = true; 195 199 RegisterEvents(); 196 200 } … … 254 258 typeof(System.Text.StringBuilder).Assembly, 255 259 typeof(System.Data.Linq.DataContext).Assembly, 260 typeof(System.ComponentModel.INotifyPropertyChanged).Assembly, 256 261 typeof(HeuristicLab.Common.IDeepCloneable).Assembly, 257 262 typeof(HeuristicLab.Core.Item).Assembly, … … 259 264 typeof(HeuristicLab.Parameters.ValueParameter<IItem>).Assembly, 260 265 typeof(HeuristicLab.Collections.ObservableList<IItem>).Assembly, 261 typeof( System.ComponentModel.INotifyPropertyChanged).Assembly,262 266 typeof(HeuristicLab.Operators.Operator).Assembly, 267 typeof(HeuristicLab.Operators.Programmable.ProgrammableOperator).Assembly, 263 268 }; 264 269 … … 293 298 "HeuristicLab.Data", 294 299 "HeuristicLab.Parameters", 300 "HeuristicLab.Operators.Programmable", 295 301 "System", 296 302 "System.Collections.Generic", … … 399 405 var sb = new StringBuilder() 400 406 .Append("public static IOperation Execute(") 401 .Append(TypeNameParser.Parse( typeof(IOperator).FullName).GetTypeNameInCode(namespaces))407 .Append(TypeNameParser.Parse(GetType().FullName).GetTypeNameInCode(namespaces)) 402 408 .Append(" op, ") 403 409 .Append(TypeNameParser.Parse(typeof(IExecutionContext).FullName).GetTypeNameInCode(namespaces)) … … 421 427 method.ReturnType = new CodeTypeReference(typeof(IOperation)); 422 428 method.Attributes = MemberAttributes.Public | MemberAttributes.Static; 423 method.Parameters.Add(new CodeParameterDeclarationExpression( typeof(IOperator), "op"));429 method.Parameters.Add(new CodeParameterDeclarationExpression(GetType(), "op")); 424 430 method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IExecutionContext), "context")); 425 431 foreach (var param in Parameters) … … 429 435 codeLines[i] = string.Format("#line {0} \"ProgrammableOperator\"{1}{2}", i + 1, "\r\n", codeLines[i]); 430 436 } 431 method.Statements.Add(new CodeSnippetStatement( 432 string.Join("\r\n", codeLines) + 433 "\r\nreturn null;")); 437 method.Statements.Add(new CodeSnippetStatement(string.Join("\r\n", codeLines) + MethodSuffix)); 434 438 return method; 439 } 440 441 public virtual string MethodSuffix { 442 get { return "return null;"; } 435 443 } 436 444 -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs
r4477 r4838 71 71 } else { 72 72 codeEditor.Prefix = GetGeneratedPrefix(); 73 codeEditor.Suffix = @" return null; 74 } 75 }"; 73 codeEditor.Suffix = String.Format(" {0}\n }}\n}}", ProgrammableOperator.MethodSuffix); 76 74 codeEditor.UserCode = ProgrammableOperator.Code; 77 75 if (codeEditor.UserCode == "") … … 121 119 ProgrammableOperator.Compile(); 122 120 MessageBox.Show("Compilation successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); 123 } 124 catch (Exception ex) { 121 } catch (Exception ex) { 125 122 ErrorHandling.ShowErrorDialog(this, ex); 126 123 } -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableSingleSuccessorOperator.cs
r4828 r4838 9 9 [StorableClass] 10 10 public class ProgrammableSingleSuccessorOperator : ProgrammableOperator { 11 12 public IOperator Successor { 13 get { 14 IParameter parameter; 15 Parameters.TryGetValue("Successor", out parameter); 16 OperatorParameter successorParameter = parameter as OperatorParameter; 17 if (successorParameter == null) 18 return null; 19 return successorParameter.Value; 20 } 21 set { 22 ((OperatorParameter)Parameters["Successor"]).Value = value; 23 } 24 } 11 25 12 26 [StorableConstructor] … … 24 38 } 25 39 26 public override IOperation Apply() { 27 IOperation operation = base.Apply(); 28 if (operation != null) 29 return operation; 30 IParameter parameter; 31 Parameters.TryGetValue("Successor", out parameter); 32 OperatorParameter successorParameter = parameter as OperatorParameter; 33 if (successorParameter != null && successorParameter.Value != null) 34 return ExecutionContext.CreateOperation(successorParameter.Value); 35 else 36 return null; 40 public override string MethodSuffix { 41 get { return "return op.Successor == null ? null : context.CreateOperation(op.Successor);"; } 37 42 } 38 43 }
Note: See TracChangeset
for help on using the changeset viewer.