You've already forked CC-Framework.BriskGameServer
75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
public abstract class BriskModuleBase
|
|
{
|
|
protected static BriskContext GetContext()
|
|
{
|
|
return Brisk.GetRequiredContext();
|
|
}
|
|
|
|
protected static Task<T> ExecuteAsync<T>(Func<BriskContext, Task<T>> action)
|
|
{
|
|
return BriskModuleExecutor.ExecuteAsync(action);
|
|
}
|
|
|
|
protected static Task ExecuteAsync(Func<BriskContext, Task> action)
|
|
{
|
|
return BriskModuleExecutor.ExecuteAsync(action);
|
|
}
|
|
|
|
protected static Task<T> ExecutePublicAsync<T>(Func<BriskContext, Task<T>> action)
|
|
{
|
|
return BriskModuleExecutor.ExecutePublicAsync(action);
|
|
}
|
|
|
|
protected static Task ExecutePublicAsync(Func<BriskContext, Task> 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>(T value, string paramName) where T : class
|
|
{
|
|
GetContext();
|
|
if (value == null)
|
|
{
|
|
throw new ArgumentNullException(paramName);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
}
|