public static void IfNull <ObjT>(this Nullable <ObjT> value, Action action) where ObjT : struct { if (value.IsNull()) { action(); } }
public static T IfNull <ObjT, T>(this Nullable <ObjT> value, Func <T> action) where ObjT : struct { if (value.IsNull()) { return(action()); } return(default(T)); }
public static T IfNull <ObjT, T>(this Nullable <ObjT> value, Func <T> actionIfNull, Func <T> actionIfNotNull) where ObjT : struct { if (value.IsNull()) { return(actionIfNull()); } else { return(actionIfNotNull()); } }
public static bool IsNotNull <T>(this Nullable <T> obj) where T : struct { return(!obj.IsNull()); }
public void IsNull_IsNotNull_false_on_not_null_nullable() { Nullable <int> obj = 12; Assert.True(!obj.IsNull() && obj.IsNotNull()); }
public void IsNull_IsNotNull_true_on_null_nullable() { Nullable <int> obj = null; Assert.True(obj.IsNull() && !obj.IsNotNull()); }