Changeset 3594
- Timestamp:
- 05/03/10 17:36:39 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Collections
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Core/3.3/Collections/CheckedItemCollection.cs ¶
r3575 r3594 30 30 31 31 namespace HeuristicLab.Core { 32 /// <summary> 33 /// Represents a collection of checked items. 34 /// </summary> 35 /// <typeparam name="T">The element type (base type IItem)</typeparam> 32 36 [StorableClass] 33 37 [Item("CheckedItemCollection<T>", "Represents a collection of items that can be checked or unchecked.")] … … 37 41 38 42 /// <summary> 39 /// gets an enumerable of checked items43 /// Gets an enumerable of checked items 40 44 /// </summary> 41 45 public IEnumerable<T> CheckedItems { … … 43 47 } 44 48 49 /// <summary> 50 /// Instantiates a new CheckedItemCollection. 51 /// </summary> 45 52 public CheckedItemCollection() 46 53 : base() { 47 54 checkedState = new Dictionary<T, bool>(); 48 55 } 56 /// <summary> 57 /// Instantiates a new CheckedItemCollection with a predefined capacity. 58 /// </summary> 59 /// <param name="capacity">Initial capacity.</param> 49 60 public CheckedItemCollection(int capacity) 50 61 : base(capacity) { 51 62 checkedState = new Dictionary<T, bool>(capacity); 52 63 } 64 /// <summary> 65 /// Instantiates a new CheckedItemCollection containing the elements of <paramref name="collection"/>. 66 /// </summary> 67 /// <param name="collection">Initial element collection.</param> 53 68 public CheckedItemCollection(IEnumerable<T> collection) 54 69 : base(collection) { … … 58 73 checkedState.Add(item, true); 59 74 } 75 /// <summary> 76 /// Instantiates an empty CheckedItemCollection for deserialization. 77 /// </summary> 78 /// <param name="deserializing"></param> 60 79 [StorableConstructor] 61 80 protected CheckedItemCollection(bool deserializing) : base(deserializing) { } 62 81 82 /// <summary> 83 /// Gets the checked state of <paramref name="item"/>. 84 /// </summary> 85 /// <param name="item">The element to get the checked state for.</param> 86 /// <returns>Checked state of <paramref name="item"/></returns> 63 87 public bool ItemChecked(T item) { 64 88 return checkedState[item]; 65 89 } 66 90 91 /// <summary> 92 /// Sets the checked state <paramref name="checkedState"/> of <paramref name="item"/>. 93 /// </summary> 94 /// <param name="item">The element to set the checked state for.</param> 95 /// <param name="checkedState">The new checked state of the item</param> 67 96 public void SetItemCheckedState(T item, bool checkedState) { 68 97 if (!this.checkedState.ContainsKey(item)) throw new ArgumentException(); … … 73 102 } 74 103 104 /// <summary> 105 /// Adds a new <paramref name="item"/> with the given <paramref name="checkedState"/>. 106 /// </summary> 107 /// <param name="item">The item to add.</param> 108 /// <param name="checkedState">The checked state of the item to add.</param> 75 109 public void Add(T item, bool checkedState) { 76 110 Add(item); … … 78 112 } 79 113 114 /// <summary> 115 /// Raised when the collection of items is reset. 116 /// </summary> 117 /// <param name="items">Empty</param> 118 /// <param name="oldItems">The elements in the collection before the reset.</param> 80 119 protected override void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) { 81 120 foreach (var oldItem in oldItems) … … 87 126 } 88 127 128 /// <summary> 129 /// Raised when new items are added to the collection. 130 /// </summary> 131 /// <param name="items">The elements that are added to the collection.</param> 89 132 protected override void OnItemsAdded(IEnumerable<T> items) { 90 133 foreach (var item in items) … … 94 137 } 95 138 139 /// <summary> 140 /// Raised when items are removed from the collection. 141 /// </summary> 142 /// <param name="items">The items that are removed.</param> 96 143 protected override void OnItemsRemoved(IEnumerable<T> items) { 97 144 foreach (var item in items) { … … 101 148 } 102 149 150 /// <summary> 151 /// Raised when the checked state of items is changed. 152 /// </summary> 153 /// <param name="items">The item whose check state is changed.</param> 103 154 protected virtual void OnCheckedItemsChanged(IEnumerable<T> items) { 104 155 RaiseCheckedItemsChanged(new CollectionItemsChangedEventArgs<T>(items)); 105 156 } 106 157 158 /// <summary> 159 /// Raised after the checked state of items has been changed. 160 /// </summary> 107 161 public event CollectionItemsChangedEventHandler<T> CheckedItemsChanged; 108 162 private void RaiseCheckedItemsChanged(CollectionItemsChangedEventArgs<T> e) { … … 111 165 } 112 166 113 public object Clone() { 114 return Clone(new Cloner()); 115 } 116 public virtual IDeepCloneable Clone(Cloner cloner) { 167 /// <summary> 168 /// Creates a deep clone of the CheckedItemCollection. 169 /// </summary> 170 /// <param name="cloner"></param> 171 /// <returns>A clone of the CheckedItemCollection</returns> 172 public override IDeepCloneable Clone(Cloner cloner) { 117 173 CheckedItemCollection<T> clone = (CheckedItemCollection<T>)Activator.CreateInstance(this.GetType()); 118 174 cloner.RegisterClonedObject(this, clone); -
TabularUnified trunk/sources/HeuristicLab.Core/3.3/Collections/CheckedItemList.cs ¶
r3575 r3594 33 33 34 34 namespace HeuristicLab.Core { 35 /// <summary> 36 /// Represents a list of checked items. 37 /// </summary> 38 /// <typeparam name="T">The element type (base type is IItem)</typeparam> 35 39 [StorableClass] 36 40 [Item("CheckedItemList<T>", "Represents a list of items that can be checked or unchecked.")] … … 39 43 private Dictionary<T, bool> checkedState; 40 44 45 /// <summary> 46 /// Gets an enumerable of checked items. 47 /// </summary> 41 48 public IEnumerable<IndexedItem<T>> CheckedItems { 42 49 get { … … 46 53 } 47 54 } 55 /// <summary> 56 /// Instantiates an empty CheckedItemList. 57 /// </summary> 48 58 public CheckedItemList() 49 59 : base() { 50 60 checkedState = new Dictionary<T, bool>(); 51 61 } 62 /// <summary> 63 /// Instantiates an empty CheckedItemList with a given initial <paramref name="capacity"/>. 64 /// </summary> 65 /// <param name="capacity">The initial capacity.</param> 52 66 public CheckedItemList(int capacity) 53 67 : base(capacity) { 54 68 checkedState = new Dictionary<T, bool>(); 55 69 } 70 /// <summary> 71 /// Instantiates an CheckedItemList initially filled with the elements of <paramref name="collection"/>. 72 /// </summary> 73 /// <param name="collection">Collection of elements.</param> 56 74 public CheckedItemList(IEnumerable<T> collection) 57 75 : base(collection) { … … 62 80 } 63 81 } 82 /// <summary> 83 /// Instantiates a new CheckedItemList for deserialization. 84 /// </summary> 85 /// <param name="deserializing"></param> 64 86 [StorableConstructor] 65 87 protected CheckedItemList(bool deserializing) : base(deserializing) { } 66 88 89 /// <summary> 90 /// Gets the checked state of <paramref name="item"/>. 91 /// </summary> 92 /// <param name="item">The element to get the checked state for.</param> 93 /// <returns>The checked state of <paramref name="item"/></returns> 67 94 public bool ItemChecked(T item) { 68 95 return checkedState[item]; 69 96 } 70 97 98 /// <summary> 99 /// Gets the checked state of item with <paramref name="index"/>. 100 /// </summary> 101 /// <param name="itemIndex">The index of the element to get the checked state for.</param> 102 /// <returns>The checked state of the element at <paramref name="itemIndex"/>.</returns> 71 103 public bool ItemChecked(int itemIndex) { 72 104 return ItemChecked(this[itemIndex]); 73 105 } 74 106 107 /// <summary> 108 /// Sets the checked state of <paramref name="item"/> to <paramref name="checkedState"/>. 109 /// </summary> 110 /// <param name="item">The item to set the checked state for.</param> 111 /// <param name="checkedState">The new checked state of <paramref name="item"/></param> 75 112 public void SetItemCheckedState(T item, bool checkedState) { 76 113 if (!this.checkedState.ContainsKey(item)) throw new ArgumentException(); … … 81 118 } 82 119 120 /// <summary> 121 /// Sets the checked state of the element with <paramref name="itemIndex"/> to <paramref name="checkedState"/>. 122 /// </summary> 123 /// <param name="itemIndex">The index of the item to set the checked state for.</param> 124 /// <param name="checkedState">The new checked state of the item.</param> 83 125 public void SetItemCheckedState(int itemIndex, bool checkedState) { 84 126 SetItemCheckedState(this[itemIndex], checkedState); 85 127 } 86 128 129 /// <summary> 130 /// Adds a new <paramref name="item"/> with <paramref name="checkedState"/> to the list. 131 /// </summary> 132 /// <param name="item">The item to add to the list.</param> 133 /// <param name="checkedState">The checked state of the item added to the list.</param> 87 134 public void Add(T item, bool checkedState) { 88 135 Add(item); … … 90 137 } 91 138 139 /// <summary> 140 /// Inserts a new <paramref name="item"/> at <paramref name="index"/> with <paramref name="checkedState"/> into the list. 141 /// </summary> 142 /// <param name="index">The insertion index of the new element.</param> 143 /// <param name="item">The element that is inserted into the list.</param> 144 /// <param name="checkedState">The checked state of the inserted element.</param> 92 145 public void Insert(int index, T item, bool checkedState) { 93 146 Insert(index, item); … … 95 148 } 96 149 150 /// <summary> 151 /// Raised after the list has been reset. 152 /// </summary> 153 /// <param name="items">Empty</param> 154 /// <param name="oldItems">The elements of the list before it has been reset.</param> 97 155 protected override void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) { 98 156 foreach (var oldIndexedItem in oldItems) { … … 106 164 } 107 165 166 /// <summary> 167 /// Raised when new items are added to the list. 168 /// </summary> 169 /// <param name="items">The items that are added.</param> 108 170 protected override void OnItemsAdded(IEnumerable<IndexedItem<T>> items) { 109 171 foreach (var indexedItem in items) … … 113 175 } 114 176 177 /// <summary> 178 /// Raised when items are removed from the list. 179 /// </summary> 180 /// <param name="items">Items that are removed.</param> 115 181 protected override void OnItemsRemoved(IEnumerable<IndexedItem<T>> items) { 116 182 foreach (var indexedItem in items) … … 119 185 } 120 186 187 /// <summary> 188 /// Raised when items are replaced. 189 /// </summary> 190 /// <param name="items">The items which replace <paramref name="oldItems"/></param> 191 /// <param name="oldItems">The items that are replaced by <paramref name="items"/></param> 121 192 protected override void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) { 122 193 foreach (var oldIndexedItem in oldItems) … … 128 199 } 129 200 201 /// <summary> 202 /// Raised after the checked state of items has been changed. 203 /// </summary> 204 /// <param name="items">The items whose check state has been changed.</param> 130 205 protected virtual void OnCheckedItemsChanged(IEnumerable<IndexedItem<T>> items) { 131 206 RaiseCheckedItemsChanged(new CollectionItemsChangedEventArgs<IndexedItem<T>>(items)); 132 207 } 133 208 209 /// <summary> 210 /// Raised after the checked state of items has been changed. 211 /// </summary> 134 212 public event CollectionItemsChangedEventHandler<IndexedItem<T>> CheckedItemsChanged; 135 213 private void RaiseCheckedItemsChanged(CollectionItemsChangedEventArgs<IndexedItem<T>> e) { … … 138 216 } 139 217 140 public object Clone() { 141 return Clone(new Cloner()); 142 } 143 public virtual IDeepCloneable Clone(Cloner cloner) { 218 /// <summary> 219 /// Creates a new deep clone of the CheckedItemList. 220 /// </summary> 221 /// <param name="cloner"></param> 222 /// <returns>A deep clone of the CheckedItemList</returns> 223 public override IDeepCloneable Clone(Cloner cloner) { 144 224 CheckedItemList<T> clone = (CheckedItemList<T>)Activator.CreateInstance(this.GetType()); 145 225 cloner.RegisterClonedObject(this, clone);
Note: See TracChangeset
for help on using the changeset viewer.