mirror of
https://github.com/cadmium-im/zirconium-sharp.git
synced 2024-09-07 22:16:17 +00:00
Implement configuration API for plugins
This commit is contained in:
parent
48d27401ae
commit
01a7589417
@ -12,6 +12,14 @@ ServerID = ""
|
||||
|
||||
# Websocket server settings
|
||||
[Websocket]
|
||||
Host = "localhost"
|
||||
Port = 8000
|
||||
Endpoint = ""
|
||||
Host = "localhost"
|
||||
Port = 8000
|
||||
Endpoint = ""
|
||||
|
||||
# Here you can specify settings that is exposed by plugins
|
||||
# For example - [Plugins.HelloWorld] is the settings for plugin called HelloWorld
|
||||
[Plugins]
|
||||
[Plugins.HelloWorld]
|
||||
text = "123"
|
||||
[Plugins.HelloWorld.Test]
|
||||
modes = ["abc"]
|
||||
|
@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Zirconium.Core
|
||||
{
|
||||
public class Config
|
||||
@ -16,6 +18,9 @@ namespace Zirconium.Core
|
||||
|
||||
// Websocket server settings
|
||||
public Websocket Websocket { get; set; }
|
||||
|
||||
// Configurations of plugins
|
||||
public Dictionary<string, dynamic> Plugins { get; set; }
|
||||
}
|
||||
|
||||
public class Websocket
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Zirconium.Core.Models;
|
||||
@ -36,6 +37,16 @@ namespace Zirconium.Core.Modules
|
||||
return _app.Config.ServerID;
|
||||
}
|
||||
|
||||
public dynamic GetSettings(IModuleAPI plugin)
|
||||
{
|
||||
return _app.Config.Plugins.GetValueOrDefault(plugin.GetModuleUniqueName(), null);
|
||||
}
|
||||
|
||||
public dynamic GetSettings(string pluginName)
|
||||
{
|
||||
return _app.Config.Plugins.GetValueOrDefault(pluginName, null);
|
||||
}
|
||||
|
||||
public void Hook(IC2SMessageHandler handler)
|
||||
{
|
||||
_router.AddC2SHandler(handler.GetHandlingMessageType(), handler);
|
||||
|
@ -13,5 +13,7 @@ namespace Zirconium.Core.Modules.Interfaces
|
||||
string[] GetServerDomains();
|
||||
string GetServerID();
|
||||
void SendMessage(ConnectionInfo connInfo, BaseMessage message);
|
||||
dynamic GetSettings(IModuleAPI plugin);
|
||||
dynamic GetSettings(string pluginName);
|
||||
}
|
||||
}
|
@ -2,11 +2,15 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<BuildProjectReferences>false</BuildProjectReferences>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../Zirconium/Zirconium.csproj" />
|
||||
<ProjectReference Include="../../Zirconium/Zirconium.csproj">
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
</ProjectReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user