< Summary

Information
Class: TeleFlow.Annotations.ChatTypeAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Filters/ChatTypeAttribute.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 28
Line coverage: 83.3%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%2283.33%

File(s)

/_/src/TeleFlow.Annotations/Filters/ChatTypeAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Restricts a handler or handler class to specific Telegram chat types.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
 6public sealed class ChatTypeAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a chat type filter.
 10    /// </summary>
 11    /// <param name="chatTypes">Telegram chat types allowed to match.</param>
 2712    public ChatTypeAttribute(params TelegramChatType[] chatTypes)
 13    {
 2714        ArgumentNullException.ThrowIfNull(chatTypes);
 15
 2716        if (chatTypes.Length == 0)
 17        {
 018            throw new ArgumentException("At least one Telegram chat type must be specified.", nameof(chatTypes));
 19        }
 20
 2721        ChatTypes = chatTypes.ToArray();
 2722    }
 23
 24    /// <summary>
 25    /// Telegram chat types allowed to match.
 26    /// </summary>
 27    public IReadOnlyList<TelegramChatType> ChatTypes { get; }
 28}