Add LambdaStartFormFactory.cs that allows pass parameters without creating factory class

eg. BotBase bb = new BotBase(api, new LambdaStartFormFactory(
    () => new Start(posible, parameters)
));
This commit is contained in:
Victor 2021-10-11 14:37:15 +03:00
parent bab69b593e
commit f3167eda2c

View File

@ -0,0 +1,22 @@
using TelegramBotBase.Form;
using TelegramBotBase.Interfaces;
namespace TelegramBotBase.Base
{
public class LambdaStartFormFactory : IStartFormFactory
{
public delegate FormBase CreateFormDelegate();
private readonly CreateFormDelegate _lambda;
public LambdaStartFormFactory(CreateFormDelegate lambda)
{
_lambda = lambda;
}
public FormBase CreateForm()
{
return _lambda();
}
}
}