///<summary> ///Determines if this potential value is equivalent to the given potential value. ///Note: All forms of no value are equal, including May.NoValue, May<T>.NoValue, May<AnyOtherT>.NoValue, default(May<T>) and new May<T>(). ///Note: Null is NOT equivalent to new May<object>(null) and neither is equivalent to new May<string>(null). ///</summary> public bool Equals(IMayHaveValue other) { if (other is May <T> ) { return(Equals((May <T>)other)); } // potential values containing no value are always equal return(other != null && !this.HasValue && !other.HasValue); }
///<summary>Runs the given no value action if the given potential value does not contain a value, and otherwise does nothing.</summary> public static void ElseDo(this IMayHaveValue potentialValue, Action noValueAction) { if (potentialValue == null) { throw new ArgumentNullException("potentialValue"); } if (noValueAction == null) { throw new ArgumentNullException("noValueAction"); } if (!potentialValue.HasValue) { noValueAction(); } }
///<summary>Determines if the given potential value contains no value.</summary> public bool Equals(IMayHaveValue other) { return(other != null && !other.HasValue); }
///<summary>Determines if the given potential value contains no value.</summary> public bool Equals(IMayHaveValue other) { return other != null && !other.HasValue; }
public bool Equals(IMayHaveValue other) { throw new NotImplementedException(); }