This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-io-cil/src/MfGames.IO/Extensions/TypeExtensions.cs

32 lines
986 B
C#

using System;
using System.IO;
namespace MfGames.IO.Extensions
{
/// <summary>
/// Additional methods for types.
/// </summary>
public static class TypeExtensions
{
/// <summary>
/// Gets the directory for a given type.
/// </summary>
/// <param name="type">The type assembly to get the directory.</param>
/// <returns>The directory or null if the assembly or location is null.</returns>
public static DirectoryInfo? GetDirectory(this Type? type)
{
return type?.Assembly.GetDirectory();
}
/// <summary>
/// Gets the file for a given type's assembly.
/// </summary>
/// <param name="type">The type assembly to get the directory.</param>
/// <returns>The directory or null if the assembly or location is null.</returns>
public static FileInfo? GetFile(this Type? type)
{
return type?.Assembly.GetFile();
}
}
}