IgnoreState and SaveState addings for better session serialization

- adding IgnoreState to all ModalDialogs to prevent them get saved.
- adding SaveState to AutoCleanForm to keep state
- change OldMessages property of AutoCleanForm to public
This commit is contained in:
FlorianDahn 2020-05-07 23:49:08 +02:00
parent 9314b4c0e5
commit 47876681e0
5 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base; using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
@ -11,6 +12,7 @@ namespace TelegramBotBase.Form
/// <summary> /// <summary>
/// A simple prompt dialog with one ok Button /// A simple prompt dialog with one ok Button
/// </summary> /// </summary>
[IgnoreState]
public class AlertDialog : ConfirmDialog public class AlertDialog : ConfirmDialog
{ {
public String ButtonText { get; set; } public String ButtonText { get; set; }

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base; using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
@ -12,11 +13,11 @@ namespace TelegramBotBase.Form
/// <summary> /// <summary>
/// A prompt with a lot of buttons /// A prompt with a lot of buttons
/// </summary> /// </summary>
[IgnoreState]
public class ArrayPromptDialog : FormBase public class ArrayPromptDialog : FormBase
{ {
public String Message { get; set; } public String Message { get; set; }
public ButtonBase[][] Buttons { get; set; } public ButtonBase[][] Buttons { get; set; }
[Obsolete] [Obsolete]

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base; using TelegramBotBase.Base;
using TelegramBotBase.Enums; using TelegramBotBase.Enums;
@ -15,10 +16,13 @@ namespace TelegramBotBase.Form
/// </summary> /// </summary>
public class AutoCleanForm : FormBase public class AutoCleanForm : FormBase
{ {
List<Message> OldMessages { get; set; } [SaveState]
public List<Message> OldMessages { get; set; }
[SaveState]
public eDeleteMode DeleteMode { get; set; } public eDeleteMode DeleteMode { get; set; }
[SaveState]
public eDeleteSide DeleteSide { get; set; } public eDeleteSide DeleteSide { get; set; }

View File

@ -5,15 +5,16 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base; using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
[IgnoreState]
public class ConfirmDialog : ModalDialog public class ConfirmDialog : ModalDialog
{ {
public String Message { get; set; } public String Message { get; set; }
public List<ButtonBase> Buttons { get; set; } public List<ButtonBase> Buttons { get; set; }
private EventHandlerList __Events { get; set; } = new EventHandlerList(); private EventHandlerList __Events { get; set; } = new EventHandlerList();

View File

@ -5,10 +5,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base; using TelegramBotBase.Base;
namespace TelegramBotBase.Form namespace TelegramBotBase.Form
{ {
[IgnoreState]
public class PromptDialog : ModalDialog public class PromptDialog : ModalDialog
{ {
public String Message { get; set; } public String Message { get; set; }