using System; namespace StuntJuice.Portal.Core.DesignByContract { public sealed class StringCheckOptions { private string _stringToCheck; private string _message; public StringCheckOptions(string stringToCheck) { _stringToCheck = stringToCheck; } public void IsNotNullOrEmpty() { if (String.IsNullOrEmpty(_stringToCheck)) Check.ThrowArgumentNullException(_message); } public StringCheckOptions WithMessage(string message) { _message = message; return this; } } public sealed class ObjectCheckOptions { private object _objectToCheck; private string _message; public ObjectCheckOptions(object objectToCheck) { _objectToCheck = objectToCheck; } public void IsNotNull() { if (_objectToCheck == null) Check.ThrowArgumentNullException(_message); } public ObjectCheckOptions WithMessage(string message) { _message = message; return this; } } public sealed class Check { public static StringCheckOptions Parameter(string field) { return new StringCheckOptions(field); } public static ObjectCheckOptions Parameter(object param) { return new ObjectCheckOptions(param); } public static void ThrowArgumentNullException(string message) { if (!String.IsNullOrEmpty(message)) throw new ArgumentNullException("", message); else throw new ArgumentNullException(); } } }