Update for easier serialization during BotBaseBuilder
This commit is contained in:
parent
077bd1384f
commit
4026f9ba4e
@ -993,7 +993,7 @@ var bb = BotBaseBuilder
|
||||
{
|
||||
a.AddStartCommand("Starts the bot");
|
||||
})
|
||||
.UseSerialization(new TelegramBotBase.States.SimpleJSONStateMachine(AppContext.BaseDirectory + "config\\states.json"))
|
||||
.UseSimpleJSON(AppContext.BaseDirectory + "config\\states.json")
|
||||
.Build();
|
||||
|
||||
//Start your Bot
|
||||
@ -1017,7 +1017,7 @@ var bb = BotBaseBuilder
|
||||
{
|
||||
a.AddStartCommand("Starts the bot");
|
||||
})
|
||||
.UseSerialization(new TelegramBotBase.States.JSONStateMachine(AppContext.BaseDirectory + "config\\states.json"))
|
||||
.UseJSON(AppContext.BaseDirectory + "config\\states.json")
|
||||
.Build();
|
||||
|
||||
//Start your Bot
|
||||
@ -1042,7 +1042,7 @@ var bb = BotBaseBuilder
|
||||
{
|
||||
a.AddStartCommand("Starts the bot");
|
||||
})
|
||||
.UseSerialization(new TelegramBotBase.States.XMLStateMachine(AppContext.BaseDirectory + "config\\states.xml"))
|
||||
.UseXML(AppContext.BaseDirectory + "config\\states.xml")
|
||||
.Build();
|
||||
|
||||
//Start your Bot
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="17.0.0" />
|
||||
<PackageReference Include="TelegramBotBase" Version="5.0.2-alpha" />
|
||||
<PackageReference Include="TelegramBotBase" Version="5.0.5-alpha" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user