Skip to content

Commit

Permalink
Update ReflectionUtility.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
GregaMohorko authored Oct 20, 2017
1 parent ebd1e20 commit 7bff426
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/GM.Utility/GM.Utility/ReflectionUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -134,12 +135,40 @@ public static AssemblyInformation GetAssemblyInformation(Assembly assembly)
}

/// <summary>
/// Gets the local (operating-system wise) path of the assembly that defines the specified type.
/// Gets the local (operating-system wise) directory path of the assembly that defines the specified type.
/// </summary>
/// <param name="type">The type that is defined in the assembly of which to get the local path.</param>
public static string GetAssemblyLocalPath(Type type)
/// <param name="type">The type that is defined in the assembly of which to get the local directory path.</param>
public static string GetAssemblyDirectoryLocalPath(Type type)
{
string codebase = type.Assembly.CodeBase;
return GetAssemblyDirectoryLocalPath(type.Assembly);
}

/// <summary>
/// Gets the local (operating-system wise) directory path of the specified assembly.
/// </summary>
/// <param name="assembly">The assembly.</param>
public static string GetAssemblyDirectoryLocalPath(Assembly assembly)
{
string filePath = GetAssemblyFileLocalPath(assembly);
return Path.GetDirectoryName(filePath);
}

/// <summary>
/// Gets the local (operating-system wise) file (.dll) path of the assembly that defines the specified type.
/// </summary>
/// <param name="type">The type that is defined in the assembly of which to get the local file path.</param>
public static string GetAssemblyFileLocalPath(Type type)
{
return GetAssemblyFileLocalPath(type.Assembly);
}

/// <summary>
/// Gets the local (operating-system wise) file (.dll) path of the specified assembly.
/// </summary>
/// <param name="assembly">The assembly.</param>
public static string GetAssemblyFileLocalPath(Assembly assembly)
{
string codebase = assembly.CodeBase;
var uri = new Uri(codebase, UriKind.Absolute);
return uri.LocalPath;
}
Expand Down

0 comments on commit 7bff426

Please sign in to comment.