Changeset 2757 for trunk/sources/HeuristicLab.Operators/3.3/ScopeCleaner.cs
- Timestamp:
- 02/08/10 03:43:36 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/ScopeCleaner.cs
r1530 r2757 24 24 using System.Text; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 28 29 namespace HeuristicLab.Operators { 29 30 /// <summary> 30 /// Operator that removes all variables in the given scope and deletes also all subscopes.31 /// An operator which removes all variables and sub-scopes from the current scope. 31 32 /// </summary> 32 public class ScopeCleaner : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"Removes all variables in the current scope and deletes all subscopes"; } 33 [Item("ScopeCleaner", "An operator which removes all variables and sub-scopes from the current scope.")] 34 [EmptyStorableClass] 35 [Creatable("Test")] 36 public sealed class ScopeCleaner : SingleSuccessorOperator { 37 private ScopeParameter CurrentScopeParameter { 38 get { return (ScopeParameter)Parameters["CurrentScope"]; } 39 } 40 public IScope CurrentScope { 41 get { return CurrentScopeParameter.ActualValue; } 36 42 } 37 43 38 /// <summary>39 /// Deletes all variable and sub scopes from the given <paramref name="scope"/>.40 /// </summary>41 /// <remarks>Calls <see cref="IScope.Clear"/> of interface <see cref="IScope"/>.</remarks>42 /// <param name="scope">The scope to clear.</param> 43 /// <returns><c>null</c>.</returns>44 public override IOperation Apply(IScope scope) {45 scope.Clear();46 return null;44 public ScopeCleaner() 45 : base() { 46 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose variables and sub-scopes should be removed.")); 47 } 48 49 public override IExecutionContext Apply() { 50 CurrentScope.Variables.Clear(); 51 CurrentScope.SubScopes.Clear(); 52 return base.Apply(); 47 53 } 48 54 }
Note: See TracChangeset
for help on using the changeset viewer.