< 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: 35
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
 1//=======================================================================
 2// LifecycleHookRegistration.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9
 10namespace Trailblazer.Support;
 11
 12/// <summary>
 13/// Represents a registration for a lifecycle hook, allowing it to be unregistered when disposed.
 14/// </summary>
 15internal sealed class LifecycleHookRegistration : IDisposable
 16{
 17    private Action? _dispose;
 18
 19    /// <summary>
 20    /// Initializes a new instance of the LifecycleHookRegistration class with the specified dispose action.
 21    /// </summary>
 22    /// <param name="dispose">The action to execute when the registration is disposed.</param>
 2623    public LifecycleHookRegistration(Action dispose) => _dispose = dispose;
 24
 25    /// <inheritdoc/>
 26    public void Dispose()
 27    {
 1728        Action? dispose = _dispose;
 1729        if (dispose == null)
 430            return;
 31
 1332        _dispose = null;
 1333        dispose();
 1334    }
 35}

Methods/Properties

.ctor(System.Action)
Dispose()