public BotCallbackQueryAttribute(BotCallbackQueryType botCallbackQueryType) { BotCallbackQueryType = botCallbackQueryType; }
public static bool TryGetCallbackQuery(this IEnumerable <IBotCallbackQuery> callbackQueries, BotCallbackQueryType botCallbackQueryType, out IBotCallbackQuery botCallbackQuery) { if (callbackQueries is null) { throw new ArgumentNullException(nameof(callbackQueries)); } if (botCallbackQueryType is BotCallbackQueryType.None) { botCallbackQuery = null; return(false); } foreach (var item in callbackQueries) { if (Attribute.IsDefined(item.GetType(), typeof(BotCallbackQueryAttribute))) { var stateHandlerAttributes = (BotCallbackQueryAttribute[])Attribute.GetCustomAttributes(item.GetType(), typeof(BotCallbackQueryAttribute)); var attribute = stateHandlerAttributes.FirstOrDefault(x => x.BotCallbackQueryType == botCallbackQueryType); if (attribute is not null) { botCallbackQuery = item; return(true); } } } botCallbackQuery = null; return(false); }