2020-03-01 22:09:14 +04:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
namespace Kruzya.TelegramBot.Core;
|
|
|
|
|
|
|
|
|
|
public abstract class Module
|
2020-03-01 22:09:14 +04:00
|
|
|
{
|
2023-07-29 15:14:52 +03:00
|
|
|
protected readonly Core Core;
|
|
|
|
|
protected IConfiguration Configuration => Core.Configuration;
|
2020-03-01 22:09:14 +04:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
public Module(Core core)
|
|
|
|
|
{
|
|
|
|
|
Core = core;
|
|
|
|
|
}
|
2020-03-01 22:09:14 +04:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
public virtual void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-03-01 22:09:14 +04:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-03-01 22:09:14 +04:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Ensures if module is loaded and started. Note that call can change module event chain.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">The Module type.</typeparam>
|
|
|
|
|
/// <returns>Module instance.</returns>
|
|
|
|
|
protected T EnsureLoaded<T>() where T : Module
|
|
|
|
|
{
|
|
|
|
|
return (T) Core.EnsureLoaded(typeof(T));
|
2020-03-01 22:09:14 +04:00
|
|
|
}
|
2023-07-29 15:14:52 +03:00
|
|
|
}
|