fix: reformat using C# rules
This commit is contained in:
@@ -2,24 +2,25 @@
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Interfaces;
|
||||
|
||||
namespace TelegramBotBase.Factories
|
||||
namespace TelegramBotBase.Factories;
|
||||
|
||||
public class DefaultStartFormFactory : IStartFormFactory
|
||||
{
|
||||
public class DefaultStartFormFactory : IStartFormFactory
|
||||
private readonly Type _startFormClass;
|
||||
|
||||
public DefaultStartFormFactory(Type startFormClass)
|
||||
{
|
||||
private readonly Type _startFormClass;
|
||||
|
||||
public DefaultStartFormFactory(Type startFormClass)
|
||||
if (!typeof(FormBase).IsAssignableFrom(startFormClass))
|
||||
{
|
||||
if (!typeof(FormBase).IsAssignableFrom(startFormClass))
|
||||
throw new ArgumentException("startFormClass argument must be a FormBase type");
|
||||
|
||||
_startFormClass = startFormClass;
|
||||
throw new ArgumentException("startFormClass argument must be a FormBase type");
|
||||
}
|
||||
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return _startFormClass.GetConstructor(new Type[] { })?.Invoke(new object[] { }) as FormBase;
|
||||
}
|
||||
_startFormClass = startFormClass;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return _startFormClass.GetConstructor(new Type[] { })?.Invoke(new object[] { }) as FormBase;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Interfaces;
|
||||
|
||||
namespace TelegramBotBase.Factories
|
||||
namespace TelegramBotBase.Factories;
|
||||
|
||||
public class LambdaStartFormFactory : IStartFormFactory
|
||||
{
|
||||
public class LambdaStartFormFactory : IStartFormFactory
|
||||
public delegate FormBase CreateFormDelegate();
|
||||
|
||||
private readonly CreateFormDelegate _lambda;
|
||||
|
||||
public LambdaStartFormFactory(CreateFormDelegate lambda)
|
||||
{
|
||||
public delegate FormBase CreateFormDelegate();
|
||||
|
||||
private readonly CreateFormDelegate _lambda;
|
||||
|
||||
public LambdaStartFormFactory(CreateFormDelegate lambda)
|
||||
{
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return _lambda();
|
||||
}
|
||||
_lambda = lambda;
|
||||
}
|
||||
}
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return _lambda();
|
||||
}
|
||||
}
|
||||
@@ -3,33 +3,34 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using TelegramBotBase.Form;
|
||||
using TelegramBotBase.Interfaces;
|
||||
|
||||
namespace TelegramBotBase.Factories
|
||||
namespace TelegramBotBase.Factories;
|
||||
|
||||
public class ServiceProviderStartFormFactory : IStartFormFactory
|
||||
{
|
||||
public class ServiceProviderStartFormFactory : IStartFormFactory
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly Type _startFormClass;
|
||||
|
||||
public ServiceProviderStartFormFactory(Type startFormClass, IServiceProvider serviceProvider)
|
||||
{
|
||||
private readonly Type _startFormClass;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public ServiceProviderStartFormFactory(Type startFormClass, IServiceProvider serviceProvider)
|
||||
if (!typeof(FormBase).IsAssignableFrom(startFormClass))
|
||||
{
|
||||
if (!typeof(FormBase).IsAssignableFrom(startFormClass))
|
||||
throw new ArgumentException("startFormClass argument must be a FormBase type");
|
||||
|
||||
_startFormClass = startFormClass;
|
||||
_serviceProvider = serviceProvider;
|
||||
throw new ArgumentException("startFormClass argument must be a FormBase type");
|
||||
}
|
||||
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
return (FormBase)ActivatorUtilities.CreateInstance(_serviceProvider, _startFormClass);
|
||||
}
|
||||
_startFormClass = startFormClass;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public class ServiceProviderStartFormFactory<T> : ServiceProviderStartFormFactory
|
||||
where T : FormBase
|
||||
public FormBase CreateForm()
|
||||
{
|
||||
public ServiceProviderStartFormFactory(IServiceProvider serviceProvider) : base(typeof(T), serviceProvider)
|
||||
{
|
||||
}
|
||||
return (FormBase)ActivatorUtilities.CreateInstance(_serviceProvider, _startFormClass);
|
||||
}
|
||||
}
|
||||
|
||||
public class ServiceProviderStartFormFactory<T> : ServiceProviderStartFormFactory
|
||||
where T : FormBase
|
||||
{
|
||||
public ServiceProviderStartFormFactory(IServiceProvider serviceProvider) : base(typeof(T), serviceProvider)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user