Table of Contents

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

string

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

condition Func<bool>

Predicate that returns true to allow access.

message string

Error message used when access is denied.

Returns

Guard

Guard that evaluates condition to decide whether access is allowed.

Exceptions

ArgumentNullException

condition is null.

ArgumentException

message is empty.

Manual(string)

Creates a manually controlled guard.

[Pure]
public static ToggleGuard Manual(string errorMessage)

Parameters

errorMessage string

Message 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()

Returns

bool