Opting for precompiled plugins, removed CS-Script

Cleaned up Nuget packages
Cleaned up references
This commit is contained in:
SpoinkyNL committed 2019-04-10 00:33:21 +02:00
1 parent 1ae5a18c8e
commit aa32c8aae4
18 files changed
+133 -426

No files matched your search

+1 -1
View File
@@ -58,7 +58,7 @@ namespace Artemis.Core.Services
// Render all active modules
using (var g = _rgbService.GraphicsDecorator.GetGraphics())
{
g.Clear(Color.Black);
g.Clear(Color.Red);
foreach (var module in _pluginService.Plugins.Select(p => p.Plugin).OfType<IModule>())
module.Render(args.DeltaTime, _rgbService.Surface, g);
@@ -25,12 +25,6 @@ namespace Artemis.Core.Services.Interfaces
/// </summary>
Task LoadPlugins();
/// <summary>
/// Reloads the plugin accompanying the provided plugin info
/// </summary>
/// <param name="pluginInfo">The plugin info containing the plugin to reload</param>
Task ReloadPlugin(PluginInfo pluginInfo);
/// <summary>
/// Gets the view model of the module accompanying the provided plugin info
/// </summary>
@@ -42,10 +36,6 @@ namespace Artemis.Core.Services.Interfaces
/// </summary>
event EventHandler<PluginEventArgs> PluginLoaded;
/// <summary>
/// Occurs when a single plugin has reloaded
/// </summary>
event EventHandler<PluginEventArgs> PluginReloaded;
/// <summary>
/// Occurs when loading all plugins has started
+30 -23
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
@@ -12,12 +13,15 @@ using Artemis.Core.Plugins.Models;
using Artemis.Core.ProfileElements;
using Artemis.Core.Services.Interfaces;
using Ninject;
using Ninject.Extensions.ChildKernel;
namespace Artemis.Core.Services
{
public class PluginService : IPluginService
{
private readonly IKernel _kernel;
private IKernel _childKernel;
private AppDomain _appDomain;
private readonly List<PluginInfo> _plugins;
public PluginService(IKernel kernel)
@@ -40,25 +44,37 @@ namespace Artemis.Core.Services
OnStartedLoadingPlugins();
// Empty the list of plugins
foreach (var pluginInfo in _plugins)
pluginInfo.UnloadPlugin();
_plugins.Clear();
UnloadPlugins();
// Iterate all plugin folders and load each plugin
foreach (var directory in Directory.GetDirectories(Constants.DataFolder + "plugins"))
_plugins.Add(await PluginInfo.FromFolder(_kernel, directory));
// Create a child kernel and app domain that will only contain the plugins
_childKernel = new ChildKernel(_kernel);
_appDomain = AppDomain.CreateDomain("PluginAppDomain");
// Load the plugin assemblies into the app domain
var directory = new DirectoryInfo(Constants.DataFolder + "plugins");
foreach (var subDirectory in directory.EnumerateDirectories())
{
// _appDomain.Load()
// _plugins.Add(new PluginInfo(subDirectory.FullName));
}
OnFinishedLoadedPlugins();
}
/// <inheritdoc />
public async Task ReloadPlugin(PluginInfo pluginInfo)
private void UnloadPlugins()
{
pluginInfo.UnloadPlugin();
await pluginInfo.CompilePlugin(_kernel);
_plugins.Clear();
OnPluginReloaded(new PluginEventArgs(pluginInfo));
if (_childKernel != null)
{
_childKernel.Dispose();
_childKernel = null;
}
if (_appDomain != null)
{
AppDomain.Unload(_appDomain);
_appDomain = null;
}
}
/// <inheritdoc />
@@ -85,16 +101,12 @@ namespace Artemis.Core.Services
public void Dispose()
{
// Empty the list of plugins
foreach (var pluginInfo in _plugins)
pluginInfo.UnloadPlugin();
_plugins.Clear();
UnloadPlugins();
}
#region Events
public event EventHandler<PluginEventArgs> PluginLoaded;
public event EventHandler<PluginEventArgs> PluginReloaded;
public event EventHandler StartedLoadingPlugins;
public event EventHandler FinishedLoadedPlugins;
@@ -102,12 +114,7 @@ namespace Artemis.Core.Services
{
PluginLoaded?.Invoke(this, e);
}
private void OnPluginReloaded(PluginEventArgs e)
{
PluginReloaded?.Invoke(this, e);
}
private void OnStartedLoadingPlugins()
{
LoadingPlugins = true;
+1
View File
@@ -44,6 +44,7 @@ namespace Artemis.Core.Services
await Task.Run(() =>
{
// TODO SpoinkyNL 8-1-18: Keep settings into account
// This one doesn't work well without ASUS devices installed
// Surface.LoadDevices(AsusDeviceProvider.Instance);
+6 -8
View File
@@ -1,28 +1,26 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Plugins.Models;
using Artemis.Core.ProfileElements;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage;
using Microsoft.EntityFrameworkCore;
using Artemis.Storage.Repositories;
namespace Artemis.Core.Services
{
public class StorageService : IStorageService
{
private readonly StorageContext _dbContext;
private readonly IPluginService _pluginService;
private readonly ProfileRepository _profileRepository;
public StorageService(StorageContext dbContext, IPluginService pluginService)
public StorageService(IPluginService pluginService)
{
_dbContext = dbContext;
_pluginService = pluginService;
_profileRepository = new ProfileRepository();
}
public async Task<ICollection<Profile>> GetModuleProfiles(PluginInfo pluginInfo)
{
var profileEntities = await _dbContext.Profiles.Where(p => p.PluginGuid == pluginInfo.Guid).ToListAsync();
var profileEntities = await _profileRepository.GetByPluginGuidAsync(pluginInfo.Guid);
var profiles = new List<Profile>();
foreach (var profileEntity in profileEntities)
profiles.Add(Profile.FromProfileEntity(pluginInfo, profileEntity, _pluginService));
@@ -36,7 +34,7 @@ namespace Artemis.Core.Services
// If not found, create a new one
await _dbContext.SaveChangesAsync();
await _profileRepository.SaveAsync();
}
}