- Timestamp:
- 03/14/10 18:26:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Collections/3.3/ReadOnlyObservableList.cs
r3017 r3019 33 33 private IObservableList<T> list; 34 34 35 #region persistence36 private ReadOnlyObservableList() { }37 38 [StorableHook(HookType.AfterDeserialization)]39 private void PostDeserizlationHook() {40 RegisterEvents();41 }42 #endregion43 44 35 #region Properties 45 36 public int Count { … … 60 51 61 52 #region Constructors 53 protected ReadOnlyObservableList() { } 62 54 public ReadOnlyObservableList(IObservableList<T> list) { 63 55 if (list == null) throw new ArgumentNullException(); … … 65 57 RegisterEvents(); 66 58 } 67 68 private void RegisterEvents() { 59 #endregion 60 61 #region Access 62 public bool Contains(T item) { 63 return list.Contains(item); 64 } 65 66 public int IndexOf(T item) { 67 return list.IndexOf(item); 68 } 69 #endregion 70 71 #region Manipulation 72 void ICollection<T>.Add(T item) { 73 throw new NotSupportedException(); 74 } 75 76 void IList<T>.Insert(int index, T item) { 77 throw new NotSupportedException(); 78 } 79 80 bool ICollection<T>.Remove(T item) { 81 throw new NotSupportedException(); 82 } 83 void IList<T>.RemoveAt(int index) { 84 throw new NotSupportedException(); 85 } 86 87 void ICollection<T>.Clear() { 88 throw new NotSupportedException(); 89 } 90 #endregion 91 92 #region Conversion 93 public void CopyTo(T[] array, int arrayIndex) { 94 list.CopyTo(array, arrayIndex); 95 } 96 #endregion 97 98 #region Enumeration 99 public IEnumerator<T> GetEnumerator() { 100 return ((ICollection<T>)list).GetEnumerator(); 101 } 102 IEnumerator IEnumerable.GetEnumerator() { 103 return ((IEnumerable)list).GetEnumerator(); 104 } 105 #endregion 106 107 #region Events 108 [StorableHook(HookType.AfterDeserialization)] 109 protected void RegisterEvents() { 69 110 list.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<T>>(list_ItemsAdded); 70 111 ((IObservableCollection<T>)list).ItemsAdded += new CollectionItemsChangedEventHandler<T>(list_ItemsAdded); … … 77 118 list.PropertyChanged += new PropertyChangedEventHandler(list_PropertyChanged); 78 119 } 79 #endregion 80 81 #region Access 82 public bool Contains(T item) { 83 return list.Contains(item); 84 } 85 86 public int IndexOf(T item) { 87 return list.IndexOf(item); 88 } 89 #endregion 90 91 #region Manipulation 92 void ICollection<T>.Add(T item) { 93 throw new NotSupportedException(); 94 } 95 96 void IList<T>.Insert(int index, T item) { 97 throw new NotSupportedException(); 98 } 99 100 bool ICollection<T>.Remove(T item) { 101 throw new NotSupportedException(); 102 } 103 void IList<T>.RemoveAt(int index) { 104 throw new NotSupportedException(); 105 } 106 107 void ICollection<T>.Clear() { 108 throw new NotSupportedException(); 109 } 110 #endregion 111 112 #region Conversion 113 public void CopyTo(T[] array, int arrayIndex) { 114 list.CopyTo(array, arrayIndex); 115 } 116 #endregion 117 118 #region Enumeration 119 public IEnumerator<T> GetEnumerator() { 120 return ((ICollection<T>)list).GetEnumerator(); 121 } 122 IEnumerator IEnumerable.GetEnumerator() { 123 return ((IEnumerable)list).GetEnumerator(); 124 } 125 #endregion 126 127 #region Events 120 128 121 [field: NonSerialized] 129 122 public event CollectionItemsChangedEventHandler<IndexedItem<T>> ItemsAdded;
Note: See TracChangeset
for help on using the changeset viewer.