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:
parent
bab69b593e
commit
f3167eda2c
22
TelegramBotBase/Base/LambdaStartFormFactory.cs
Normal file
22
TelegramBotBase/Base/LambdaStartFormFactory.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user