Example #1
0
 /// <summary>
 /// Add <paramref name="disposable"/> to be disposed along with <paramref name="packageEntry"/>.
 ///
 /// If <paramref name="disposable"/> is not <see cref="IDisposable"/>, then it's not added.
 /// </summary>
 /// <param name="packageEntry"></param>
 /// <param name="disposable">object to dispose</param>
 /// <returns></returns>
 internal static PackageEntry AddDisposable(this PackageEntry packageEntry, object disposable)
 {
     if (disposable is IDisposable toDispose && packageEntry is IDisposeList disposeList)
     {
         disposeList.AddDisposable(toDispose);
     }
     return(packageEntry);
 }
Example #2
0
 /// <summary>
 /// Add <paramref name="disposables"/> to be disposed along with <paramref name="packageEntry"/>.
 ///
 /// If <paramref name="disposables"/> is not <see cref="IDisposable"/>, then it's not added.
 /// </summary>
 /// <param name="packageEntry"></param>
 /// <param name="disposables">object(s) to dispose</param>
 /// <returns></returns>
 internal static PackageEntry AddDisposables(this PackageEntry packageEntry, IEnumerable disposables)
 {
     foreach (var disposable in disposables)
     {
         if (disposable is IDisposable toDispose && packageEntry is IDisposeList disposeList)
         {
             disposeList.AddDisposable(toDispose);
         }
     }
     return(packageEntry);
 }