forked from adam/discord-bot-shtik
organize - behaver is not a behavior, only one use of connection string
This commit is contained in:
parent
6d181e2b68
commit
ef31418166
@ -1,5 +1,6 @@
|
|||||||
namespace vassago.Behavior;
|
namespace vassago;
|
||||||
#pragma warning disable 4014 //the "not awaited" error
|
#pragma warning disable 4014 //the "not awaited" error
|
||||||
|
using vassago.Behavior;
|
||||||
using vassago.Models;
|
using vassago.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,18 +13,18 @@ public class Behaver
|
|||||||
{
|
{
|
||||||
private List<Account> SelfAccounts { get; set; } = new List<Account>();
|
private List<Account> SelfAccounts { get; set; } = new List<Account>();
|
||||||
private User SelfUser { get; set; }
|
private User SelfUser { get; set; }
|
||||||
public static List<Behavior> Behaviors { get; private set; } = new List<Behavior>();
|
public static List<vassago.Behavior.Behavior> Behaviors { get; private set; } = new List<vassago.Behavior.Behavior>();
|
||||||
internal Behaver()
|
internal Behaver()
|
||||||
{
|
{
|
||||||
var subtypes = AppDomain.CurrentDomain.GetAssemblies()
|
var subtypes = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
.SelectMany(domainAssembly => domainAssembly.GetTypes())
|
.SelectMany(domainAssembly => domainAssembly.GetTypes())
|
||||||
.Where(type => type.IsSubclassOf(typeof(Behavior)) && !type.IsAbstract &&
|
.Where(type => type.IsSubclassOf(typeof(vassago.Behavior.Behavior)) && !type.IsAbstract &&
|
||||||
type.GetCustomAttributes(typeof(StaticPlzAttribute),false)?.Any() == true)
|
type.GetCustomAttributes(typeof(StaticPlzAttribute),false)?.Any() == true)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var subtype in subtypes)
|
foreach (var subtype in subtypes)
|
||||||
{
|
{
|
||||||
Behaviors.Add((Behavior)Activator.CreateInstance(subtype));
|
Behaviors.Add((vassago.Behavior.Behavior)Activator.CreateInstance(subtype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static Behaver() { }
|
static Behaver() { }
|
@ -44,7 +44,7 @@ namespace vassago
|
|||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,6 +17,8 @@ public class ChattingContext : DbContext
|
|||||||
public ChattingContext(DbContextOptions<ChattingContext> options) : base(options) { }
|
public ChattingContext(DbContextOptions<ChattingContext> options) : base(options) { }
|
||||||
public ChattingContext() : base() { }
|
public ChattingContext() : base() { }
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
=> optionsBuilder.UseNpgsql(Shared.DBConnectionString)
|
{
|
||||||
|
optionsBuilder.UseNpgsql(Shared.DBConnectionString)
|
||||||
.EnableSensitiveDataLogging(true); //who the fuck is looking at log output but not allowed to see it? this should be on by default.
|
.EnableSensitiveDataLogging(true); //who the fuck is looking at log output but not allowed to see it? this should be on by default.
|
||||||
}
|
}
|
||||||
|
}
|
@ -6,8 +6,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
builder.Services.AddSingleton<IHostedService, vassago.ConsoleService>();
|
builder.Services.AddSingleton<IHostedService, vassago.ConsoleService>();
|
||||||
builder.Services.AddDbContext<ChattingContext>(options =>
|
builder.Services.AddDbContext<ChattingContext>();
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString("ChattingContext") ));
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user