File: System\ServiceModel\Syndication\NullNotAllowedCollection.cs
Web Access
Project: src\src\libraries\System.ServiceModel.Syndication\src\System.ServiceModel.Syndication.csproj (System.ServiceModel.Syndication)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Collections.ObjectModel;
 
namespace System.ServiceModel.Syndication
{
    internal sealed class NullNotAllowedCollection<TCollectionItem> : Collection<TCollectionItem> where TCollectionItem : class
    {
        public NullNotAllowedCollection() : base()
        {
        }
 
        protected override void InsertItem(int index, TCollectionItem item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }
 
            base.InsertItem(index, item);
        }
 
        protected override void SetItem(int index, TCollectionItem item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }
 
            base.SetItem(index, item);
        }
    }
}