public void RemoveFromParent() { if (parent != null) { parent.children.Remove(this); parent = null; } }
public virtual void Dispose() { disposeChilderen(); if (parent != null) { if (parent.children != null) { parent.children.Remove(this); } parent = null; } IsDisposed = true; }
private void init(IDisposableResource parent, Dictionary <string, object> constructorParameters) { DisposableResource disposable = null; if (parent != null) { disposable = parent as DisposableResource; if (disposable == null) { Debug.ThrowError("DisposableResource", "Parent object must be a DisposableResource class object, NOT just an interface"); } } this.parent = disposable; if (this.parent != null) { this.parent.children.Add(this); } children = new List <DisposableResource>(); referenceCount = 1; this.constructorParameters = constructorParameters; }