< Summary

Information
Class: TeleFlow.Annotations.StateAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/State/StateAttribute.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 44
Line coverage: 100%
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
.ctor(...)100%11100%

File(s)

/_/src/TeleFlow.Annotations/State/StateAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Restricts a handler or handler class to updates whose current state matches the specified state id.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 6public sealed class StateAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a state filter.
 10    /// </summary>
 11    /// <param name="state">State id that must be active for the handler to match.</param>
 1812    public StateAttribute(string state)
 13    {
 1814        ArgumentException.ThrowIfNullOrWhiteSpace(state);
 15        State = state;
 1816    }
 17
 18    /// <summary>
 19    /// State id that must be active for the handler to match.
 20    /// </summary>
 21    public string State { get; }
 22}
 23/// <summary>
 24/// Restricts a handler or handler class to a state from a typed state group.
 25/// </summary>
 26/// <typeparam name="TStateGroup">State group type decorated with <see cref="StateGroupAttribute"/>.</typeparam>
 27[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 28public sealed class StateAttribute<TStateGroup> : TeleFlowAttribute
 29{
 30    /// <summary>
 31    /// Creates a typed state-group filter.
 32    /// </summary>
 33    /// <param name="stateName">State name inside the typed state group.</param>
 34    public StateAttribute(string stateName)
 35    {
 36        ArgumentException.ThrowIfNullOrWhiteSpace(stateName);
 37        StateName = stateName;
 38    }
 39
 40    /// <summary>
 41    /// State name inside the typed state group.
 42    /// </summary>
 43    public string StateName { get; }
 44}

Methods/Properties

.ctor(System.String)