using System; using System.Threading.Tasks; public abstract class BriskModuleBase { protected static BriskContext GetContext() { return Brisk.GetRequiredContext(); } protected static Task ExecuteAsync(Func> action) { return BriskModuleExecutor.ExecuteAsync(action); } protected static Task ExecuteAsync(Func action) { return BriskModuleExecutor.ExecuteAsync(action); } protected static Task ExecutePublicAsync(Func> action) { return BriskModuleExecutor.ExecutePublicAsync(action); } protected static Task ExecutePublicAsync(Func action) { return BriskModuleExecutor.ExecutePublicAsync(action); } protected static string RequireNotEmpty(string value, string paramName) { GetContext(); if (string.IsNullOrWhiteSpace(value)) { throw new ArgumentException(paramName + " is required.", paramName); } return value; } protected static int RequirePositive(int value, string paramName, string message) { GetContext(); if (value <= 0) { throw new ArgumentOutOfRangeException(paramName, message); } return value; } protected static long RequirePositive(long value, string paramName, string message) { GetContext(); if (value <= 0) { throw new ArgumentOutOfRangeException(paramName, message); } return value; } protected static T RequireNotNull(T value, string paramName) where T : class { GetContext(); if (value == null) { throw new ArgumentNullException(paramName); } return value; } }