You've already forked CC-Framework.BriskGameServer
Initial Brisk Unity SDK project
This commit is contained in:
74
Assets/BriskSdk/Runtime/Core/BriskModuleBase.cs
Normal file
74
Assets/BriskSdk/Runtime/Core/BriskModuleBase.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user