Files
LeagueARAMTracker/LeagueAPI/Utils/ProcessInfo.cs
2026-03-08 20:45:01 +01:00

34 lines
884 B
C#

using System.Diagnostics;
namespace LeagueAPI.Utils;
public class ProcessInfo
{
private static readonly List<IPortTokenBehavior> Behaviors =
[
new PortTokenWithLockfile(),
new PortTokenWithProcessList(),
];
public int AppPort { get; }
public string RemotingAuthToken { get; }
internal ProcessInfo(Process process)
{
List<Exception> exceptions = [];
foreach (IPortTokenBehavior behavior in Behaviors)
{
if (behavior.TryGet(process, out string remotingAuthToken, out int appPort, out Exception? exception))
{
RemotingAuthToken = remotingAuthToken;
AppPort = appPort;
return;
}
exceptions.Add(exception);
}
throw new AggregateException("Unable to obtain process information.", exceptions);
}
}