Created
September 20, 2012 13:09
-
-
Save rarous/3755795 to your computer and use it in GitHub Desktop.
Extension for safe registration of Facility
This file contains hidden or 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
| using System.Linq; | |
| using Castle.MicroKernel; | |
| using Castle.Windsor; | |
| public static class WindsorExtensions | |
| { | |
| public static IWindsorContainer AddFacilitySafe<TFacility>(this IWindsorContainer container) | |
| where TFacility : class, IFacility, new() | |
| { | |
| if (container.Kernel.GetFacilities().Any(x => x.GetType() == typeof(TFacility))) | |
| return container; | |
| return container.AddFacility<TFacility>(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment