internal static void HandlerMustBeSet <TRunInfo>(CustomArgument <TRunInfo> argument, int commandLevel) where TRunInfo : class { if (argument.Handler == null) { throw new CommandValidationException("Custom Argument is missing its handler callback.", CommandValidationError.NullCustomHandler, commandLevel); } }
internal static void CountMustBeGreaterThanZero <TRunInfo>(CustomArgument <TRunInfo> argument, int commandLevel) where TRunInfo : class { if (argument.Count <= 0) { throw new CommandValidationException("Custom Argument has an invalid count. Must be greater than 0.", CommandValidationError.InvalidCount, commandLevel); } }
internal static List <Action <int> > Rules <TRunInfo>(CustomArgument <TRunInfo> argument) where TRunInfo : class { return(new List <Action <int> > { CountMustBeGreaterThanZero(argument), HandlerMustBeSet(argument) }); }
private static Action <int> HandlerMustBeSet <TRunInfo>(CustomArgument <TRunInfo> argument) where TRunInfo : class { return(commandLevel => { if (argument.Handler == null) { throw new CommandValidationException("Custom Argument is missing its handler callback.", CommandValidationError.NullCustomHandler, commandLevel); } }); }
private static Action <int> CountMustBeGreaterThanZero <TRunInfo>(CustomArgument <TRunInfo> argument) where TRunInfo : class { return(commandLevel => { if (argument.Count <= 0) { throw new CommandValidationException("Custom Argument has an invalid count. Must be greater than 0.", CommandValidationError.InvalidCount, commandLevel); } }); }