namespace Eis.Web.Configuration;

public static class ApplicationPaths
{
    public static string FindApplicationRoot()
    {
        foreach (var start in new[] { Directory.GetCurrentDirectory(), AppContext.BaseDirectory })
        {
            var directory = new DirectoryInfo(Path.GetFullPath(start));
            while (directory is not null)
            {
                if (File.Exists(Path.Combine(directory.FullName, "Eis.slnx")))
                {
                    return directory.FullName;
                }
                directory = directory.Parent;
            }
        }

        return Path.GetFullPath(Directory.GetCurrentDirectory());
    }
}
