Пример #1
0
 private void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             var disposables = (Root == this
                 ? SingletonCache.Union(scopedCache)
                 : scopedCache)
                               .Where(x => x.Value != this);
             foreach (var scoped in disposables)
             {
                 var disposable = scoped.Value as IDisposable;
                 disposable?.Dispose();
             }
             scopedCache.Clear();
             if (Root == this)
             {
                 SingletonCache.Clear();
             }
         }
         disposedValue = true;
     }
 }