1234567891011121314151617181920212223 |
- using System;
- namespace Wayne.Lib
- {
- public static class ParamGuard
- {
- public static void AssertIsNotNull<T>(T paramValue, string paramName) where T : class
- {
- if (paramValue == null)
- {
- throw new ArgumentNullException(paramName);
- }
- }
- public static void AssertMeetsCondition<T>(T paramValue, Func<T, bool> paramChecker, string paramName, string conditionName)
- {
- if (!paramChecker(paramValue))
- {
- throw new ArgumentException(string.Format("Parameter {0} does not meet condition {1} ", paramName, conditionName));
- }
- }
- }
- }
|