A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3using System.Collections.ObjectModel;
4
5namespace Unity.VisualScripting
6{
7 public abstract class NonNullableCollection<T> : Collection<T>
8 {
9 protected override void InsertItem(int index, T item)
10 {
11 if (item == null)
12 {
13 throw new ArgumentNullException(nameof(item));
14 }
15
16 base.InsertItem(index, item);
17 }
18
19 protected override void SetItem(int index, T item)
20 {
21 if (item == null)
22 {
23 throw new ArgumentNullException(nameof(item));
24 }
25
26 base.SetItem(index, item);
27 }
28
29 public void AddRange(IEnumerable<T> collection)
30 {
31 foreach (var item in collection)
32 {
33 Add(item);
34 }
35 }
36 }
37}