diff --git a/.travis.yml b/.travis.yml index e217066..39ecf02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ env: global: - - PACKAGE_VERSION="1.2.2" + - PACKAGE_VERSION="1.2.3" - PACKAGE_ICON="https://www.enbiso.com/logo.svg" - PACKAGE_PROJECT="https://nlib.enbiso.com" - PACKAGE_REPO="https://github.com/enbiso/Enbiso.NLib" diff --git a/Enbiso.NLib.DependencyInjection/ServiceExtensions.cs b/Enbiso.NLib.DependencyInjection/ServiceExtensions.cs index aa335f7..db320b0 100644 --- a/Enbiso.NLib.DependencyInjection/ServiceExtensions.cs +++ b/Enbiso.NLib.DependencyInjection/ServiceExtensions.cs @@ -8,6 +8,9 @@ namespace Enbiso.NLib.DependencyInjection { public static class ServiceExtensions { + public static IServiceCollection AddServices(this IServiceCollection services, params Type[] typeReferences) + => services.AddServices(typeReferences.Select(t => t.Assembly).ToArray()); + public static IServiceCollection AddServices(this IServiceCollection services, params Assembly[] assemblies) { assemblies.ToList().ForEach(services.AddServicesForAssembly); @@ -16,7 +19,7 @@ public static IServiceCollection AddServices(this IServiceCollection services, p public static IServiceCollection AddServices(this IServiceCollection services) { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies().Select(Assembly.Load).ToArray(); return services.AddServices(assemblies); } @@ -28,7 +31,7 @@ private static void AddServicesForAssembly(this IServiceCollection services, Ass if (service == null) continue; // Get defined interfaces var interfaces = service.ServiceTypes.ToList(); - // If not specificed add implemented interfaces + // If not specified add implemented interfaces if (!interfaces.Any()) interfaces.AddRange(type.GetInterfaces()); // If not then self bind if (!interfaces.Any()) interfaces.Add(type);