Skip to content

Commit

Permalink
add assembly resolver to help with more permissive plugin references …
Browse files Browse the repository at this point in the history
…to iw4madmin libraries
  • Loading branch information
RaidMax committed May 28, 2023
1 parent 1a4e9b6 commit c8691f4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Application/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ public class Program
public static async Task Main(string[] args)
{
AppDomain.CurrentDomain.SetData("DataDirectory", Utilities.OperatingDirectory);
AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) =>
{
var libraryName = eventArgs.Name.Split(",").First();
var overrides = new[] { nameof(SharedLibraryCore), nameof(Stats) };
if (!overrides.Contains(libraryName))
{
return AppDomain.CurrentDomain.GetAssemblies().First(asm => asm.FullName == eventArgs.Name);
}
// added to be a bit more permissive with plugin references
return AppDomain.CurrentDomain.GetAssemblies()
.FirstOrDefault(asm => asm.FullName?.StartsWith(libraryName) ?? false);
};

Console.OutputEncoding = Encoding.UTF8;
Console.ForegroundColor = ConsoleColor.Gray;
Expand Down Expand Up @@ -413,9 +426,9 @@ private static void ConfigureServices(IServiceCollection serviceCollection)
commandConfigHandler.BuildAsync().GetAwaiter().GetResult();

var appConfig = appConfigHandler.Configuration();
var masterUri = Utilities.IsDevelopment
var masterUri = /*Utilities.IsDevelopment
? new Uri("http://127.0.0.1:8080")
: appConfig?.MasterUrl ?? new ApplicationConfiguration().MasterUrl;
: appConfig?.MasterUrl ?? */new ApplicationConfiguration().MasterUrl;
var httpClient = new HttpClient
{
BaseAddress = masterUri,
Expand Down

0 comments on commit c8691f4

Please sign in to comment.