< Summary

Information
Class: TeleFlow.Annotations.CommandTemplateAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Routing/CommandTemplateAttribute.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 42
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/Routing/CommandTemplateAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Routes a Telegram command message by matching a template and binding template values.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 6public sealed class CommandTemplateAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a command template route.
 10    /// </summary>
 11    /// <param name="template">Command template such as <c>ticket {id:long?}</c>.</param>
 8212    public CommandTemplateAttribute(string template)
 13    {
 8214        ArgumentException.ThrowIfNullOrWhiteSpace(template);
 15        Template = template;
 8216    }
 17
 18    /// <summary>
 19    /// Command template used for route matching and value binding.
 20    /// </summary>
 21    public string Template { get; }
 22
 23    /// <summary>
 24    /// Command prefixes accepted by this route. Defaults to <c>/</c>.
 25    /// </summary>
 8226    public string[] Prefixes { get; set; } = ["/"];
 27
 28    /// <summary>
 29    /// Defines whether the command prefix is required, optional, or disabled for this route.
 30    /// </summary>
 31    public CommandPrefixMode PrefixMode { get; set; } = CommandPrefixMode.Required;
 32
 33    /// <summary>
 34    /// Allows whitespace between the prefix and command body.
 35    /// </summary>
 36    public bool AllowSpaceAfterPrefix { get; set; }
 37
 38    /// <summary>
 39    /// Matches literal template parts without case sensitivity.
 40    /// </summary>
 41    public bool IgnoreCase { get; set; } = true;
 42}

Methods/Properties

.ctor(System.String)