-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadOnlyReactiveCollection.cs
38 lines (25 loc) · 1.04 KB
/
ReadOnlyReactiveCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using DynamicData.Binding;
using ReactiveUI;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace WwtbamOld;
public abstract class ReadOnlyReactiveCollection<T> : ReactiveObject, IEnumerable<T>
{
#region Fields
protected readonly ObservableCollectionExtended<T> _collection;
protected readonly ReadOnlyObservableCollection<T> _readOnlyCollection;
#endregion Fields
public ReadOnlyReactiveCollection()
{
_readOnlyCollection = new ReadOnlyObservableCollection<T>(_collection = new ObservableCollectionExtended<T>());
}
#region Properties
public ReadOnlyObservableCollection<T> Collection => _readOnlyCollection;
#endregion Properties
public T this[int id] => _readOnlyCollection[id];
#region IEnumerable<T>
public IEnumerator<T> GetEnumerator() => ((IEnumerable<T>)_readOnlyCollection).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_readOnlyCollection).GetEnumerator();
#endregion IEnumerable<T>
}