diff --git a/README.md b/README.md index b1fdcdf..b52f9b3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/TelegramBotBase.Extensions.Images/TelegramBotBase.Extensions.Images.csproj b/TelegramBotBase.Extensions.Images/TelegramBotBase.Extensions.Images.csproj index aa47dfd..ea76a8f 100644 --- a/TelegramBotBase.Extensions.Images/TelegramBotBase.Extensions.Images.csproj +++ b/TelegramBotBase.Extensions.Images/TelegramBotBase.Extensions.Images.csproj @@ -11,7 +11,7 @@ - + \ No newline at end of file diff --git a/TelegramBotBase/Builder/BotBaseBuilder.cs b/TelegramBotBase/Builder/BotBaseBuilder.cs index dc4eb33..0a91ea9 100644 --- a/TelegramBotBase/Builder/BotBaseBuilder.cs +++ b/TelegramBotBase/Builder/BotBaseBuilder.cs @@ -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(); diff --git a/TelegramBotBase/Builder/Interfaces/ISessionSerializationStage.cs b/TelegramBotBase/Builder/Interfaces/ISessionSerializationStage.cs index ee51bd6..7231c81 100644 --- a/TelegramBotBase/Builder/Interfaces/ISessionSerializationStage.cs +++ b/TelegramBotBase/Builder/Interfaces/ISessionSerializationStage.cs @@ -13,6 +13,7 @@ namespace TelegramBotBase.Builder.Interfaces /// IBuildingStage NoSerialization(); + /// /// Sets the state machine for serialization. /// @@ -20,5 +21,29 @@ namespace TelegramBotBase.Builder.Interfaces /// IBuildingStage UseSerialization(IStateMachine machine); + + /// + /// Using the complex version of .Net JSON, which can serialize all objects. + /// + /// + /// + IBuildingStage UseJSON(String path); + + + /// + /// Use the easy version of .Net JSON, which can serialize basic types, but not generics and others. + /// + /// + /// + IBuildingStage UseSimpleJSON(String path); + + + /// + /// Uses the XML serializer for session serialization. + /// + /// + /// + IBuildingStage UseXML(String path); + } }