public static string IsRequired(this string source, string text, ConditionFlavor flavor) { switch (flavor) { case ConditionFlavor.Null: if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(source)) { throw new InvalidCastException("Failed to Merge Property [" + source + "] "); } break; case ConditionFlavor.Equal: if (!source.Equals(text)) { throw new InvalidCastException("Failed to Merge Property [" + source + "] "); } break; default: throw new InvalidCastException("Failed to Merge Property [" + source + "] "); } return(source); }
public static bool IsEffective(this DateTime x, DateTime y, ConditionFlavor conditionFlavor) { switch (conditionFlavor) { case ConditionFlavor.IsGreaterThan: if (x > y) { return(false); } break; case ConditionFlavor.IsEqual: if (x == y) { return(false); } break; default: return(false); } return(true); }