mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Plugins - Adjusted namespaces
This commit is contained in:
1 parent
625fcbafdd
commit
e27f658cea
144 files changed
+267
-252
No files matched your search
+19
@@ -0,0 +1,19 @@
|
||||
namespace Artemis.Core.Plugins.Modules.ActivationRequirements
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by returning the value of ActivationMet
|
||||
/// </summary>
|
||||
public class BooleanActivationRequirement : IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether the activation requirement is met
|
||||
/// </summary>
|
||||
public bool ActivationMet { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
return ActivationMet;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
namespace Artemis.Core.Plugins.Modules.ActivationRequirements
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking requirements specific to the implementation
|
||||
/// </summary>
|
||||
public interface IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Called to determine whether the activation requirement is met
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Evaluate();
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
|
||||
namespace Artemis.Core.Plugins.Modules.ActivationRequirements
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking if the specified process is running
|
||||
/// </summary>
|
||||
public class ProcessActivationRequirement : IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ProcessActivationRequirement" /> class
|
||||
/// </summary>
|
||||
/// <param name="processName">The name of the process that must run</param>
|
||||
/// <param name="location">The location of where the process must be running from (optional)</param>
|
||||
public ProcessActivationRequirement(string processName, string location = null)
|
||||
{
|
||||
ProcessName = processName;
|
||||
Location = location;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the process that must run
|
||||
/// </summary>
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The location of where the process must be running from
|
||||
/// </summary>
|
||||
public string Location { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
if (ProcessName == null && Location == null)
|
||||
return false;
|
||||
|
||||
var processes = ProcessName != null ? Process.GetProcessesByName(ProcessName).Where(p => !p.HasExited) : Process.GetProcesses().Where(p => !p.HasExited);
|
||||
return Location != null
|
||||
? processes.Any(p => Path.GetDirectoryName(p.GetProcessFilename()) == Location)
|
||||
: processes.Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user