-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added scanner to convention builder. Added overloads to convention bu…
…ilder similar to scanner. IConvenctionContainer can now be used as a 'root' interface for adding many conventions on a common builder (Host, WebHost, etc) +semver:major
- Loading branch information
1 parent
7bd6c46
commit 7bf024d
Showing
5 changed files
with
211 additions
and
33 deletions.
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
2 changes: 1 addition & 1 deletion
2
...ractions/Scanners/IConventionContainer.cs → ...ions.Abstractions/IConventionContainer.cs
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
81 changes: 81 additions & 0 deletions
81
src/Conventions.Abstractions/Scanners/ConventionScannerExtensions.cs
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,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace Rocket.Surgery.Conventions.Scanners | ||
{ | ||
/// <summary> | ||
/// Class ConventionScannerExtensions. | ||
/// </summary> | ||
/// TODO Edit XML Comment Template for ConventionScannerExtensions | ||
public static class ConventionScannerExtensions | ||
{ | ||
/// <summary> | ||
/// Adds an exception to the scanner to exclude a specific type | ||
/// </summary> | ||
/// <typeparam name="T">The scanner</typeparam> | ||
/// <param name="scanner">The scanner.</param> | ||
/// <param name="types">The additional types to exclude.</param> | ||
/// <returns>The scanner</returns> | ||
public static T ExceptConvention<T>(this T scanner, params Type[] types) | ||
where T : IConventionScanner | ||
{ | ||
foreach (var type in types) | ||
{ | ||
scanner.ExceptConvention(type); | ||
} | ||
return scanner; | ||
} | ||
|
||
/// <summary> | ||
/// Adds an exception to the scanner to exclude a specific type | ||
/// </summary> | ||
/// <typeparam name="T">The scanner</typeparam> | ||
/// <param name="scanner">The scanner.</param> | ||
/// <param name="types">The convention types to exclude.</param> | ||
/// <returns>The scanner</returns> | ||
public static T ExceptConvention<T>(this T scanner, IEnumerable<Type> types) | ||
where T : IConventionScanner | ||
{ | ||
foreach (var type in types) | ||
{ | ||
scanner.ExceptConvention(type); | ||
} | ||
return scanner; | ||
} | ||
|
||
/// <summary> | ||
/// Adds an exception to the scanner to exclude a specific type | ||
/// </summary> | ||
/// <typeparam name="T">The scanner</typeparam> | ||
/// <param name="scanner">The scanner.</param> | ||
/// <param name="assemblies">The additional types to exclude.</param> | ||
/// <returns>The scanner</returns> | ||
public static T ExceptConvention<T>(this T scanner, params Assembly[] assemblies) | ||
where T : IConventionScanner | ||
{ | ||
foreach (var type in assemblies) | ||
{ | ||
scanner.ExceptConvention(type); | ||
} | ||
return scanner; | ||
} | ||
|
||
/// <summary> | ||
/// Adds an exception to the scanner to exclude a specific type | ||
/// </summary> | ||
/// <typeparam name="T">The scanner</typeparam> | ||
/// <param name="scanner">The scanner.</param> | ||
/// <param name="assemblies">The convention types to exclude.</param> | ||
/// <returns>The scanner</returns> | ||
public static T ExceptConvention<T>(this T scanner, IEnumerable<Assembly> assemblies) | ||
where T : IConventionScanner | ||
{ | ||
foreach (var type in assemblies) | ||
{ | ||
scanner.ExceptConvention(type); | ||
} | ||
return scanner; | ||
} | ||
} | ||
} |
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