mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Added some more plugin architecture (modules are now a type of plugin)
This commit is contained in:
1 parent
f093520ce8
commit
c761c880ed
22 files changed
+122
-122
No files matched your search
@@ -185,7 +185,6 @@
|
||||
<Compile Include="Exceptions\ArtemisCoreException.cs" />
|
||||
<Compile Include="Exceptions\ArtemisModuleException.cs" />
|
||||
<Compile Include="Models\ModuleInfo.cs" />
|
||||
<Compile Include="Modules\Interfaces\IModule.cs" />
|
||||
<Compile Include="Ninject\CoreModule.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Scripting.evaluator.cs" />
|
||||
@@ -194,9 +193,9 @@
|
||||
<Compile Include="Services\CoreService.cs" />
|
||||
<Compile Include="Services\Interfaces\IArtemisService.cs" />
|
||||
<Compile Include="Services\Interfaces\ICoreService.cs" />
|
||||
<Compile Include="Services\Interfaces\IModuleService.cs" />
|
||||
<Compile Include="Services\Interfaces\IPluginService.cs" />
|
||||
<Compile Include="Events\ModuleEventArgs.cs" />
|
||||
<Compile Include="Services\ModuleService.cs" />
|
||||
<Compile Include="Services\PluginService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
@@ -206,6 +205,12 @@
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Artemis.Plugins\Artemis.Plugins.csproj">
|
||||
<Project>{cd23bc5e-57f0-46ce-a007-24d031146219}</Project>
|
||||
<Name>Artemis.Plugins</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\RGB.NET.Devices.Asus.0.0.1.20\build\net45\RGB.NET.Devices.Asus.targets" Condition="Exists('..\packages\RGB.NET.Devices.Asus.0.0.1.20\build\net45\RGB.NET.Devices.Asus.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Artemis.Core.Modules.Interfaces;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Events
|
||||
{
|
||||
public class ModuleEventArgs : System.EventArgs
|
||||
{
|
||||
public IModule Module { get; set; }
|
||||
public IPlugin Plugin { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Modules.Interfaces;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core.Models
|
||||
@@ -12,6 +12,6 @@ namespace Artemis.Core.Models
|
||||
public IReadOnlyList<string> SubFiles { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IModule Module { get; set; }
|
||||
public IPlugin Plugin { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Artemis.Core.Modules.Interfaces
|
||||
{
|
||||
public interface IModule
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,24 +5,24 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
public class CoreService : ICoreService
|
||||
{
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IPluginService _pluginService;
|
||||
|
||||
public CoreService(IModuleService moduleService)
|
||||
public CoreService(IPluginService pluginService)
|
||||
{
|
||||
_moduleService = moduleService;
|
||||
_pluginService = pluginService;
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_moduleService.Dispose();
|
||||
_pluginService.Dispose();
|
||||
}
|
||||
|
||||
public bool IsInitialized { get; set; }
|
||||
|
||||
private async Task Initialize()
|
||||
{
|
||||
await _moduleService.LoadModules();
|
||||
await _pluginService.LoadModules();
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Modules.Interfaces;
|
||||
using Artemis.Plugins.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Services.Interfaces
|
||||
{
|
||||
public interface IModuleService : IArtemisService, IDisposable
|
||||
public interface IPluginService : IArtemisService, IDisposable
|
||||
{
|
||||
Task LoadModules();
|
||||
Task ReloadModule(IModule module);
|
||||
Task ReloadModule(IPlugin plugin);
|
||||
|
||||
event EventHandler<ModuleEventArgs> ModuleLoaded;
|
||||
event EventHandler<ModuleEventArgs> ModuleReloaded;
|
||||
+9
-9
@@ -6,27 +6,27 @@ using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models;
|
||||
using Artemis.Core.Modules.Interfaces;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.Interfaces;
|
||||
using CSScriptLibrary;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
public class ModuleService : IModuleService
|
||||
public class PluginService : IPluginService
|
||||
{
|
||||
private readonly List<IModule> _modules;
|
||||
private readonly List<IPlugin> _modules;
|
||||
|
||||
public ModuleService()
|
||||
public PluginService()
|
||||
{
|
||||
_modules = new List<IModule>();
|
||||
_modules = new List<IPlugin>();
|
||||
|
||||
if (!Directory.Exists(Constants.DataFolder + "modules"))
|
||||
Directory.CreateDirectory(Constants.DataFolder + "modules");
|
||||
}
|
||||
|
||||
public bool LoadingModules { get; private set; }
|
||||
public ReadOnlyCollection<IModule> Modules => _modules.AsReadOnly();
|
||||
public ReadOnlyCollection<IPlugin> Modules => _modules.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Loads all installed modules. If modules already loaded this will reload them all
|
||||
@@ -50,7 +50,7 @@ namespace Artemis.Core.Services
|
||||
OnFinishedLoadedModules();
|
||||
}
|
||||
|
||||
public async Task ReloadModule(IModule module)
|
||||
public async Task ReloadModule(IPlugin plugin)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
}
|
||||
|
||||
private async Task<IModule> LoadModuleFromFolder(string folder)
|
||||
private async Task<IPlugin> LoadModuleFromFolder(string folder)
|
||||
{
|
||||
if (!folder.EndsWith("\\"))
|
||||
folder += "\\";
|
||||
@@ -67,7 +67,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
var moduleInfo = JsonConvert.DeserializeObject<ModuleInfo>(File.ReadAllText(folder + "module.json"));
|
||||
// Load the main module which will contain a class implementing IModule
|
||||
var module = await CSScript.Evaluator.LoadFileAsync<IModule>(folder + moduleInfo.MainFile);
|
||||
var module = await CSScript.Evaluator.LoadFileAsync<IPlugin>(folder + moduleInfo.MainFile);
|
||||
return module;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user