Class StaticFunctions
This class is intended to be use static
'd and includes generic utility and readability functions
Inheritance
Inherited Members
Namespace: Piksel.Helpers
Assembly: cs.temp.dll.dll
Syntax
public static class StaticFunctions
Examples
using static Piksel.Helpers.StaticFunctions;
Methods
Attempt<TResult>(Func<TResult>, String)
Execute tryFunc
in a try-catch clause returning it's result.
If it fails, throw new failureMessage
and tryFunc
.
Declaration
public static TResult Attempt<TResult>(Func<TResult> tryFunc, string failureMessage)
Parameters
Type | Name | Description |
---|---|---|
Func<TResult> | tryFunc | The function to execute inside the clause |
System.String | failureMessage | The message that the resulting Exception will contain upon failure |
Returns
Type | Description |
---|---|
TResult | Instance of |
Type Parameters
Name | Description |
---|---|
TResult | Type of return value, can usually be inferred from |
Examples
var something = Attempt(() => foo.GetSomethingThatMayFail(), "Failed to get Something from foo");
TryOrThrow(Action, String)
Execute tryFunc
in a try-catch clause.
If it fails, throw new failureMessage
and tryFunc
.
Declaration
public static void TryOrThrow(Action tryFunc, string failureMessage)
Parameters
Type | Name | Description |
---|---|---|
Action | tryFunc | The function to execute inside the clause |
System.String | failureMessage | The message that the resulting Exception will contain upon failure |
Examples
TryOrThrow(() => foo.DoSomethingThatMayFail(), "Failed to do Something using foo");