Class Global
Global utility methods.
Inheritance
Namespace: CarinaStudio
Assembly: CarinaStudio.AppBase.Core.dll
Syntax
public static class Global : object
Methods
| Improve this Doc View SourceRun<R>(PointerOutFunc<R>)
Generate a pointer of unmanaged type.
Declaration
public static R*Run<R>(PointerOutFunc<R> func)
where R : struct
Parameters
Type | Name | Description |
---|---|---|
Pointer |
func | Function to generate pointer of unmanaged type. |
Returns
Type | Description |
---|---|
R* | Generated pointer of unmanaged type. |
Type Parameters
Name | Description |
---|---|
R | Unmanaged type. |
Run<R>(RefOutFunc<R>)
Generate a reference to value.
Declaration
public static ref R Run<R>(RefOutFunc<R> func)
Parameters
Type | Name | Description |
---|---|---|
Ref |
func | Function to generate reference to value. |
Returns
Type | Description |
---|---|
R | Generated reference to value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
Run<R>(Func<R>)
Generate a value.
Declaration
public static R Run<R>(Func<R> func)
Parameters
Type | Name | Description |
---|---|---|
Func<R> | func | Function to generate value. |
Returns
Type | Description |
---|---|
R | Generated value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
RunCatching<T>(Func<T>)
Generate value and catch exception if occurred.
Declaration
public static Global.RunCatchingResult<T> RunCatching<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func | Function to generate value. |
Returns
Type | Description |
---|---|
Global. |
Global.RunCatchingResult<T> contains the result and exception occurred. |
Type Parameters
Name | Description |
---|---|
T | Type of generated value. |
RunOrDefault<R>(Func<R>, R)
Try generating value or return default value if error occurs.
Declaration
public static R RunOrDefault<R>(Func<R> func, R defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
Func<R> | func | Function to generate value. |
R | defaultValue | Default value. |
Returns
Type | Description |
---|---|
R | Generated value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
RunOrDefault<R>(Func<R>, Action<Exception>, R)
Try generating value or return default value if error occurs.
Declaration
public static R RunOrDefault<R>(Func<R> func, Action<Exception> errorHandler, R defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
Func<R> | func | Function to generate value. |
Action<Exception> | errorHandler | Action to handle occurred error. |
R | defaultValue | Default value. |
Returns
Type | Description |
---|---|
R | Generated value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
RunOrDefaultAsync<R>(Func<Task<R>>, R)
Try generating value asynchronously or return default value if error occurs.
Declaration
public static async Task<R> RunOrDefaultAsync<R>(Func<Task<R>> func, R defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<R>> | func | Function to generate value. |
R | defaultValue | Default value. |
Returns
Type | Description |
---|---|
Task<R> | Generated value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
RunOrDefaultAsync<R>(Func<Task<R>>, Action<Exception>, R)
Try generating value asynchronously or return default value if error occurs.
Declaration
public static async Task<R> RunOrDefaultAsync<R>(Func<Task<R>> func, Action<Exception> errorHandler, R defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<R>> | func | Function to generate value. |
Action<Exception> | errorHandler | Action to handle occurred error. |
R | defaultValue | Default value. |
Returns
Type | Description |
---|---|
Task<R> | Generated value. |
Type Parameters
Name | Description |
---|---|
R | Type of generated value. |
RunWithoutError(Action)
Run given action and ignore any error occurred.
Declaration
public static void RunWithoutError(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Action to run. |
RunWithoutErrorAsync(Action)
Run given action and ignore any error occurred asynchronously.
Declaration
public static void RunWithoutErrorAsync(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | Action to run. |
RunWithoutErrorAsync(Func<Task>)
Run given action and ignore any error occurred asynchronously.
Declaration
public static async Task RunWithoutErrorAsync(Func<Task> action)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | action | Action to run. |
Returns
Type | Description |
---|---|
Task |