di and serialization support
All checks were successful
build nuget workflow for TelegramBotBase project / Build-TelegramBotBase (x64, linux) (push) Successful in 37s
All checks were successful
build nuget workflow for TelegramBotBase project / Build-TelegramBotBase (x64, linux) (push) Successful in 37s
This commit is contained in:
parent
0931147f5a
commit
6a80ec66ad
@ -8,7 +8,7 @@ jobs:
|
|||||||
Build-TelegramBotBase:
|
Build-TelegramBotBase:
|
||||||
env:
|
env:
|
||||||
APP_PROJECT_NAME: TelegramBotBase
|
APP_PROJECT_NAME: TelegramBotBase
|
||||||
PACKAGE_VERSION: "123.0.0"
|
PACKAGE_VERSION: "123.0.1"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
|
|||||||
@ -23,13 +23,15 @@ public class ServiceProviderStartFormFactory : IStartFormFactory
|
|||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormBase CreateForm()
|
public FormBase CreateForm() => CreateForm(null);
|
||||||
|
|
||||||
|
public FormBase CreateForm(Type? specifiedStartFrom = null)
|
||||||
{
|
{
|
||||||
FormBase fb = null;
|
FormBase fb = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fb = (FormBase)ActivatorUtilities.CreateInstance(_serviceProvider, _startFormClass);
|
fb = (FormBase)ActivatorUtilities.CreateInstance(_serviceProvider, specifiedStartFrom ?? _startFormClass);
|
||||||
}
|
}
|
||||||
catch(InvalidOperationException ex)
|
catch(InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using TelegramBotBase.Args;
|
using TelegramBotBase.Args;
|
||||||
using TelegramBotBase.Attributes;
|
using TelegramBotBase.Attributes;
|
||||||
using TelegramBotBase.Base;
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Factories;
|
||||||
using TelegramBotBase.Form;
|
using TelegramBotBase.Form;
|
||||||
using TelegramBotBase.Interfaces;
|
using TelegramBotBase.Interfaces;
|
||||||
using TelegramBotBase.Sessions;
|
using TelegramBotBase.Sessions;
|
||||||
@ -145,9 +146,17 @@ public class SessionManager
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
FormBase form;
|
||||||
|
if (BotBase.StartFormFactory is ServiceProviderStartFormFactory diFactory)
|
||||||
|
{
|
||||||
|
form = diFactory.CreateForm(t);
|
||||||
|
}
|
||||||
//No default constructor, fallback
|
//No default constructor, fallback
|
||||||
if (!(t.GetConstructor(new Type[] { })?.Invoke(new object[] { }) is FormBase form))
|
else if (t.GetConstructor(new Type[] { })?.Invoke(new object[] { }) is FormBase f)
|
||||||
|
{
|
||||||
|
form = f;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!statemachine.FallbackStateForm.IsSubclassOf(typeof(FormBase)))
|
if (!statemachine.FallbackStateForm.IsSubclassOf(typeof(FormBase)))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user