< Summary

Information
Class: Trailblazer.Support.LifecycleHookRegistration
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Support/LifecycleHooks/LifecycleHookRegistration.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 28
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Dispose()100%22100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Support/LifecycleHooks/LifecycleHookRegistration.cs

#LineLine coverage
 1using System;
 2
 3namespace Trailblazer.Support;
 4
 5/// <summary>
 6/// Represents a registration for a lifecycle hook, allowing it to be unregistered when disposed.
 7/// </summary>
 8public sealed class LifecycleHookRegistration : IDisposable
 9{
 10    private Action? _dispose;
 11
 12    /// <summary>
 13    /// Initializes a new instance of the LifecycleHookRegistration class with the specified dispose action.
 14    /// </summary>
 15    /// <param name="dispose">The action to execute when the registration is disposed.</param>
 2416    public LifecycleHookRegistration(Action dispose) => _dispose = dispose;
 17
 18    /// <inheritdoc/>
 19    public void Dispose()
 20    {
 1621        Action? dispose = _dispose;
 1622        if (dispose == null)
 423            return;
 24
 1225        _dispose = null;
 1226        dispose();
 1227    }
 28}

Methods/Properties

.ctor(System.Action)
Dispose()