Changeset 2618
- Timestamp:
- 01/09/10 03:22:58 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Collections/3.3
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Collections/3.3/HeuristicLab.Collections-3.3.csproj
r2574 r2618 49 49 </ItemGroup> 50 50 <ItemGroup> 51 <Compile Include="ReadOnlyObservableKeyedCollection.cs"> 52 <SubType>Code</SubType> 53 </Compile> 54 <Compile Include="ReadOnlyObservableList.cs" /> 55 <Compile Include="ReadOnlyObservableDictionary.cs" /> 56 <Compile Include="ReadOnlyObservableCollection.cs" /> 51 57 <Compile Include="IObservableKeyedCollection.cs" /> 52 58 <Compile Include="IObservableList.cs" /> -
trunk/sources/HeuristicLab.Collections/3.3/HeuristicLabCollectionsPlugin.cs
r2572 r2618 29 29 /// Plugin class for HeuristicLab.Collections plugin. 30 30 /// </summary> 31 [ ClassInfo(Name = "HeuristicLab.Collections-3.2")]32 [PluginFile( Filename = "HeuristicLab.Collections-3.3.dll", Filetype =PluginFileType.Assembly)]33 [ Dependency(Dependency ="HeuristicLab.Persistence-3.3")]31 [Plugin("HeuristicLab.Collections-3.3")] 32 [PluginFile("HeuristicLab.Collections-3.3.dll", PluginFileType.Assembly)] 33 [PluginDependency("HeuristicLab.Persistence-3.3")] 34 34 public class HeuristicLabCollectionsPlugin : PluginBase { 35 35 } -
trunk/sources/HeuristicLab.Collections/3.3/IObservableCollection.cs
r2575 r2618 26 26 27 27 namespace HeuristicLab.Collections { 28 public interface IObservableCollection<T> : ICollection<T> , IDisposable{28 public interface IObservableCollection<T> : ICollection<T> { 29 29 event CollectionItemsChangedEventHandler<T> ItemsAdded; 30 30 event CollectionItemsChangedEventHandler<T> ItemsRemoved; -
trunk/sources/HeuristicLab.Collections/3.3/IObservableDictionary.cs
r2574 r2618 26 26 27 27 namespace HeuristicLab.Collections { 28 public interface IObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IObservableCollection<KeyValuePair<TKey, TValue>> { 28 public interface IObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue> { 29 event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsAdded; 30 event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsRemoved; 29 31 event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> ItemsReplaced; 32 event CollectionItemsChangedEventHandler<KeyValuePair<TKey, TValue>> CollectionReset; 30 33 } 31 34 } -
trunk/sources/HeuristicLab.Collections/3.3/IObservableKeyedCollection.cs
r2575 r2618 26 26 27 27 namespace HeuristicLab.Collections { 28 public interface IObservableKeyedCollection<TKey, TItem> : IObservableCollection<TItem> { 28 public interface IObservableKeyedCollection<TKey, TItem> : ICollection<TItem> { 29 TItem this[TKey key] { get; } 30 31 bool ContainsKey(TKey key); 32 bool TryGetValue(TKey key, out TItem item); 33 34 event CollectionItemsChangedEventHandler<TItem> ItemsAdded; 35 event CollectionItemsChangedEventHandler<TItem> ItemsRemoved; 29 36 event CollectionItemsChangedEventHandler<TItem> ItemsReplaced; 37 event CollectionItemsChangedEventHandler<TItem> CollectionReset; 30 38 } 31 39 } -
trunk/sources/HeuristicLab.Collections/3.3/IObservableList.cs
r2574 r2618 26 26 27 27 namespace HeuristicLab.Collections { 28 public interface IObservableList<T> : IList<T>, IObservableCollection<IndexedItem<T>> { 28 public interface IObservableList<T> : IList<T> { 29 event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded; 30 event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsRemoved; 29 31 event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsReplaced; 30 32 event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsMoved; 33 event CollectionItemsChangedEventHandler<IndexedItem<T>> CollectionReset; 31 34 } 32 35 } -
trunk/sources/HeuristicLab.Collections/3.3/ObservableCollection.cs
r2575 r2618 42 42 get { return list.Count; } 43 43 } 44 public boolIsReadOnly {44 bool ICollection<T>.IsReadOnly { 45 45 get { return ((ICollection<T>)list).IsReadOnly; } 46 46 } … … 57 57 list = new List<T>(collection); 58 58 OnItemsAdded(collection); 59 }60 #endregion61 62 #region Destructors63 ~ObservableCollection() {64 Dispose(false);65 }66 protected virtual void Dispose(bool disposing) {67 if (disposing) {68 Clear();69 }70 }71 public void Dispose() {72 Dispose(true);73 GC.SuppressFinalize(this);74 59 } 75 60 #endregion … … 137 122 138 123 #region Conversion 139 public ReadOnly Collection<T> AsReadOnly() {140 return list.AsReadOnly();124 public ReadOnlyObservableCollection<T> AsReadOnly() { 125 return new ReadOnlyObservableCollection<T>(this); 141 126 } 142 127 public T[] ToArray() { -
trunk/sources/HeuristicLab.Collections/3.3/ObservableDictionary.cs
r2575 r2618 91 91 #endregion 92 92 93 #region Destructors94 ~ObservableDictionary() {95 Dispose(false);96 }97 protected virtual void Dispose(bool disposing) {98 if (disposing) {99 Clear();100 }101 }102 public void Dispose() {103 Dispose(true);104 GC.SuppressFinalize(this);105 }106 #endregion107 108 93 #region Access 109 94 public bool ContainsKey(TKey key) { … … 157 142 158 143 #region Conversion 144 public ReadOnlyObservableDictionary<TKey, TValue> AsReadOnly() { 145 return new ReadOnlyObservableDictionary<TKey, TValue>(this); 146 } 159 147 void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { 160 148 ((ICollection<KeyValuePair<TKey, TValue>>)dict).CopyTo(array, arrayIndex); -
trunk/sources/HeuristicLab.Collections/3.3/ObservableKeyedCollectionBase.cs
r2575 r2618 41 41 get { return dict.Comparer; } 42 42 } 43 public boolIsReadOnly {43 bool ICollection<TItem>.IsReadOnly { 44 44 get { return ((ICollection<KeyValuePair<TKey, TItem>>)dict).IsReadOnly; } 45 45 } … … 78 78 dict.Add(GetKeyForItem(item), item); 79 79 OnItemsAdded(collection); 80 }81 #endregion82 83 #region Destructors84 ~ObservableKeyedCollectionBase() {85 Dispose(false);86 }87 protected virtual void Dispose(bool disposing) {88 if (disposing) {89 Clear();90 }91 }92 public void Dispose() {93 Dispose(true);94 GC.SuppressFinalize(this);95 80 } 96 81 #endregion … … 115 100 116 101 #region Access 117 public bool Contains (TKey key) {102 public bool ContainsKey(TKey key) { 118 103 return dict.ContainsKey(key); 119 104 } … … 203 188 204 189 #region Conversion 190 public ReadOnlyObservableKeyedCollection<TKey, TItem> AsReadOnly() { 191 return new ReadOnlyObservableKeyedCollection<TKey, TItem>(this); 192 } 205 193 public TItem[] ToArray() { 206 194 return dict.Values.ToArray(); -
trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs
r2575 r2618 45 45 get { return ((ICollection<T>)list).IsReadOnly; } 46 46 } 47 bool ICollection<IndexedItem<T>>.IsReadOnly {48 get { return ((ICollection<T>)list).IsReadOnly; }49 }50 47 51 48 public T this[int index] { … … 74 71 #endregion 75 72 76 #region Destructors77 ~ObservableList() {78 Dispose(false);79 }80 protected virtual void Dispose(bool disposing) {81 if (disposing) {82 Clear();83 }84 }85 public void Dispose() {86 Dispose(true);87 GC.SuppressFinalize(this);88 }89 #endregion90 91 73 #region Access 92 74 public List<T> GetRange(int index, int count) { … … 96 78 public bool Contains(T item) { 97 79 return list.Contains(item); 98 }99 public bool Contains(IndexedItem<T> item) {100 return list[item.Index].Equals(item.Value);101 80 } 102 81 … … 170 149 list.Add(item); 171 150 OnItemsAdded(new IndexedItem<T>[] { new IndexedItem<T>(list.Count - 1, item) }); 172 }173 public void Add(IndexedItem<T> item) {174 list.Insert(item.Index, item.Value);175 OnItemsAdded(new IndexedItem<T>[] { item });176 151 } 177 152 public void AddRange(IEnumerable<T> collection) { … … 209 184 return false; 210 185 } 211 public bool Remove(IndexedItem<T> item) {212 if (list[item.Index].Equals(item.Value)) {213 list.RemoveAt(item.Index);214 OnItemsRemoved(new IndexedItem<T>[] { item });215 return true;216 }217 return false;218 }219 186 public int RemoveAll(Predicate<T> match) { 220 187 if (match == null) throw new ArgumentNullException(); … … 279 246 280 247 #region Conversion 281 public ReadOnly Collection<T> AsReadOnly() {282 return list.AsReadOnly();248 public ReadOnlyObservableList<T> AsReadOnly() { 249 return new ReadOnlyObservableList<T>(this); 283 250 } 284 251 public T[] ToArray() { … … 287 254 void ICollection<T>.CopyTo(T[] array, int arrayIndex) { 288 255 list.CopyTo(array, arrayIndex); 289 }290 void ICollection<IndexedItem<T>>.CopyTo(IndexedItem<T>[] array, int arrayIndex) {291 IndexedItem<T>[] items = GetIndexedItems();292 items.CopyTo(array, arrayIndex);293 256 } 294 257 public List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter) { … … 312 275 IEnumerator<T> IEnumerable<T>.GetEnumerator() { 313 276 return ((IEnumerable<T>)list).GetEnumerator(); 314 }315 IEnumerator<IndexedItem<T>> IEnumerable<IndexedItem<T>>.GetEnumerator() {316 int index = -1;317 foreach (T item in list) {318 index++;319 yield return new IndexedItem<T>(index, item);320 }321 277 } 322 278 IEnumerator IEnumerable.GetEnumerator() {
Note: See TracChangeset
for help on using the changeset viewer.