protected virtual void InternalDispose() { if (!_disposed) { _disposed = true; Cleanup.SafeMethod(() => (_container as IDisposable)?.Dispose()); } }
public void Dispose() { // We do not support a finalizer because MultiInstanceFactory // calls Dispose() for us. It also manages calling Dispose() // once and only once. Cleanup.SafeMethod(() => { (_weakReference.Target as IDisposable)?.Dispose(); }); }
public void Dispose() { if (_disposed) { return; } // We do not support a finalizer because our owner has one Cleanup.SafeMethod(() => { foreach (var o in _instances) { (o as IDisposable)?.Dispose(); } }); _disposed = true; }
public void Dispose() { // We do not support a finalizer because our owner has one if (_disposed) { return; } Cleanup.SafeMethod(() => { if (_instance.IsValueCreated) { (_instance.Value as IDisposable)?.Dispose(); } }); _disposed = true; }
private void Dispose(bool dispose) { if (_disposed) { return; } Cleanup.SafeMethod(() => { var trackers = GetTrackers(); foreach (var t in trackers) { t.Dispose(); } }); _disposed = true; }
protected void Dispose(bool dispose) { if (_disposed) { return; } Cleanup.SafeMethod(() => { _parent?.RemoveChild(this); List <Container> childrenToDispose; lock (_syncLock) { childrenToDispose = _children.ToList(); _children.Clear(); } foreach (var c in childrenToDispose) { ((IDisposable)c).Dispose(); } List <IInstanceFactory> factoriesToDispose = _factories.Values.ToList(); foreach (var f in factoriesToDispose) { f.Dispose(); } _factories.Clear(); }); _disposed = true; if (dispose) { GC.SuppressFinalize(this); } }