Changeset 3390 for trunk/sources/HeuristicLab.Core/3.3
- Timestamp:
- 04/18/10 02:27:02 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3
- Files:
-
- 15 added
- 1 edited
- 13 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemArray.cs
r3381 r3390 35 35 [StorableClass] 36 36 [Item("ItemArray<T>", "Represents an array of items.")] 37 public class ItemArray<T> : ObservableArray<T>, IItem where T : class, IItem {37 public class ItemArray<T> : ObservableArray<T>, IItemArray<T> where T : class, IItem { 38 38 public virtual string ItemName { 39 39 get { return ItemAttribute.GetName(this.GetType()); } … … 46 46 } 47 47 48 public ItemArray() : base() { } 49 public ItemArray(int length) : base(length) { } 50 public ItemArray(T[] array) : base(array) { } 51 public ItemArray(IEnumerable<T> collection) : base(collection) { } 48 [Storable] 49 private T[] Items { 50 get { return array; } 51 set { array = value; } 52 } 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !(array.IsReadOnly)) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemArray() 68 : base() { 69 readOnlyView = array.IsReadOnly; 70 } 71 public ItemArray(int length) 72 : base(length) { 73 readOnlyView = array.IsReadOnly; 74 } 75 public ItemArray(T[] array) 76 : base(array) { 77 readOnlyView = array.IsReadOnly; 78 } 79 public ItemArray(IEnumerable<T> collection) 80 : base(collection) { 81 readOnlyView = array.IsReadOnly; 82 } 83 [StorableConstructor] 84 protected ItemArray(bool deserializing) { } 52 85 53 86 public object Clone() { 54 87 return Clone(new Cloner()); 55 88 } 56 57 89 public virtual IDeepCloneable Clone(Cloner cloner) { 58 90 ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType()); 59 91 cloner.RegisterClonedObject(this, clone); 60 clone. ReadOnlyView = ReadOnlyView;92 clone.readOnlyView = readOnlyView; 61 93 clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray(); 62 94 return clone; 95 } 96 97 public new ReadOnlyItemArray<T> AsReadOnly() { 98 return new ReadOnlyItemArray<T>(this); 63 99 } 64 100 … … 77 113 if (handler != null) handler(this, EventArgs.Empty); 78 114 } 115 public event EventHandler ReadOnlyViewChanged; 116 protected virtual void OnReadOnlyViewChanged() { 117 EventHandler handler = ReadOnlyViewChanged; 118 if (handler != null) handler(this, EventArgs.Empty); 119 } 79 120 } 80 121 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemCollection.cs
r3381 r3390 32 32 [StorableClass] 33 33 [Item("ItemCollection<T>", "Represents a collection of items.")] 34 public class ItemCollection<T> : ObservableCollection<T>, IItem where T : class, IItem {34 public class ItemCollection<T> : ObservableCollection<T>, IItemCollection<T> where T : class, IItem { 35 35 public virtual string ItemName { 36 36 get { return ItemAttribute.GetName(this.GetType()); } … … 43 43 } 44 44 45 public ItemCollection() : base() { } 46 public ItemCollection(int capacity) : base(capacity) { } 47 public ItemCollection(IEnumerable<T> collection) : base(collection) { } 45 [Storable] 46 private List<T> Items { 47 get { return list; } 48 set { list = value; } 49 } 50 51 [Storable] 52 private bool readOnlyView; 53 public virtual bool ReadOnlyView { 54 get { return readOnlyView; } 55 set { 56 if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) { 57 readOnlyView = value; 58 OnReadOnlyViewChanged(); 59 OnPropertyChanged("ReadOnlyView"); 60 } 61 } 62 } 63 64 public ItemCollection() 65 : base() { 66 readOnlyView = ((ICollection<T>)list).IsReadOnly; 67 } 68 public ItemCollection(int capacity) 69 : base(capacity) { 70 readOnlyView = ((ICollection<T>)list).IsReadOnly; 71 } 72 public ItemCollection(IEnumerable<T> collection) 73 : base(collection) { 74 readOnlyView = ((ICollection<T>)list).IsReadOnly; 75 } 76 [StorableConstructor] 77 protected ItemCollection(bool deserializing) { } 48 78 49 79 public object Clone() { 50 80 return Clone(new Cloner()); 51 81 } 52 53 82 public virtual IDeepCloneable Clone(Cloner cloner) { 54 83 ItemCollection<T> clone = (ItemCollection<T>)Activator.CreateInstance(this.GetType()); 55 84 cloner.RegisterClonedObject(this, clone); 56 clone. ReadOnlyView = ReadOnlyView;85 clone.readOnlyView = readOnlyView; 57 86 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 58 87 return clone; 88 } 89 90 public new ReadOnlyItemCollection<T> AsReadOnly() { 91 return new ReadOnlyItemCollection<T>(this); 59 92 } 60 93 … … 73 106 if (handler != null) handler(this, EventArgs.Empty); 74 107 } 108 public event EventHandler ReadOnlyViewChanged; 109 protected virtual void OnReadOnlyViewChanged() { 110 EventHandler handler = ReadOnlyViewChanged; 111 if (handler != null) handler(this, EventArgs.Empty); 112 } 75 113 } 76 114 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs
r3381 r3390 35 35 [StorableClass] 36 36 [Item("ItemList<T>", "Represents a list of items.")] 37 public class ItemList<T> : ObservableList<T>, IItem where T : class, IItem {37 public class ItemList<T> : ObservableList<T>, IItemList<T> where T : class, IItem { 38 38 public virtual string ItemName { 39 39 get { return ItemAttribute.GetName(this.GetType()); } … … 46 46 } 47 47 48 public ItemList() : base() { } 49 public ItemList(int capacity) : base(capacity) { } 50 public ItemList(IEnumerable<T> collection) : base(collection) { } 48 [Storable] 49 private List<T> Items { 50 get { return list; } 51 set { list = value; } 52 } 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !((ICollection<T>)list).IsReadOnly) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemList() 68 : base() { 69 readOnlyView = ((ICollection<T>)list).IsReadOnly; 70 } 71 public ItemList(int capacity) 72 : base(capacity) { 73 readOnlyView = ((ICollection<T>)list).IsReadOnly; 74 } 75 public ItemList(IEnumerable<T> collection) 76 : base(collection) { 77 readOnlyView = ((ICollection<T>)list).IsReadOnly; 78 } 79 [StorableConstructor] 80 protected ItemList(bool deserializing) { } 51 81 52 82 public object Clone() { 53 83 return Clone(new Cloner()); 54 84 } 55 56 85 public virtual IDeepCloneable Clone(Cloner cloner) { 57 86 ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType()); 58 87 cloner.RegisterClonedObject(this, clone); 59 clone. ReadOnlyView = ReadOnlyView;88 clone.readOnlyView = readOnlyView; 60 89 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 61 90 return clone; 91 } 92 93 public new ReadOnlyItemList<T> AsReadOnly() { 94 return new ReadOnlyItemList<T>(this); 62 95 } 63 96 … … 76 109 if (handler != null) handler(this, EventArgs.Empty); 77 110 } 111 public event EventHandler ReadOnlyViewChanged; 112 protected virtual void OnReadOnlyViewChanged() { 113 EventHandler handler = ReadOnlyViewChanged; 114 if (handler != null) handler(this, EventArgs.Empty); 115 } 78 116 } 79 117 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemSet.cs
r3381 r3390 35 35 [StorableClass] 36 36 [Item("ItemSet<T>", "Represents a set of items.")] 37 public class ItemSet<T> : ObservableSet<T>, IItem where T : class, IItem {37 public class ItemSet<T> : ObservableSet<T>, IItemSet<T> where T : class, IItem { 38 38 public virtual string ItemName { 39 39 get { return ItemAttribute.GetName(this.GetType()); } … … 46 46 } 47 47 48 public ItemSet() : base() { } 49 public ItemSet(IEnumerable<T> collection) : base(collection) { } 48 [Storable] 49 private HashSet<T> Items { 50 get { return set; } 51 set { set = value; } 52 } 53 54 [Storable] 55 private bool readOnlyView; 56 public virtual bool ReadOnlyView { 57 get { return readOnlyView; } 58 set { 59 if ((readOnlyView != value) && !((ICollection<T>)set).IsReadOnly) { 60 readOnlyView = value; 61 OnReadOnlyViewChanged(); 62 OnPropertyChanged("ReadOnlyView"); 63 } 64 } 65 } 66 67 public ItemSet() 68 : base() { 69 readOnlyView = ((ICollection<T>)set).IsReadOnly; 70 } 71 public ItemSet(IEnumerable<T> collection) 72 : base(collection) { 73 readOnlyView = ((ICollection<T>)set).IsReadOnly; 74 } 75 [StorableConstructor] 76 protected ItemSet(bool deserializing) { } 50 77 51 78 public object Clone() { 52 79 return Clone(new Cloner()); 53 80 } 54 55 81 public virtual IDeepCloneable Clone(Cloner cloner) { 56 82 ItemSet<T> clone = (ItemSet<T>)Activator.CreateInstance(this.GetType()); 57 83 cloner.RegisterClonedObject(this, clone); 58 clone. ReadOnlyView = ReadOnlyView;84 clone.readOnlyView = readOnlyView; 59 85 clone.set = new HashSet<T>(this.Select(x => (T)cloner.Clone(x))); 60 86 return clone; 87 } 88 89 public new ReadOnlyItemSet<T> AsReadOnly() { 90 return new ReadOnlyItemSet<T>(this); 61 91 } 62 92 … … 75 105 if (handler != null) handler(this, EventArgs.Empty); 76 106 } 107 public event EventHandler ReadOnlyViewChanged; 108 protected virtual void OnReadOnlyViewChanged() { 109 EventHandler handler = ReadOnlyViewChanged; 110 if (handler != null) handler(this, EventArgs.Empty); 111 } 77 112 } 78 113 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/NamedItemCollection.cs
r3381 r3390 31 31 [Item("NamedItemCollection<T>", "Represents a collection of named items.")] 32 32 [StorableClass] 33 public class NamedItemCollection<T> : ObservableKeyedCollection<string, T>, IItem where T : class, INamedItem { 34 public virtual string ItemName { 35 get { return ItemAttribute.GetName(this.GetType()); } 36 } 37 public virtual string ItemDescription { 38 get { return ItemAttribute.GetDescription(this.GetType()); } 39 } 40 public virtual Image ItemImage { 41 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } 42 } 43 33 public class NamedItemCollection<T> : KeyedItemCollection<string, T> where T : class, INamedItem { 44 34 public NamedItemCollection() : base() { } 45 35 public NamedItemCollection(int capacity) : base(capacity) { } … … 47 37 Initialize(); 48 38 } 39 [StorableConstructor] 40 protected NamedItemCollection(bool deserializing) { } 49 41 50 42 [StorableHook(HookType.AfterDeserialization)] … … 53 45 } 54 46 55 public object Clone() { 56 return Clone(new Cloner()); 57 } 58 public virtual IDeepCloneable Clone(Cloner cloner) { 59 NamedItemCollection<T> clone = (NamedItemCollection<T>)Activator.CreateInstance(this.GetType()); 60 cloner.RegisterClonedObject(this, clone); 61 clone.ReadOnlyView = ReadOnlyView; 62 foreach (string key in dict.Keys) 63 clone.dict.Add(key, (T)cloner.Clone(dict[key])); 47 public override IDeepCloneable Clone(Cloner cloner) { 48 NamedItemCollection<T> clone = (NamedItemCollection<T>)base.Clone(cloner); 64 49 clone.Initialize(); 65 50 return clone; 66 }67 68 public override string ToString() {69 return ItemName;70 }71 72 public event EventHandler ItemImageChanged;73 protected virtual void OnItemImageChanged() {74 EventHandler handler = ItemImageChanged;75 if (handler != null) handler(this, EventArgs.Empty);76 }77 public event EventHandler ToStringChanged;78 protected virtual void OnToStringChanged() {79 EventHandler handler = ToStringChanged;80 if (handler != null) handler(this, EventArgs.Empty);81 51 } 82 52 -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperationCollection.cs
r3385 r3390 51 51 parallel = false; 52 52 } 53 [StorableConstructor] 54 private OperationCollection(bool deserializing) { } 53 55 54 56 public override IDeepCloneable Clone(Cloner cloner) { -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorCollection.cs
r3381 r3390 35 35 public OperatorCollection() : base() { } 36 36 public OperatorCollection(IEnumerable<IOperator> collection) : base(collection) { } 37 [StorableConstructor] 38 protected OperatorCollection(bool deserializing) : base(deserializing) { } 37 39 } 38 40 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorList.cs
r3381 r3390 35 35 public OperatorList(int capacity) : base(capacity) { } 36 36 public OperatorList(IEnumerable<IOperator> collection) : base(collection) { } 37 [StorableConstructor] 38 protected OperatorList(bool deserializing) : base(deserializing) { } 37 39 } 38 40 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorSet.cs
r3381 r3390 34 34 public OperatorSet() : base() { } 35 35 public OperatorSet(IEnumerable<IOperator> collection) : base(collection) { } 36 [StorableConstructor] 37 protected OperatorSet(bool deserializing) : base(deserializing) { } 36 38 } 37 39 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ParameterCollection.cs
r3381 r3390 30 30 public ParameterCollection(int capacity) : base(capacity) { } 31 31 public ParameterCollection(IEnumerable<IParameter> collection) : base(collection) { } 32 [StorableConstructor] 33 protected ParameterCollection(bool deserializing) : base(deserializing) { } 32 34 } 33 35 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ScopeList.cs
r3381 r3390 32 32 public ScopeList(int capacity) : base(capacity) { } 33 33 public ScopeList(IEnumerable<IScope> collection) : base(collection) { } 34 [StorableConstructor] 35 private ScopeList(bool deserializing) : base(deserializing) { } 34 36 35 37 public override IDeepCloneable Clone(Cloner cloner) { -
trunk/sources/HeuristicLab.Core/3.3/Collections/ValueParameterCollection.cs
r3381 r3390 30 30 public ValueParameterCollection(int capacity) : base(capacity) { } 31 31 public ValueParameterCollection(IEnumerable<IValueParameter> collection) : base(collection) { } 32 [StorableConstructor] 33 protected ValueParameterCollection(bool deserializing) : base(deserializing) { } 32 34 } 33 35 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/VariableCollection.cs
r3381 r3390 32 32 public VariableCollection(int capacity) : base(capacity) { } 33 33 public VariableCollection(IEnumerable<IVariable> collection) : base(collection) { } 34 [StorableConstructor] 35 private VariableCollection(bool deserializing) : base(deserializing) { } 34 36 35 37 public override IDeepCloneable Clone(Cloner cloner) { -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r3384 r3390 102 102 <Compile Include="Attributes\CreatableAttribute.cs" /> 103 103 <None Include="HeuristicLabCorePlugin.cs.frame" /> 104 <Compile Include="Collections\ReadOnlyItemDictionary.cs" /> 105 <Compile Include="Collections\ItemDictionary.cs" /> 106 <Compile Include="Collections\ReadOnlyKeyedItemCollection.cs" /> 107 <Compile Include="Collections\KeyedItemCollection.cs" /> 108 <Compile Include="Collections\ReadOnlyItemSet.cs" /> 109 <Compile Include="Collections\ReadOnlyItemList.cs" /> 110 <Compile Include="Collections\ReadOnlyItemArray.cs" /> 111 <Compile Include="Collections\ReadOnlyItemCollection.cs" /> 112 <Compile Include="Collections\ItemArray.cs" /> 113 <Compile Include="Collections\ItemCollection.cs" /> 114 <Compile Include="Collections\ItemList.cs" /> 115 <Compile Include="Collections\ItemSet.cs" /> 116 <Compile Include="Collections\NamedItemCollection.cs" /> 117 <Compile Include="Collections\OperationCollection.cs" /> 118 <Compile Include="Collections\OperatorCollection.cs" /> 119 <Compile Include="Collections\OperatorList.cs" /> 120 <Compile Include="Collections\OperatorSet.cs" /> 121 <Compile Include="Collections\ParameterCollection.cs" /> 122 <Compile Include="Collections\ScopeList.cs" /> 123 <Compile Include="Collections\ValueParameterCollection.cs" /> 124 <Compile Include="Collections\VariableCollection.cs" /> 125 <Compile Include="Interfaces\IKeyedItemCollection.cs" /> 126 <Compile Include="Interfaces\IItemList.cs" /> 127 <Compile Include="Interfaces\IItemSet.cs" /> 128 <Compile Include="Interfaces\IItemDictionary.cs" /> 129 <Compile Include="Interfaces\IItemArray.cs" /> 130 <Compile Include="Interfaces\IItemCollection.cs" /> 104 131 <Compile Include="Log.cs" /> 105 132 <Compile Include="Executable.cs" /> … … 112 139 <Compile Include="Interfaces\IExecutionContext.cs" /> 113 140 <Compile Include="Interfaces\IOperation.cs" /> 114 <Compile Include="OperationCollection.cs" />115 141 <Compile Include="ParameterizedNamedItem.cs" /> 116 <Compile Include="ValueParameterCollection.cs" />117 142 <Compile Include="Interfaces\IValueLookupParameter.cs" /> 118 143 <Compile Include="Interfaces\IValueParameter.cs" /> 119 144 <Compile Include="Interfaces\ILookupParameter.cs" /> 120 <Compile Include="ItemArray.cs" />121 145 <Compile Include="Engine.cs" /> 122 146 <Compile Include="Interfaces\IScope.cs" /> … … 126 150 <Compile Include="OperatorGraph.cs" /> 127 151 <Compile Include="Interfaces\IParameter.cs" /> 128 <Compile Include="OperatorCollection.cs" />129 <Compile Include="ItemCollection.cs" />130 <Compile Include="OperatorSet.cs" />131 <Compile Include="ItemSet.cs" />132 <Compile Include="ItemList.cs" />133 152 <Compile Include="Interfaces\IEngine.cs"> 134 153 <SubType>Code</SubType> 135 154 </Compile> 136 155 <Compile Include="ExecutionContext.cs" /> 137 <Compile Include="OperatorList.cs" />138 <Compile Include="ParameterCollection.cs" />139 <Compile Include="VariableCollection.cs" />140 <Compile Include="ScopeList.cs" />141 <Compile Include="NamedItemCollection.cs" />142 156 <Compile Include="Interfaces\INamedItem.cs" /> 143 157 <Compile Include="Interfaces\IItem.cs" />
Note: See TracChangeset
for help on using the changeset viewer.