blob: be0906fc4637430f695a8b8635fced3566565d25 (
plain)
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
<// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.ObjectModel;
namespace Tango.Scripting.Editors.Utils
{
/// <summary>
/// A collection that cannot contain null values.
/// </summary>
[Serializable]
public class NullSafeCollection<T> : Collection<T> where T : class
{
/// <inheritdoc/>
protected override void InsertItem(int index, T item)
{
if (item == null)
throw new ArgumentNullException("item");
base.InsertItem(index, item);
}
/// <inheritdoc/>
protected override void SetItem(int index, T item)
{
if (item == null)
throw new ArgumentNullException("item");
base.SetItem(index, item);
}
}
}
|