Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7351 for trunk


Ignore:
Timestamp:
01/17/12 23:54:58 (13 years ago)
Author:
abeham
Message:

#1722

  • fixed some problems that were identified with the first existing FxCop rules (duplicate storable hook in ExternalEvaluationProblem, multiple wrong names)
  • generally renamed AttachEventHandlers to RegisterEventHandlers to be consistent
  • fixed some backwards compatible regions to use the format from the snippet and the comment
Location:
trunk/sources
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs

    r7259 r7351  
    157157      : base(original, cloner) {
    158158      paretoFrontAnalyzer = (RankBasedParetoFrontAnalyzer)cloner.Clone(original.paretoFrontAnalyzer);
    159       AttachEventHandlers();
     159      AfterDeserialization();
    160160    }
    161161    public NSGA2() {
     
    229229      UpdateAnalyzers();
    230230
    231       AttachEventHandlers();
     231      AfterDeserialization();
    232232    }
    233233
     
    310310    #region Helpers
    311311    [StorableHook(HookType.AfterDeserialization)]
    312     private void AttachEventHandlers() {
     312    private void AfterDeserialization() {
    313313      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
    314314      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
  • trunk/sources/HeuristicLab.Analysis/3.3/ValueAnalysis/MinAverageMaxValueAnalyzer.cs

    r7259 r7351  
    9494      : base(original, cloner) {
    9595      resultsCollector = cloner.Clone(original.resultsCollector);
    96       Initialize();
     96      RegisterEventHandlers();
    9797    }
    9898    public override IDeepCloneable Clone(Cloner cloner) {
     
    147147      #endregion
    148148
    149       Initialize();
     149      RegisterEventHandlers();
    150150    }
    151151
    152152    [StorableHook(HookType.AfterDeserialization)]
    153     private void Initialize() {
     153    private void AfterDeserialization() {
     154      RegisterEventHandlers();
     155    }
     156
     157    private void RegisterEventHandlers() {
    154158      ValueParameter.DepthChanged += new EventHandler(ValueParameter_DepthChanged);
    155159      CollectMinValueInResultsParameter.ValueChanged += new EventHandler(CollectMinValueInResultsParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r7259 r7351  
    6161    }
    6262
    63     [StorableHook(HookType.AfterDeserialization)]
    64     private void AfterDeserializationHook() {
    65       #region Backwards Compatibility
    66       if (!Parameters.ContainsKey("SelectedOperator")) {
    67         Parameters.Add(new LookupParameter<StringValue>("SelectedOperator", "If the TraceSelectedOperator flag is set, the name of the operator is traced in this parameter."));
    68         SelectedOperatorParameter.Hidden = false;
    69       }
    70       if (!Parameters.ContainsKey("TraceSelectedOperator")) {
    71         Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false)));
    72       }
    73       #endregion
    74     }
    75 
    7663    [StorableConstructor]
    7764    protected StochasticMultiBranch(bool deserializing) : base(deserializing) { }
     
    9077      Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false)));
    9178      SelectedOperatorParameter.Hidden = false;
     79    }
     80
     81    [StorableHook(HookType.AfterDeserialization)]
     82    private void AfterDeserialization() {
     83      // BackwardsCompatibility3.3
     84      #region Backwards compatible code, remove with 3.4
     85      if (!Parameters.ContainsKey("SelectedOperator")) {
     86        Parameters.Add(new LookupParameter<StringValue>("SelectedOperator", "If the TraceSelectedOperator flag is set, the name of the operator is traced in this parameter."));
     87        SelectedOperatorParameter.Hidden = false;
     88      }
     89      if (!Parameters.ContainsKey("TraceSelectedOperator")) {
     90        Parameters.Add(new ValueParameter<BoolValue>("TraceSelectedOperator", "Indicates, if the selected operator should be traced.", new BoolValue(false)));
     91      }
     92      #endregion
    9293    }
    9394
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdingDistanceAssignment.cs

    r7259 r7351  
    5353      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The vector of quality values."));
    5454      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("CrowdingDistance", "Sets the crowding distance in each sub-scope."));
    55       AttachEventHandlers();
     55      RegisterEventHandlers();
    5656    }
    5757
    5858    [StorableHook(HookType.AfterDeserialization)]
    59     private void AttachEventHandlers() {
     59    private void AfterDeserialization() {
     60      RegisterEventHandlers();
     61    }
     62
     63    private void RegisterEventHandlers() {
    6064      QualitiesParameter.DepthChanged += new EventHandler(QualitiesParameter_DepthChanged);
    6165    }
  • trunk/sources/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r7259 r7351  
    121121    [StorableHook(HookType.AfterDeserialization)]
    122122    private void AfterDeserialization() {
    123       AttachEventHandlers();
     123      RegisterEventHandlers();
    124124    }
    125125    public UserDefinedProblem()
     
    132132      Parameters.Add(new ValueParameter<ItemList<IOperator>>("Operators", "The operators that are passed to the algorithm.", new ItemList<IOperator>()));
    133133
    134       AttachEventHandlers();
     134      RegisterEventHandlers();
    135135    }
    136136
    137137    private UserDefinedProblem(UserDefinedProblem original, Cloner cloner)
    138138      : base(original, cloner) {
    139       AttachEventHandlers();
     139      RegisterEventHandlers();
    140140    }
    141141    public override IDeepCloneable Clone(Cloner cloner) {
     
    194194
    195195    #region Helpers
    196     private void AttachEventHandlers() {
     196    private void RegisterEventHandlers() {
    197197      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    198198      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs

    r7259 r7351  
    151151    [StorableHook(HookType.AfterDeserialization)]
    152152    private void AfterDeserialization() {
    153       AttachEventHandlers();
     153      RegisterEventHandlers();
    154154    }
    155155
    156156    private ArtificialAntProblem(ArtificialAntProblem original, Cloner cloner)
    157157      : base(original, cloner) {
    158       AttachEventHandlers();
     158      RegisterEventHandlers();
    159159    }
    160160    public override IDeepCloneable Clone(Cloner cloner) {
     
    179179      Evaluator.QualityParameter.ActualName = "FoodEaten";
    180180      InitializeOperators();
    181       AttachEventHandlers();
     181      RegisterEventHandlers();
    182182    }
    183183
     
    212212
    213213    #region Helpers
    214     private void AttachEventHandlers() {
     214    private void RegisterEventHandlers() {
    215215      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    216216      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluationProblem.cs

    r7259 r7351  
    127127    [StorableConstructor]
    128128    private ExternalEvaluationProblem(bool deserializing) : base(deserializing) { }
    129     [StorableHook(HookType.AfterDeserialization)]
    130     private void AfterDeserializationHook() {
    131       AttachEventHandlers();
    132     }
    133 
    134129    private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner)
    135130      : base(original, cloner) {
    136       AttachEventHandlers();
     131      RegisterEventHandlers();
    137132    }
    138133    public override IDeepCloneable Clone(Cloner cloner) {
     
    154149
    155150      InitializeOperators();
    156       AttachEventHandlers();
     151      RegisterEventHandlers();
    157152    }
    158153    [StorableHook(HookType.AfterDeserialization)]
     
    170165      }
    171166      #endregion
     167      RegisterEventHandlers();
    172168    }
    173169
     
    220216
    221217    #region Helper
    222     private void AttachEventHandlers() {
     218    private void RegisterEventHandlers() {
    223219      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    224220      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/SolutionMessageBuilder.cs

    r7259 r7351  
    5252    [StorableHook(HookType.AfterDeserialization)]
    5353    private void AfterDeserialization() {
    54       AttachEventHandlers();
     54      // BackwardsCompatibility3.3
     55      #region Backwards compatible code, remove with 3.4
     56#pragma warning disable 0612
     57      if (converters != null) {
     58        if (convertersList == null) convertersList = new CheckedItemList<IItemToSolutionMessageConverter>();
     59        foreach (IItemToSolutionMessageConverter c in converters)
     60          convertersList.Add(c);
     61        converters.Clear();
     62        converters = null;
     63      }
     64#pragma warning restore 0612
     65      #endregion
     66      RegisterEventHandlers();
    5567    }
    5668
     
    5870      : base(original, cloner) {
    5971      convertersList = cloner.Clone(original.convertersList);
    60       AttachEventHandlers();
     72      RegisterEventHandlers();
    6173    }
    6274    public override IDeepCloneable Clone(Cloner cloner) {
     
    7587      convertersList.Add(new TimeSpanValueConverter());
    7688
    77       AttachEventHandlers();
     89      RegisterEventHandlers();
    7890    }
    7991
     
    93105    }
    94106
    95     private void AttachEventHandlers() {
    96       // BackwardsCompatibility3.3
    97       #region Backwards compatible code, remove with 3.4
    98 #pragma warning disable 0612
    99       if (converters != null) {
    100         if (convertersList == null) convertersList = new CheckedItemList<IItemToSolutionMessageConverter>();
    101         foreach (IItemToSolutionMessageConverter c in converters)
    102           convertersList.Add(c);
    103         converters.Clear();
    104         converters = null;
    105       }
    106 #pragma warning restore 0612
    107       #endregion
     107    private void RegisterEventHandlers() {
    108108      convertersList.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IItemToSolutionMessageConverter>>(convertersList_Changed);
    109109      convertersList.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IItemToSolutionMessageConverter>>(convertersList_Changed);
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r7259 r7351  
    100100    private KnapsackProblem(KnapsackProblem original, Cloner cloner)
    101101      : base(original, cloner) {
    102       AttachEventHandlers();
     102      RegisterEventHandlers();
    103103    }
    104104    public override IDeepCloneable Clone(Cloner cloner) {
     
    124124
    125125      InitializeOperators();
    126       AttachEventHandlers();
     126      RegisterEventHandlers();
    127127    }
    128128
     
    194194      if (Operators.Count == 0) InitializeOperators();
    195195      #endregion
    196       AttachEventHandlers();
    197     }
    198 
    199     private void AttachEventHandlers() {
     196      RegisterEventHandlers();
     197    }
     198
     199    private void RegisterEventHandlers() {
    200200      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    201201      KnapsackCapacityParameter.ValueChanged += new EventHandler(KnapsackCapacityParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs

    r7259 r7351  
    7272    private OneMaxProblem(OneMaxProblem original, Cloner cloner)
    7373      : base(original, cloner) {
    74       AttachEventHandlers();
     74      RegisterEventHandlers();
    7575    }
    7676    public OneMaxProblem()
     
    8888
    8989      InitializeOperators();
    90       AttachEventHandlers();
     90      RegisterEventHandlers();
    9191    }
    9292
     
    140140      if (Operators.Count == 0) InitializeOperators();
    141141      #endregion
    142       AttachEventHandlers();
     142      RegisterEventHandlers();
    143143    }
    144144
    145     private void AttachEventHandlers() {
     145    private void RegisterEventHandlers() {
    146146      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    147147      LengthParameter.ValueChanged += new EventHandler(LengthParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r7259 r7351  
    109109    private QuadraticAssignmentProblem(QuadraticAssignmentProblem original, Cloner cloner)
    110110      : base(original, cloner) {
    111       AttachEventHandlers();
     111      RegisterEventHandlers();
    112112    }
    113113    public QuadraticAssignmentProblem()
     
    142142
    143143      InitializeOperators();
    144       AttachEventHandlers();
     144      RegisterEventHandlers();
    145145    }
    146146
     
    165165        Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", d));
    166166      }
    167       AttachEventHandlers();
     167      RegisterEventHandlers();
    168168      #endregion
    169169    }
     
    254254
    255255    #region Helpers
    256     private void AttachEventHandlers() {
     256    private void RegisterEventHandlers() {
    257257      SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    258258      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r7259 r7351  
    9292      strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover);
    9393      strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator);
    94       AttachEventHandlers();
     94      RegisterEventHandlers();
    9595    }
    9696    public SingleObjectiveTestFunctionProblem()
     
    115115
    116116      InitializeOperators();
    117       AttachEventHandlers();
     117      RegisterEventHandlers();
    118118      UpdateStrategyVectorBounds();
    119119    }
     
    232232      if (Operators.Count == 0) InitializeOperators();
    233233      #endregion
    234       AttachEventHandlers();
    235     }
    236 
    237     private void AttachEventHandlers() {
     234      RegisterEventHandlers();
     235    }
     236
     237    private void RegisterEventHandlers() {
    238238      ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
    239239      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r7259 r7351  
    100100    private TravelingSalesmanProblem(TravelingSalesmanProblem original, Cloner cloner)
    101101      : base(original, cloner) {
    102       AttachEventHandlers();
     102      RegisterEventHandlers();
    103103    }
    104104    public override IDeepCloneable Clone(Cloner cloner) {
     
    130130
    131131      InitializeOperators();
    132       AttachEventHandlers();
     132      RegisterEventHandlers();
    133133    }
    134134
     
    197197      if (Operators.Count == 0) InitializeOperators();
    198198      #endregion
    199       AttachEventHandlers();
    200     }
    201 
    202     private void AttachEventHandlers() {
     199      RegisterEventHandlers();
     200    }
     201
     202    private void RegisterEventHandlers() {
    203203      CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
    204204      Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestVRPSolutionAnalyzer.cs

    r7259 r7351  
    125125
    126126    [StorableHook(HookType.AfterDeserialization)]
    127     private void AfterDeserializationHook() {
    128       #region Backwards Compatibility
     127    private void AfterDeserialization() {
     128      // BackwardsCompatibility3.3
     129      #region Backwards compatible code, remove with 3.4
    129130      if (!Parameters.ContainsKey("BestKnownQuality")) {
    130131        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r7259 r7351  
    155155    private VehicleRoutingProblem(VehicleRoutingProblem original, Cloner cloner)
    156156      : base(original, cloner) {
    157       AttachEventHandlers();
     157      RegisterEventHandlers();
    158158    }
    159159    public VehicleRoutingProblem()
     
    187187
    188188      InitializeOperators();
    189       AttachEventHandlers();
     189      RegisterEventHandlers();
    190190    }
    191191
     
    355355    #region Helpers
    356356    [StorableHook(HookType.AfterDeserialization)]
    357     private void AfterDeserializationHook() {
    358       #region Backwards Compatibility
     357    private void AfterDeserialization() {
     358      // BackwardsCompatibility3.3
     359      #region Backwards compatible code, remove with 3.4
    359360      if (!Parameters.ContainsKey("BestKnownSolution")) {
    360361        Parameters.Add(new OptionalValueParameter<IVRPEncoding>("BestKnownSolution", "The best known solution of this TSP instance."));
     
    362363      #endregion
    363364
    364       AttachEventHandlers();
    365     }
    366 
    367     private void AttachEventHandlers() {
     365      RegisterEventHandlers();
     366    }
     367
     368    private void RegisterEventHandlers() {
    368369      CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
    369370      Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged);
Note: See TracChangeset for help on using the changeset viewer.