using System; namespace NucuCar.Domain.Utilities { /// /// Helper class used for checking arguments and raise exception if the checks don't pass. /// public static class Guard { /// /// Checks if the argument string is null or whitespace and raises exception on check fail. /// /// The argument name that will be logged in the exception message. /// The argument to check if it's null or whitespace. /// Raised if the argument is null or whitespace. public static void ArgumentNotNullOrWhiteSpace(string argumentName, string argument) { if (string.IsNullOrWhiteSpace(argument)) { throw new ArgumentNullException($"The argument {argumentName} is null or whitespace!"); } } /// /// Checks if the argument is null and raises exception on check fail. /// /// The argument name that will be logged in the exception message. /// The argument to check if it's null. /// Raised if the argument is null. public static void ArgumentNotNull(string argumentName, object argument) { if (argument == null) { throw new ArgumentNullException($"The argument {argumentName} is null or whitespace!"); } } } }