< Summary

Information
Class: Elsa.Alterations.Core.Abstractions.AlterationHandlerBase<T>
Assembly: Elsa.Alterations.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Abstractions/AlterationHandlerBase.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 33
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CanHandle(...)100%210%
HandleAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Abstractions/AlterationHandlerBase.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contexts;
 2using Elsa.Alterations.Core.Contracts;
 3
 4namespace Elsa.Alterations.Core.Abstractions;
 5
 6/// <summary>
 7/// A base class for alterations.
 8/// </summary>
 9public abstract class AlterationHandlerBase : IAlterationHandler
 10{
 11    /// <inheritdoc />
 12    public abstract bool CanHandle(IAlteration alteration);
 13
 14    /// <inheritdoc />
 15    public abstract ValueTask HandleAsync(AlterationContext context);
 16}
 17
 18/// <inheritdoc />
 19public abstract class AlterationHandlerBase<T> : AlterationHandlerBase where T : IAlteration
 20{
 21    /// <inheritdoc />
 022    public override bool CanHandle(IAlteration alteration) => alteration is T;
 23
 24    /// <inheritdoc />
 025    public override ValueTask HandleAsync(AlterationContext context) => HandleAsync(context, (T)context.Alteration);
 26
 27    /// <summary>
 28    /// Applies the alteration to the specified context.
 29    /// </summary>
 30    /// <param name="context">A context object that contains information for the alteration and provides a way to alter 
 31    /// <param name="alteration">A strongly typed alteration.</param>
 32    protected abstract ValueTask HandleAsync(AlterationContext context, T alteration);
 33}