DisposableExtensions.cs 645 B

1234567891011121314151617181920
  1. using System;
  2. using System.Collections.Generic;
  3. namespace UniRx
  4. {
  5. public static partial class DisposableExtensions
  6. {
  7. /// <summary>Add disposable(self) to CompositeDisposable(or other ICollection). Return value is self disposable.</summary>
  8. public static T AddTo<T>(this T disposable, ICollection<IDisposable> container)
  9. where T : IDisposable
  10. {
  11. if (disposable == null) throw new ArgumentNullException("disposable");
  12. if (container == null) throw new ArgumentNullException("container");
  13. container.Add(disposable);
  14. return disposable;
  15. }
  16. }
  17. }