Skip to content
This repository

Added TypesOf overloads #946

Merged
merged 1 commit into from over 1 year ago

2 participants

Andreas Håkansson Steven Robbins
Andreas Håkansson

No description provided.

Steven Robbins grumpydev merged commit 0467152 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 03, 2013
Andreas Håkansson thecodejunkie Added TypesOf overloads 4fedaca
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 37 additions and 4 deletions. Show diff stats Hide diff stats

  1. +37 4 src/Nancy/Bootstrapper/AppDomainAssemblyTypeScanner.cs
41 src/Nancy/Bootstrapper/AppDomainAssemblyTypeScanner.cs
@@ -179,15 +179,26 @@ public static IEnumerable<Type> TypesOf<TType>(bool excludeInternalTypes = false
179 179 }
180 180
181 181 /// <summary>
  182 + /// Gets all non-Nancy types implementing a particular interface/base class
  183 + /// </summary>
  184 + /// <param name="type">Type to search for</param>
  185 + /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
  186 + /// <remarks>Will scan with <see cref="ScanMode.ExcludeNancy"/>.</remarks>
  187 + public static IEnumerable<Type> TypesOf(Type type)
  188 + {
  189 + return TypesOf(type, ScanMode.ExcludeNancy);
  190 + }
  191 +
  192 + /// <summary>
182 193 /// Gets all types implementing a particular interface/base class
183 194 /// </summary>
184   - /// <typeparam name="TType">Type to search for</typeparam>
  195 + /// <param name="type">Type to search for</param>
185 196 /// <param name="mode">A <see cref="ScanMode"/> value to determin which type set to scan in.</param>
186 197 /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
187   - public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
  198 + public static IEnumerable<Type> TypesOf(Type type, ScanMode mode)
188 199 {
189   - var returnTypes =
190   - Types.Where(t => typeof(TType).IsAssignableFrom(t));
  200 + var returnTypes =
  201 + Types.Where(type.IsAssignableFrom);
191 202
192 203 if (mode == ScanMode.All)
193 204 {
@@ -200,6 +211,28 @@ public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
200 211 }
201 212
202 213 /// <summary>
  214 + /// Gets all non-Nancy types implementing a particular interface/base class
  215 + /// </summary>
  216 + /// <typeparam name="TType">Type to search for</typeparam>
  217 + /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
  218 + /// <remarks>Will scan with <see cref="ScanMode.ExcludeNancy"/>.</remarks>
  219 + public static IEnumerable<Type> TypesOf<TType>()
  220 + {
  221 + return TypesOf<TType>(ScanMode.ExcludeNancy);
  222 + }
  223 +
  224 + /// <summary>
  225 + /// Gets all types implementing a particular interface/base class
  226 + /// </summary>
  227 + /// <typeparam name="TType">Type to search for</typeparam>
  228 + /// <param name="mode">A <see cref="ScanMode"/> value to determin which type set to scan in.</param>
  229 + /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns>
  230 + public static IEnumerable<Type> TypesOf<TType>(ScanMode mode)
  231 + {
  232 + return TypesOf(typeof(TType), mode);
  233 + }
  234 +
  235 + /// <summary>
203 236 /// Returns the directories containing dll files. It uses the default convention as stated by microsoft.
204 237 /// </summary>
205 238 /// <see cref="http://msdn.microsoft.com/en-us/library/system.appdomainsetup.privatebinpathprobe.aspx"/>

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.