Class Guard
- Namespace
- Executables.Guards
- Assembly
- executables.dll
Factory methods for creating guards.
public abstract class Guard
- Inheritance
-
Guard
- Derived
- Inherited Members
Properties
ErrorMessage
Error message used when access is denied.
public abstract string ErrorMessage { get; }
Property Value
Methods
Create(Func<bool>, string)
Creates a guard from a predicate and error message.
[Pure]
public static Guard Create(Func<bool> condition, string message)
Parameters
conditionFunc<bool>Predicate that returns true to allow access.
messagestringError message used when access is denied.
Returns
- Guard
Guard that evaluates
conditionto decide whether access is allowed.
Exceptions
- ArgumentNullException
conditionis null.- ArgumentException
messageis empty.
Manual(string)
Creates a manually controlled guard.
[Pure]
public static ToggleGuard Manual(string errorMessage)
Parameters
errorMessagestringMessage returned when guard denies access.
Returns
- ToggleGuard
Guard that can deny and allow an access programmatically.
TryGetAccess()
Returns true when access is granted.
public abstract bool TryGetAccess()