public void Load_configuration_from_file() { var config = ShelfConfiguration.GetConfig(); Assert.That(config, Is.Not.Null); config.BootstrapperType.ShouldEqual(typeof(TestAppDomainBootsrapper)); }
public static Type FindBootstrapperImplementationType(Type bootstrapper) { if (bootstrapper != null) { if (bootstrapper.GetInterfaces().Where(IsBootstrapperType).Count() > 0) { return(bootstrapper); } throw new InvalidOperationException( "Bootstrapper type, '{0}', is not a subclass of Bootstrapper.".FormatWith(bootstrapper.GetType().Name)); } // check configuration first ShelfConfiguration config = ShelfConfiguration.GetConfig(); if (config != null) { return(config.BootstrapperType); } IEnumerable <Type> possibleTypes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(x => x.GetTypes()) .Where(x => x.IsInterface == false) .Where(t => t.GetInterfaces().Any(IsBootstrapperType)); if (possibleTypes.Count() > 1) { throw new InvalidOperationException("Unable to identify the bootstrapper, more than one found."); } if (possibleTypes.Count() == 0) { throw new InvalidOperationException("The bootstrapper was not found."); } return(possibleTypes.Single()); }