Prerequisites - Moved to PluginInfo and FeatureInfo

Features don't have instances until they are enabled so this made sense, Plugins followed suit for consistency's sake
This commit is contained in:
Robert committed 2021-04-28 17:06:47 +02:00
1 parent 0cfddcbbaf
commit 5cae14efd3
8 files changed
+66 -31

No files matched your search

+10 -13
View File
@@ -78,11 +78,6 @@ namespace Artemis.Core
/// </summary>
public IKernel? Kernel { get; internal set; }
/// <summary>
/// Gets a list of prerequisites for this plugin feature
/// </summary>
public List<PluginPrerequisite> Prerequisites { get; } = new();
/// <summary>
/// The PluginLoader backing this plugin
/// </summary>
@@ -118,6 +113,16 @@ namespace Artemis.Core
{
return _features.FirstOrDefault(i => i.Instance is T)?.Instance as T;
}
/// <summary>
/// Looks up the feature info the feature of type <typeparamref name="T" />
/// </summary>
/// <typeparam name="T">The type of feature to find</typeparam>
/// <returns>If found, feature info of the feature</returns>
public PluginFeatureInfo? GetFeatureInfo<T>() where T : PluginFeature
{
return _features.FirstOrDefault(i => i.FeatureType == typeof(T));
}
/// <inheritdoc />
public override string ToString()
@@ -125,14 +130,6 @@ namespace Artemis.Core
return Info.ToString();
}
/// <summary>
/// Determines whether the prerequisites of this plugin are met
/// </summary>
public bool ArePrerequisitesMet()
{
return Prerequisites.All(p => p.IsMet());
}
/// <summary>
/// Occurs when the plugin is enabled
/// </summary>
@@ -60,11 +60,6 @@ namespace Artemis.Core
/// </summary>
public TimeSpan RenderTime { get; private set; }
/// <summary>
/// Gets a list of prerequisites for this plugin feature
/// </summary>
public List<PluginPrerequisite> Prerequisites { get; } = new();
internal PluginFeatureEntity Entity { get; set; } = null!; // Will be set right after construction
/// <summary>
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.DeviceProviders;
using Artemis.Core.LayerBrushes;
@@ -128,6 +130,19 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _instance, value);
}
/// <summary>
/// Gets a list of prerequisites for this plugin feature
/// </summary>
public List<PluginPrerequisite> Prerequisites { get; } = new();
/// <summary>
/// Determines whether the prerequisites of this feature are met
/// </summary>
public bool ArePrerequisitesMet()
{
return Prerequisites.All(p => p.IsMet());
}
/// <inheritdoc />
public override string ToString()
{
+16
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Newtonsoft.Json;
namespace Artemis.Core
@@ -117,6 +119,20 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _plugin, value);
}
/// <summary>
/// Gets a list of prerequisites for this plugin
/// </summary>
public List<PluginPrerequisite> Prerequisites { get; } = new();
/// <summary>
/// Determines whether the prerequisites of this plugin are met
/// </summary>
public bool ArePrerequisitesMet()
{
return Prerequisites.All(p => p.IsMet());
}
/// <inheritdoc />
public override string ToString()
{