Ejemplo n.º 1
0
 public static void NullOrWhitespace(this GuardClause g, string?input, string argumentName, string?errorMessage = null)
 {
     if (string.IsNullOrWhiteSpace(input))
     {
         throw new ArgumentException(errorMessage, argumentName);
     }
 }
Ejemplo n.º 2
0
 public static void Null(this GuardClause g, object input, string argumentName, string?errorMessage = null)
 {
     if (input == null)
     {
         throw new ArgumentException(errorMessage, argumentName);
     }
 }
Ejemplo n.º 3
0
 public static void Null <T>(this GuardClause g, object input, string errorMessage) where T : Exception, new()
 {
     if (input == null)
     {
         Type            classType        = typeof(T);
         ConstructorInfo classConstructor = classType.GetConstructor(new Type[] { typeof(string) });
         T ex = (T)classConstructor.Invoke(parameters: new object[] { errorMessage });
         throw ex;
     }
 }