More Attributes for Serialization
- adding IgnoreState Attribute to make it easier to skip forms on session serialization
This commit is contained in:
parent
8b66842d34
commit
f80fda8ff9
17
TelegramBotBase/Attributes/IgnoreState.cs
Normal file
17
TelegramBotBase/Attributes/IgnoreState.cs
Normal 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
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -584,6 +584,11 @@ namespace TelegramBotBase
|
|||||||
se.FormUri = form.GetType().FullName;
|
se.FormUri = form.GetType().FullName;
|
||||||
se.QualifiedName = form.GetType().AssemblyQualifiedName;
|
se.QualifiedName = form.GetType().AssemblyQualifiedName;
|
||||||
|
|
||||||
|
if (form.GetType().GetCustomAttributes(typeof(IgnoreState), true).Length != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Is Subclass of IStateForm
|
//Is Subclass of IStateForm
|
||||||
var iform = form as IStateForm;
|
var iform = form as IStateForm;
|
||||||
if (iform != null)
|
if (iform != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user