Skip to content

Commit

Permalink
Added IsInModule
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Sep 14, 2023
1 parent aee6995 commit 5694b3a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Bannerlord.BUTR.Shared/Helpers/ModuleInfoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,18 @@ public static bool IsModuleAssembly(ModuleInfoExtendedWithMetadata loadedModule,
if (assembly.IsDynamic || string.IsNullOrWhiteSpace(assembly.CodeBase))
return false;

return IsInModule(loadedModule, assembly.CodeBase);
}

public static bool IsInModule(ModuleInfoExtendedWithMetadata loadedModule, string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
return false;

var modulePath = new Uri(Path.GetFullPath(loadedModule.Path));
var moduleDirectory = Path.GetFileName(loadedModule.Path);

var assemblyPath = new Uri(assembly.CodeBase);
var assemblyPath = new Uri(filePath);
var relativePath = modulePath.MakeRelativeUri(assemblyPath);
return relativePath.OriginalString.StartsWith(moduleDirectory);
}
Expand Down

0 comments on commit 5694b3a

Please sign in to comment.