From f80fda8ff9cc428e1958570c88051ac60363c991 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Sun, 5 Apr 2020 23:46:33 +0700 Subject: [PATCH] More Attributes for Serialization - adding IgnoreState Attribute to make it easier to skip forms on session serialization --- TelegramBotBase/Attributes/IgnoreState.cs | 17 +++++++++++++++++ TelegramBotBase/BotBase.cs | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 TelegramBotBase/Attributes/IgnoreState.cs diff --git a/TelegramBotBase/Attributes/IgnoreState.cs b/TelegramBotBase/Attributes/IgnoreState.cs new file mode 100644 index 0000000..e1c5543 --- /dev/null +++ b/TelegramBotBase/Attributes/IgnoreState.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TelegramBotBase.Attributes +{ + + /// + /// Declares that this class should not be getting serialized + /// + [AttributeUsage(AttributeTargets.Class)] + public class IgnoreState : Attribute + { + + + } +} diff --git a/TelegramBotBase/BotBase.cs b/TelegramBotBase/BotBase.cs index 9b6227f..f6dd56a 100644 --- a/TelegramBotBase/BotBase.cs +++ b/TelegramBotBase/BotBase.cs @@ -584,6 +584,11 @@ namespace TelegramBotBase se.FormUri = form.GetType().FullName; se.QualifiedName = form.GetType().AssemblyQualifiedName; + if (form.GetType().GetCustomAttributes(typeof(IgnoreState), true).Length != 0) + { + continue; + } + //Is Subclass of IStateForm var iform = form as IStateForm; if (iform != null)