Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/ConstrainedItemList.cs @ 16574

Last change on this file since 16574 was 16574, checked in by gkronber, 5 years ago

#2520: changed HeuristicLab.MetaOptimization addon to compile with new HL.Persistence

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using HeuristicLab.Common;
8using HEAL.Attic;
9
10namespace HeuristicLab.Problems.MetaOptimization {
11  [StorableType("D5AB5F97-8D08-4BE4-AB71-BA670EA26B6D")]
12  public class ConstrainedItemList<T> : ItemList<T> where T : class, IItem {
13    [Storable]
14    private Type type;
15    public Type Type {
16      get { return type; }
17      set {
18        if (type != value) {
19          type = value;
20          this.RemoveAll(x => x.GetType() != type);
21        }
22      }
23    }
24
25    public ConstrainedItemList() {
26      Type = typeof(T);
27    }
28    [StorableConstructor]
29    protected ConstrainedItemList(StorableConstructorFlag _) : base(_) { }
30    protected ConstrainedItemList(ConstrainedItemList<T> original, Cloner cloner)
31      : base(original, cloner) {
32      this.Type = original.Type;
33    }
34    public override IDeepCloneable Clone(Cloner cloner) {
35      return new ConstrainedItemList<T>(this, cloner);
36    }
37  }
38}
Note: See TracBrowser for help on using the repository browser.