using System; using System.Collections.Generic; using System.Runtime.Serialization; namespace Nuclex.Support { /// /// Represents a weak reference, which references an object while still allowing /// that object to be garbage collected. /// public class WeakReference : WeakReference where ReferencedType : class { /// /// Initializes a new instance of the System.WeakReference class, referencing /// the specified object. /// /// The object to track or null. public WeakReference(ReferencedType target) : base(target) { } /// /// Initializes a new instance of the System.WeakReference class, referencing /// the specified object optionally using resurrection tracking. /// /// An object to track. /// /// Indicates when to stop tracking the object. If true, the object is tracked /// after finalization; if false, the object is only tracked until finalization. /// public WeakReference(ReferencedType target, bool trackResurrection) : base(target, trackResurrection) { } /// /// Initializes a new instance of the System.WeakReference class, using deserialized /// data from the specified serialization and stream objects. /// /// /// An object that holds all the data needed to serialize or deserialize the /// current System.WeakReference object. /// /// /// (Reserved) Describes the source and destination of the serialized stream /// specified by info. /// /// /// The info parameter is null. /// protected WeakReference(SerializationInfo info, StreamingContext context) : base(info, context) { } /// /// Gets or sets the object (the target) referenced by the current System.WeakReference /// object. /// /// /// null if the object referenced by the current System.WeakReference object /// has been garbage collected; otherwise, a reference to the object referenced /// by the current System.WeakReference object. /// /// /// The reference to the target object is invalid. This can occur if the current /// System.WeakReference object has been finalized /// public new ReferencedType Target { get { return (base.Target as ReferencedType); } set { base.Target = value; } } } } // namespace Nuclex.Support