/// <summary> /// Disposes the objects in the container. /// </summary> /// <param name="disposing">True if called from Dispose(); false if called from /// a finalizer.</param> protected virtual void Dispose(bool disposing) { if (disposing) { lifetime.Dispose(); } }
/// <summary> /// Disposes the object. /// </summary> /// <param name="disposing"><see langword="true"/> when the user code is disposing; /// <see langword="false"/> when it is the GC. /// </param> protected virtual void Dispose(bool disposing) { if (disposing) { _builder.TearDown(_locator, this); if (_parent != null) { List <object> ids = new List <object>(); foreach (KeyValuePair <object, object> pair in _parent.Locator) { if (pair.Value == this) { ids.Add(pair.Key); } } foreach (object id in ids) { _parent.Locator.Remove(id); } _parent._lifetime.Remove(this); } _lifetime.Remove(this); List <object> lifetimeObjects = new List <object>(); lifetimeObjects.AddRange(_lifetime); foreach (object obj in lifetimeObjects) { if (_lifetime.Contains(obj)) { _builder.TearDown(_locator, obj); } } _lifetime.Dispose(); } }
public virtual void Dispose() { container.Dispose(); }