private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { _listener = null; _delegateSource = null; _subscriberReference = null; } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
public WeakDelegate(object subscriber, object target, MethodInfo listener) { _subscriberReference = new WeakReference(subscriber ?? throw new ArgumentNullException(nameof(subscriber))); _delegateSource = new MaybeWeakReference(subscriber, target ?? throw new ArgumentNullException(nameof(target))); _listener = listener ?? throw new ArgumentNullException(nameof(listener)); }