fix: assemblies are files, not directories
This commit is contained in:
parent
2800cd039a
commit
e69971df7f
2 changed files with 16 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue