mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
+17
-18
@@ -1,25 +1,24 @@
|
||||
namespace Artemis.Core.Modules
|
||||
namespace Artemis.Core.Modules;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by returning the value of ActivationMet
|
||||
/// </summary>
|
||||
public class BooleanActivationRequirement : IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by returning the value of ActivationMet
|
||||
/// Gets or sets whether the activation requirement is met
|
||||
/// </summary>
|
||||
public class BooleanActivationRequirement : IModuleActivationRequirement
|
||||
public bool ActivationMet { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether the activation requirement is met
|
||||
/// </summary>
|
||||
public bool ActivationMet { get; set; }
|
||||
return ActivationMet;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
return ActivationMet;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetUserFriendlyDescription()
|
||||
{
|
||||
return "No description available";
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public string GetUserFriendlyDescription()
|
||||
{
|
||||
return "No description available";
|
||||
}
|
||||
}
|
||||
+14
-15
@@ -1,20 +1,19 @@
|
||||
namespace Artemis.Core.Modules
|
||||
namespace Artemis.Core.Modules;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking requirements specific to the implementation
|
||||
/// </summary>
|
||||
public interface IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking requirements specific to the implementation
|
||||
/// Called to determine whether the activation requirement is met
|
||||
/// </summary>
|
||||
public interface IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Called to determine whether the activation requirement is met
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Evaluate();
|
||||
/// <returns></returns>
|
||||
bool Evaluate();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a user-friendly description of the activation requirement, should include parameters if applicable
|
||||
/// </summary>
|
||||
/// <returns>A user-friendly description of the activation requirement</returns>
|
||||
string GetUserFriendlyDescription();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a user-friendly description of the activation requirement, should include parameters if applicable
|
||||
/// </summary>
|
||||
/// <returns>A user-friendly description of the activation requirement</returns>
|
||||
string GetUserFriendlyDescription();
|
||||
}
|
||||
+43
-44
@@ -5,62 +5,61 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Services;
|
||||
|
||||
namespace Artemis.Core.Modules
|
||||
namespace Artemis.Core.Modules;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking if the specified process is running
|
||||
/// </summary>
|
||||
public class ProcessActivationRequirement : IModuleActivationRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Evaluates to true or false by checking if the specified process is running
|
||||
/// Creates a new instance of the <see cref="ProcessActivationRequirement" /> class
|
||||
/// </summary>
|
||||
public class ProcessActivationRequirement : IModuleActivationRequirement
|
||||
/// <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)
|
||||
{
|
||||
/// <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)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(processName) && string.IsNullOrWhiteSpace(location))
|
||||
throw new ArgumentNullException($"Atleast one {nameof(processName)} and {nameof(location)} must not be null");
|
||||
if (string.IsNullOrWhiteSpace(processName) && string.IsNullOrWhiteSpace(location))
|
||||
throw new ArgumentNullException($"Atleast one {nameof(processName)} and {nameof(location)} must not be null");
|
||||
|
||||
ProcessName = processName;
|
||||
Location = location;
|
||||
}
|
||||
ProcessName = processName;
|
||||
Location = location;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the process that must run
|
||||
/// </summary>
|
||||
public string? ProcessName { get; set; }
|
||||
/// <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; }
|
||||
/// <summary>
|
||||
/// The location of where the process must be running from
|
||||
/// </summary>
|
||||
public string? Location { get; set; }
|
||||
|
||||
internal static IProcessMonitorService? ProcessMonitorService { get; set; }
|
||||
internal static IProcessMonitorService? ProcessMonitorService { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
if (ProcessMonitorService == null || ProcessName == null && Location == null)
|
||||
return false;
|
||||
/// <inheritdoc />
|
||||
public bool Evaluate()
|
||||
{
|
||||
if (ProcessMonitorService == null || (ProcessName == null && Location == null))
|
||||
return false;
|
||||
|
||||
IEnumerable<Process> processes = ProcessMonitorService.GetRunningProcesses();
|
||||
if (ProcessName != null)
|
||||
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (Location != null)
|
||||
processes = processes.Where(p => string.Equals(Path.GetDirectoryName(p.GetProcessFilename()), Location, StringComparison.InvariantCultureIgnoreCase));
|
||||
IEnumerable<Process> processes = ProcessMonitorService.GetRunningProcesses();
|
||||
if (ProcessName != null)
|
||||
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (Location != null)
|
||||
processes = processes.Where(p => string.Equals(Path.GetDirectoryName(p.GetProcessFilename()), Location, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
return processes.Any();
|
||||
}
|
||||
return processes.Any();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetUserFriendlyDescription()
|
||||
{
|
||||
string description = $"Requirement met when \"{ProcessName}.exe\" is running";
|
||||
if (Location != null)
|
||||
description += $" from \"{Location}\"";
|
||||
/// <inheritdoc />
|
||||
public string GetUserFriendlyDescription()
|
||||
{
|
||||
string description = $"Requirement met when \"{ProcessName}.exe\" is running";
|
||||
if (Location != null)
|
||||
description += $" from \"{Location}\"";
|
||||
|
||||
return description;
|
||||
}
|
||||
return description;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user