diff options
author | Marek Safar <marek.safar@gmail.com> | 2013-07-30 16:45:46 +0400 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2013-07-30 17:51:29 +0400 |
commit | d90decc41762fd9f71282966a89cb210cc4c1675 (patch) | |
tree | 334a3421dbecbdbb169e126ec249b3fc9cce927d /mcs/class/WindowsBase | |
parent | fa8dc3c5e56c374cca8fe6fbddbe60acaa99f272 (diff) |
Fixed binary serialization
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r-- | mcs/class/WindowsBase/System.Collections.ObjectModel/ObservableCollection.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mcs/class/WindowsBase/System.Collections.ObjectModel/ObservableCollection.cs b/mcs/class/WindowsBase/System.Collections.ObjectModel/ObservableCollection.cs index 3519eebf020..2ec5f3be0b4 100644 --- a/mcs/class/WindowsBase/System.Collections.ObjectModel/ObservableCollection.cs +++ b/mcs/class/WindowsBase/System.Collections.ObjectModel/ObservableCollection.cs @@ -42,11 +42,11 @@ namespace System.Collections.ObjectModel { [Serializable] public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged { - - private class Reentrant : IDisposable { + [Serializable] + sealed class SimpleMonitor : IDisposable { private int _busyCount; - public Reentrant() + public SimpleMonitor() { } @@ -66,7 +66,7 @@ namespace System.Collections.ObjectModel } } - private Reentrant reentrant = new Reentrant (); + private SimpleMonitor _monitor = new SimpleMonitor (); public ObservableCollection() { @@ -86,7 +86,9 @@ namespace System.Collections.ObjectModel { } + [field:NonSerialized] public virtual event NotifyCollectionChangedEventHandler CollectionChanged; + [field:NonSerialized] protected virtual event PropertyChangedEventHandler PropertyChanged; event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { @@ -96,8 +98,8 @@ namespace System.Collections.ObjectModel protected IDisposable BlockReentrancy () { - reentrant.Enter (); - return reentrant; + _monitor.Enter (); + return _monitor; } protected void CheckReentrancy () @@ -105,7 +107,7 @@ namespace System.Collections.ObjectModel NotifyCollectionChangedEventHandler eh = CollectionChanged; // Only have a problem if we have more than one event listener. - if (reentrant.Busy && eh != null && eh.GetInvocationList ().Length > 1) + if (_monitor.Busy && eh != null && eh.GetInvocationList ().Length > 1) throw new InvalidOperationException ("Cannot modify the collection while reentrancy is blocked."); } |