NullNotAllowedCollection.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Syndication
  5. {
  6. using System.Collections.ObjectModel;
  7. class NullNotAllowedCollection<TCollectionItem> : Collection<TCollectionItem>
  8. where TCollectionItem : class
  9. {
  10. public NullNotAllowedCollection()
  11. : base()
  12. {
  13. }
  14. protected override void InsertItem(int index, TCollectionItem item)
  15. {
  16. if (item == null)
  17. {
  18. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
  19. }
  20. base.InsertItem(index, item);
  21. }
  22. protected override void SetItem(int index, TCollectionItem item)
  23. {
  24. if (item == null)
  25. {
  26. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
  27. }
  28. base.SetItem(index, item);
  29. }
  30. }
  31. }