-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include type forwarders when looking for components (.NET Core only)
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace IS4.SFI.Application.Tools | ||
{ | ||
/// <summary> | ||
/// Provides extension methods for application-related classes. | ||
/// </summary> | ||
public static class Extensions | ||
{ | ||
static readonly Func<Assembly, Type[]> getForwardedTypes; | ||
|
||
static Extensions() | ||
{ | ||
var forwardedTypesMethod = typeof(Assembly).GetMethod("GetForwardedTypes", Type.EmptyTypes); | ||
if(forwardedTypesMethod != null) | ||
{ | ||
getForwardedTypes = (Func<Assembly, Type[]>)Delegate.CreateDelegate(typeof(Func<Assembly, Type[]>), forwardedTypesMethod); | ||
}else{ | ||
getForwardedTypes = _ => Array.Empty<Type>(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the collection of forwarded types in <paramref name="assembly"/>. | ||
/// </summary> | ||
/// <param name="assembly">The assembly to browse.</param> | ||
/// <returns>The array of types forwarded to another assembly.</returns> | ||
public static Type[] GetForwardedTypes(this Assembly assembly) | ||
{ | ||
return getForwardedTypes(assembly); | ||
} | ||
} | ||
} |