Permalink
Browse files

Merge pull request #946 from thecodejunkie/adatsmethodmodifications

Added TypesOf overloads
  • Loading branch information...
2 parents 6d5aa79 + 4fedaca commit 0467152d9df2ef25f66f41ffbd58504bf962610f @grumpydev grumpydev committed Feb 4, 2013
Showing with 37 additions and 4 deletions.
  1. +37 −4 src/Nancy/Bootstrapper/AppDomainAssemblyTypeScanner.cs
View
41 src/Nancy/Bootstrapper/AppDomainAssemblyTypeScanner.cs
@@ -179,15 +179,26 @@ public static IEnumerable<Type> TypesOf<TType>(bool excludeInternalTypes = false
}
/// <summary>
+ /// Gets all non-Nancy types implementing a particular interface/base class
+ /// </summary>
+ /// <param name="type">Type to search for</param>
+ /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
+ /// <remarks>Will scan with <see cref="ScanMode.ExcludeNancy"/>.</remarks>
+ public static IEnumerable<Type> TypesOf(Type type)
+ {
+ return TypesOf(type, ScanMode.ExcludeNancy);
+ }
+
+ /// <summary>
/// Gets all types implementing a particular interface/base class
/// </summary>
- /// <typeparam name="TType">Type to search for</typeparam>
+ /// <param name="type">Type to search for</param>
/// <param name="mode">A <see cref="ScanMode"/> value to determin which type set to scan in.</param>
/// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
- public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
+ public static IEnumerable<Type> TypesOf(Type type, ScanMode mode)
{
- var returnTypes =
- Types.Where(t => typeof(TType).IsAssignableFrom(t));
+ var returnTypes =
+ Types.Where(type.IsAssignableFrom);
if (mode == ScanMode.All)
{
@@ -200,6 +211,28 @@ public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
}
/// <summary>
+ /// Gets all non-Nancy types implementing a particular interface/base class
+ /// </summary>
+ /// <typeparam name="TType">Type to search for</typeparam>
+ /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
+ /// <remarks>Will scan with <see cref="ScanMode.ExcludeNancy"/>.</remarks>
+ public static IEnumerable<Type> TypesOf<TType>()
+ {
+ return TypesOf<TType>(ScanMode.ExcludeNancy);
+ }
+
+ /// <summary>
+ /// Gets all types implementing a particular interface/base class
+ /// </summary>
+ /// <typeparam name="TType">Type to search for</typeparam>
+ /// <param name="mode">A <see cref="ScanMode"/> value to determin which type set to scan in.</param>
+ /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
+ public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
+ {
+ return TypesOf(typeof(TType), mode);
+ }
+
+ /// <summary>
/// Returns the directories containing dll files. It uses the default convention as stated by microsoft.
/// </summary>
/// <see cref="http://msdn.microsoft.com/en-us/library/system.appdomainsetup.privatebinpathprobe.aspx"/>

0 comments on commit 0467152

Please sign in to comment.