| | | 1 | | using System.ComponentModel; |
| | | 2 | | |
| | | 3 | | namespace TeleFlow.Telegram; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Infrastructure filter metadata emitted by TeleFlow source generators. |
| | | 7 | | /// This API is not intended to be used by application code. |
| | | 8 | | /// </summary> |
| | | 9 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 10 | | public sealed class TelegramGeneratedFilterDescriptor |
| | | 11 | | { |
| | | 12 | | public TelegramGeneratedFilterDescriptor( |
| | | 13 | | TelegramGeneratedFilterKind kind, |
| | | 14 | | IReadOnlyList<string>? stringValues = null, |
| | | 15 | | IReadOnlyList<long>? longValues = null) |
| | | 16 | | { |
| | | 17 | | Kind = kind; |
| | 675 | 18 | | StringValues = CopyValues(stringValues); |
| | 675 | 19 | | LongValues = CopyValues(longValues); |
| | 675 | 20 | | } |
| | | 21 | | |
| | | 22 | | public TelegramGeneratedFilterDescriptor(Type customFilterType) |
| | | 23 | | { |
| | 64 | 24 | | ArgumentNullException.ThrowIfNull(customFilterType); |
| | | 25 | | |
| | | 26 | | Kind = TelegramGeneratedFilterKind.Custom; |
| | | 27 | | CustomFilterType = customFilterType; |
| | | 28 | | StringValues = []; |
| | | 29 | | LongValues = []; |
| | 64 | 30 | | } |
| | | 31 | | |
| | | 32 | | public TelegramGeneratedFilterDescriptor( |
| | | 33 | | Type customFilterType, |
| | | 34 | | Type customFilterContextType) |
| | 32 | 35 | | : this(customFilterType) |
| | | 36 | | { |
| | 32 | 37 | | ArgumentNullException.ThrowIfNull(customFilterContextType); |
| | | 38 | | |
| | | 39 | | CustomFilterContextType = customFilterContextType; |
| | 32 | 40 | | } |
| | | 41 | | |
| | | 42 | | public TelegramGeneratedFilterDescriptor( |
| | | 43 | | Type customFilterType, |
| | | 44 | | Attribute customFilterAttribute) |
| | 0 | 45 | | : this(customFilterType) |
| | | 46 | | { |
| | 0 | 47 | | ArgumentNullException.ThrowIfNull(customFilterAttribute); |
| | | 48 | | |
| | | 49 | | CustomFilterAttribute = customFilterAttribute; |
| | 0 | 50 | | } |
| | | 51 | | |
| | | 52 | | public TelegramGeneratedFilterDescriptor( |
| | | 53 | | Type customFilterType, |
| | | 54 | | Type customFilterContextType, |
| | | 55 | | Attribute customFilterAttribute) |
| | 32 | 56 | | : this(customFilterType, customFilterContextType) |
| | | 57 | | { |
| | 32 | 58 | | ArgumentNullException.ThrowIfNull(customFilterAttribute); |
| | | 59 | | |
| | | 60 | | CustomFilterAttribute = customFilterAttribute; |
| | 32 | 61 | | } |
| | | 62 | | |
| | | 63 | | public TelegramGeneratedFilterKind Kind { get; } |
| | | 64 | | |
| | | 65 | | public Type? CustomFilterType { get; } |
| | | 66 | | |
| | | 67 | | public Type? CustomFilterContextType { get; } |
| | | 68 | | |
| | | 69 | | public Attribute? CustomFilterAttribute { get; } |
| | | 70 | | |
| | | 71 | | public IReadOnlyList<string> StringValues { get; } |
| | | 72 | | |
| | | 73 | | public IReadOnlyList<long> LongValues { get; } |
| | | 74 | | |
| | | 75 | | private static TValue[] CopyValues<TValue>(IReadOnlyList<TValue>? values) |
| | | 76 | | { |
| | 1350 | 77 | | return values is null || values.Count == 0 |
| | 1350 | 78 | | ? [] |
| | 1350 | 79 | | : values.ToArray(); |
| | | 80 | | } |
| | | 81 | | } |