fix: assemblies are files, not directories

This commit is contained in:
Dylan R. E. Moonfire 2021-12-06 23:15:42 -06:00
parent 2800cd039a
commit e69971df7f
2 changed files with 16 additions and 2 deletions

View file

@ -30,7 +30,11 @@ The repository can also be added to a project by setting the `NuGet.Config` file
#### `DirectoryInfo? GetDirectory(this Assembly? assembly)`
Gets a directory representing the assembly's `Location` property or null.
Gets a directory containing the assembly directory.
#### `FileInfo? GetFile(this Assembly? assembly)`
Gets a file representing the assembly's `Location` property or null.
### DirectoryInfo Extensions

View file

@ -14,10 +14,20 @@ namespace MfGames.IO.Extensions
/// <param name="assembly">The assembly to get the directory.</param>
/// <returns>The directory or null if the assembly or location is null.</returns>
public static DirectoryInfo? GetDirectory(this Assembly? assembly)
{
return assembly.GetFile()?.Directory;
}
/// <summary>
/// Gets the file for a given assembly.
/// </summary>
/// <param name="assembly">The assembly to get the directory.</param>
/// <returns>The directory or null if the assembly or location is null.</returns>
public static FileInfo? GetFile(this Assembly? assembly)
{
return assembly?.Location == null
? null
: new DirectoryInfo(assembly.Location);
: new FileInfo(assembly.Location);
}
}
}