mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Code cleanup
This commit is contained in:
+7
-5
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -107,7 +109,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
/// </summary>
|
||||
/// <param name="path">The full path to assembly file</param>
|
||||
/// <returns><see cref="IEnumerable{T}"/> if success, null otherwise.</returns>
|
||||
private IEnumerable<Type> LoadAssembly(string path)
|
||||
private IEnumerable<Type>? LoadAssembly(string path)
|
||||
{
|
||||
Assembly assembly;
|
||||
try
|
||||
@@ -150,7 +152,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
var module = _modules.FirstOrDefault(module => module.GetType() == moduleType);
|
||||
if (module == null)
|
||||
{
|
||||
module = (Module) Activator.CreateInstance(moduleType, this);
|
||||
module = (Module) Activator.CreateInstance(moduleType, this)!;
|
||||
Console.WriteLine($"Started module {module.GetType().Name}");
|
||||
_modules.Add(module);
|
||||
}
|
||||
@@ -169,12 +171,12 @@ namespace Kruzya.TelegramBot.Core
|
||||
var possiblePaths = new List<string>();
|
||||
if (args.RequestingAssembly != null)
|
||||
{
|
||||
var modulePath = Path.GetDirectoryName(args.RequestingAssembly.Location);
|
||||
var modulePath = Path.GetDirectoryName(args.RequestingAssembly.Location)!;
|
||||
possiblePaths.Add(modulePath);
|
||||
possiblePaths.Add(args.RequestingAssembly.Location.Replace(".dll", ""));
|
||||
}
|
||||
|
||||
possiblePaths.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
|
||||
possiblePaths.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!);
|
||||
possiblePaths.Add(Environment.CurrentDirectory);
|
||||
|
||||
foreach (var basePath in possiblePaths)
|
||||
|
||||
Reference in New Issue
Block a user