Table of Contents

Class LifecycleHookHandler

Namespace
Gravitas.Support
Assembly
Gravitas.dll

Provides functionality to register, unregister, and invoke lifecycle hooks in a thread-safe manner.

public class LifecycleHookHandler
Inheritance
LifecycleHookHandler
Inherited Members

Constructors

LifecycleHookHandler()

public LifecycleHookHandler()

Methods

InvokeHooks(SwiftList<OrderedLifecycleHook>)

Invokes all registered lifecycle hooks in the order they were registered.

public void InvokeHooks(SwiftList<OrderedLifecycleHook> hooks)

Parameters

hooks SwiftList<OrderedLifecycleHook>

The list of hooks to invoke.

RegisterHook(SwiftList<OrderedLifecycleHook>, string, int, Action)

Registers a lifecycle hook with the specified owner, order, and callback. Hooks are executed in order of their specified order, and if orders are equal, they are sorted by owner name. The returned IDisposable can be used to unregister the hook when it is no longer needed.

public IDisposable RegisterHook(SwiftList<OrderedLifecycleHook> hooks, string owner, int order, Action callback)

Parameters

hooks SwiftList<OrderedLifecycleHook>

The list of hooks to register the new hook with.

owner string

The owner of the hook, used to identify and manage the hook.

order int

The order in which the hook should be executed relative to other hooks.

callback Action

The callback to invoke when the hook is executed.

Returns

IDisposable

An IDisposable that can be used to unregister the hook.

Exceptions

ArgumentException

Thrown if the owner is null or whitespace.

InvalidOperationException

Thrown if a hook with the same owner is already registered.

UnregisterHook(SwiftList<OrderedLifecycleHook>, string)

Unregisters a lifecycle hook based on the specified owner.

public void UnregisterHook(SwiftList<OrderedLifecycleHook> hooks, string owner)

Parameters

hooks SwiftList<OrderedLifecycleHook>

The list of hooks to unregister the hook from.

owner string

The owner of the hook to unregister.