using System.Collections.Generic; namespace Chernobyl.Values { /// /// An that gets its value from another /// that may not always be present. /// public class SourceContainer : SourceValue, IContainer { /// /// Initializes a new instance of the class /// that uses null for the and /// for the /// . /// public SourceContainer() : this(null) {} /// /// Initializes a new instance of the class /// that uses /// for the . /// /// The that acts as the /// source for or null if this source has not yet /// been provided. public SourceContainer(IContainer source) : this(source, EqualityComparer.Default) { } /// /// Initializes a new instance of the class. /// /// The that acts as the /// source for or null if this source has not yet /// been provided. /// The instance used to compare new and previous /// values of to determine if /// should be raised. public SourceContainer(IContainer source, IEqualityComparer comparer) : base(source, comparer) { Source = source; } /// /// The value held by this instance or default(T) if /// has not been provided. /// T IContainer.Value { get { return _source != null ? _source.Value : default(T); } } /// /// The that acts as the source for /// or null if this source has not yet been /// provided. /// public new IContainer Source { get { return _source; } set { if (_source != value) base.Source = _source = value; } } /// /// The backing field to . /// IContainer _source; } }