Changing BotBase behaviour to fluent api
- removing unecessary constructors from BotBase - removing generics from BotBase - removing generics from SessionBase - adding StartFormFactory interface - adding DefaultStartFormFactory - adding multiple methods to BotBaseBuilder
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Factories
|
||||
{
|
||||
public class DefaultStartFormFactory : Interfaces.IStartFormFactory
|
||||
{
|
||||
private readonly Type _startFormClass;
|
||||
|
||||
public DefaultStartFormFactory(Type startFormClass)
|
||||
{
|
||||
if (!typeof(FormBase).IsAssignableFrom(startFormClass))
|
||||
throw new ArgumentException("startFormClass argument must be a FormBase type");
|
||||
|
||||
_startFormClass = startFormClass;
|
||||
}
|
||||
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return _startFormClass.GetConstructor(new Type[] { })?.Invoke(new object[] { }) as FormBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user