using System.Diagnostics; namespace LeagueAPI.Utils; public class ProcessInfo { private static readonly List Behaviors = [ new PortTokenWithLockfile(), new PortTokenWithProcessList(), ]; public int AppPort { get; } public string RemotingAuthToken { get; } internal ProcessInfo(Process process) { List 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); } }