More Attributes for Serialization

- adding IgnoreState Attribute to make it easier to skip forms on session serialization
This commit is contained in:
FlorianDahn 2020-04-05 23:46:33 +07:00
parent 8b66842d34
commit f80fda8ff9
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TelegramBotBase.Attributes
{
/// <summary>
/// Declares that this class should not be getting serialized
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class IgnoreState : Attribute
{
}
}

View File

@ -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)