Adding simplified versions for BotBaseBuilder serialization options.
This commit is contained in:
parent
d34df46087
commit
98eba1c5f9
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
@ -314,19 +315,63 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the application runtime path to load and write a states.json file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ILanguageSelectionStage UseJSON()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), "states.json");
|
||||||
|
_stateMachine = new JsonStateMachine(path);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the given path to load and write a states.json file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public ILanguageSelectionStage UseJSON(string path)
|
public ILanguageSelectionStage UseJSON(string path)
|
||||||
{
|
{
|
||||||
_stateMachine = new JsonStateMachine(path);
|
_stateMachine = new JsonStateMachine(path);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the application runtime path to load and write a states.json file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ILanguageSelectionStage UseSimpleJSON()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), "states.json");
|
||||||
|
_stateMachine = new SimpleJsonStateMachine(path);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the given path to load and write a states.json file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public ILanguageSelectionStage UseSimpleJSON(string path)
|
public ILanguageSelectionStage UseSimpleJSON(string path)
|
||||||
{
|
{
|
||||||
_stateMachine = new SimpleJsonStateMachine(path);
|
_stateMachine = new SimpleJsonStateMachine(path);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the application runtime path to load and write a states.xml file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ILanguageSelectionStage UseXML()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), "states.xml");
|
||||||
|
_stateMachine = new XmlStateMachine(path);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the given path to load and write a states.xml file.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public ILanguageSelectionStage UseXML(string path)
|
public ILanguageSelectionStage UseXML(string path)
|
||||||
{
|
{
|
||||||
_stateMachine = new XmlStateMachine(path);
|
_stateMachine = new XmlStateMachine(path);
|
||||||
|
|||||||
@ -18,6 +18,13 @@ public interface ISessionSerializationStage
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ILanguageSelectionStage UseSerialization(IStateMachine machine);
|
ILanguageSelectionStage UseSerialization(IStateMachine machine);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Using the complex version of .Net JSON, which can serialize all objects.
|
||||||
|
/// Saves in application directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ILanguageSelectionStage UseJSON();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Using the complex version of .Net JSON, which can serialize all objects.
|
/// Using the complex version of .Net JSON, which can serialize all objects.
|
||||||
@ -26,6 +33,13 @@ public interface ISessionSerializationStage
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ILanguageSelectionStage UseJSON(string path);
|
ILanguageSelectionStage UseJSON(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use the easy version of .Net JSON, which can serialize basic types, but not generics and others.
|
||||||
|
/// Saves in application directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ILanguageSelectionStage UseSimpleJSON();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use the easy version of .Net JSON, which can serialize basic types, but not generics and others.
|
/// Use the easy version of .Net JSON, which can serialize basic types, but not generics and others.
|
||||||
@ -34,6 +48,13 @@ public interface ISessionSerializationStage
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ILanguageSelectionStage UseSimpleJSON(string path);
|
ILanguageSelectionStage UseSimpleJSON(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the XML serializer for session serialization.
|
||||||
|
/// Saves in application directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ILanguageSelectionStage UseXML();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Uses the XML serializer for session serialization.
|
/// Uses the XML serializer for session serialization.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user