Update for easier serialization during BotBaseBuilder

This commit is contained in:
FlorianDahn
2021-12-06 02:36:59 +01:00
parent 077bd1384f
commit 4026f9ba4e
4 changed files with 49 additions and 4 deletions
+20
View File
@@ -9,6 +9,7 @@ using TelegramBotBase.Builder.Interfaces;
using TelegramBotBase.Commands;
using TelegramBotBase.Form;
using TelegramBotBase.Interfaces;
using TelegramBotBase.States;
namespace TelegramBotBase.Builder
{
@@ -166,6 +167,25 @@ namespace TelegramBotBase.Builder
return this;
}
public IBuildingStage UseJSON(string path)
{
this._statemachine = new JSONStateMachine(path);
return this;
}
public IBuildingStage UseSimpleJSON(string path)
{
this._statemachine = new SimpleJSONStateMachine(path);
return this;
}
public IBuildingStage UseXML(string path)
{
this._statemachine = new XMLStateMachine(path);
return this;
}
public BotBase Build()
{
var bb = new BotBase();
@@ -13,6 +13,7 @@ namespace TelegramBotBase.Builder.Interfaces
/// <returns></returns>
IBuildingStage NoSerialization();
/// <summary>
/// Sets the state machine for serialization.
/// </summary>
@@ -20,5 +21,29 @@ namespace TelegramBotBase.Builder.Interfaces
/// <returns></returns>
IBuildingStage UseSerialization(IStateMachine machine);
/// <summary>
/// Using the complex version of .Net JSON, which can serialize all objects.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
IBuildingStage UseJSON(String path);
/// <summary>
/// Use the easy version of .Net JSON, which can serialize basic types, but not generics and others.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
IBuildingStage UseSimpleJSON(String path);
/// <summary>
/// Uses the XML serializer for session serialization.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
IBuildingStage UseXML(String path);
}
}