mirror of
https://github.com/cadmium-im/zirconium-sharp.git
synced 2024-11-23 10:52:25 +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 server settings
|
||||||
[Websocket]
|
[Websocket]
|
||||||
Host = "localhost"
|
Host = "localhost"
|
||||||
Port = 8000
|
Port = 8000
|
||||||
Endpoint = ""
|
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
|
namespace Zirconium.Core
|
||||||
{
|
{
|
||||||
public class Config
|
public class Config
|
||||||
@ -16,6 +18,9 @@ namespace Zirconium.Core
|
|||||||
|
|
||||||
// Websocket server settings
|
// Websocket server settings
|
||||||
public Websocket Websocket { get; set; }
|
public Websocket Websocket { get; set; }
|
||||||
|
|
||||||
|
// Configurations of plugins
|
||||||
|
public Dictionary<string, dynamic> Plugins { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Websocket
|
public class Websocket
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Zirconium.Core.Models;
|
using Zirconium.Core.Models;
|
||||||
@ -36,6 +37,16 @@ namespace Zirconium.Core.Modules
|
|||||||
return _app.Config.ServerID;
|
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)
|
public void Hook(IC2SMessageHandler handler)
|
||||||
{
|
{
|
||||||
_router.AddC2SHandler(handler.GetHandlingMessageType(), handler);
|
_router.AddC2SHandler(handler.GetHandlingMessageType(), handler);
|
||||||
|
@ -13,5 +13,7 @@ namespace Zirconium.Core.Modules.Interfaces
|
|||||||
string[] GetServerDomains();
|
string[] GetServerDomains();
|
||||||
string GetServerID();
|
string GetServerID();
|
||||||
void SendMessage(ConnectionInfo connInfo, BaseMessage message);
|
void SendMessage(ConnectionInfo connInfo, BaseMessage message);
|
||||||
|
dynamic GetSettings(IModuleAPI plugin);
|
||||||
|
dynamic GetSettings(string pluginName);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<BuildProjectReferences>false</BuildProjectReferences>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../../Zirconium/Zirconium.csproj" />
|
<ProjectReference Include="../../Zirconium/Zirconium.csproj">
|
||||||
|
<ExcludeAssets>runtime</ExcludeAssets>
|
||||||
|
</ProjectReference>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user