Module Archeticture
This commit is contained in:
@@ -6,13 +6,13 @@ public class WeatherModule : IModule
|
||||
{
|
||||
public string Name => "Прогноз Погоды";
|
||||
|
||||
public string[] GetCommands() => new[] { "ShowWeather", "Ping" };
|
||||
public string[] GetCommands() => new[] { "Погода", "Пинг" };
|
||||
|
||||
public object Execute(string command, object[] args)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case "ShowWeather":
|
||||
case "Погода":
|
||||
// args[0] — это родительское окно из Ядра
|
||||
var parentWindow = args != null && args.Length > 0 ? args[0] as Window : null;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class WeatherModule : IModule
|
||||
|
||||
return "Окно открыто успешно";
|
||||
|
||||
case "Ping":
|
||||
case "Пинг":
|
||||
return "Pong! Модуль погоды активен.";
|
||||
|
||||
default:
|
||||
|
||||
@@ -35,8 +35,11 @@ public class Core
|
||||
if (type != null)
|
||||
{
|
||||
var module = (IModule)Activator.CreateInstance(type)!;
|
||||
Core._loadedModules.Add(module.Name, module);
|
||||
|
||||
_loadedModules.Add(module.Name, module);
|
||||
foreach (var cmd in module.GetCommands())
|
||||
{
|
||||
Console.WriteLine($"- {cmd}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user