Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonius Riha <antoniusriha@gmail.com>2014-01-02 20:27:31 +0400
committerAntonius Riha <antoniusriha@gmail.com>2014-01-02 20:31:36 +0400
commit3e28c643b0c4502f5a971f8a656d899269d182f3 (patch)
tree6975a4953f7662c75c832e84cc771ea6c628c285 /mcs/class/WindowsBase
parent9e20dc9fa855f331531181eadca1571e720f995a (diff)
Make empty SortDescriptionCollection read-only.
This is in accordance with the behavior of SortDescriptionCollection in .NET.
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r--mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs23
1 files changed, 21 insertions, 2 deletions
diff --git a/mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs b/mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs
index 2044bca0769..9174cfb4458 100644
--- a/mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs
+++ b/mcs/class/WindowsBase/System.ComponentModel/SortDescriptionCollection.cs
@@ -32,10 +32,17 @@ namespace System.ComponentModel {
public class SortDescriptionCollection : Collection<SortDescription>, INotifyCollectionChanged
{
- public static readonly SortDescriptionCollection Empty = new SortDescriptionCollection ();
+ public static readonly SortDescriptionCollection Empty = new SortDescriptionCollection (true);
- public SortDescriptionCollection ()
+ readonly bool isReadOnly;
+
+ public SortDescriptionCollection () : this (false)
+ {
+ }
+
+ SortDescriptionCollection (bool isReadOnly)
{
+ this.isReadOnly = isReadOnly;
}
event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged {
@@ -47,12 +54,18 @@ namespace System.ComponentModel {
protected override void ClearItems ()
{
+ if (isReadOnly)
+ throw new NotSupportedException ();
+
base.ClearItems ();
OnCollectionChanged (NotifyCollectionChangedAction.Reset);
}
protected override void InsertItem (int index, SortDescription item)
{
+ if (isReadOnly)
+ throw new NotSupportedException ();
+
item.Seal ();
base.InsertItem (index, item);
OnCollectionChanged (NotifyCollectionChangedAction.Add, item, index);
@@ -60,6 +73,9 @@ namespace System.ComponentModel {
protected override void RemoveItem (int index)
{
+ if (isReadOnly)
+ throw new NotSupportedException ();
+
SortDescription sd = base [index];
base.RemoveItem (index);
OnCollectionChanged (NotifyCollectionChangedAction.Remove, sd, index);
@@ -67,6 +83,9 @@ namespace System.ComponentModel {
protected override void SetItem (int index, SortDescription item)
{
+ if (isReadOnly)
+ throw new NotSupportedException ();
+
SortDescription old = base [index];
item.Seal ();
base.SetItem (index, item);