/// <summary> /// Disposes of this instance. /// </summary> /// <param name="finalizing">True if called from <see cref="Dispose()" />, false otherwise.</param> protected virtual void Dispose(bool finalizing) { // If we can dispose of the production collection we must var disposable = Produce as IDisposable; disposable?.Dispose(); if (_dependentTransformer != null) { // If we can dispose of the dependent transformer we must _dependentTransformer.Dispose(); } else { // If there is no dependent transformation then dispose of the consumer source disposable = Consume as IDisposable; disposable?.Dispose(); } }