/// <summary> /// Auto scan and register implementation of service follow /// <see cref="Elect.DI.Attributes" /> life time setup. /// </summary> public static IServiceCollection AddElectDI(this IServiceCollection services, [NotNull] Action <ElectDIOptions> configure) { services.Configure(configure); ElectDIOptions options = configure.GetValue(); var scanner = new Scanner(); foreach (var assemblyName in options.ListAssemblyName) { var rootAssemblyName = assemblyName.Split('.').FirstOrDefault(); foreach (var assemblyFolderPath in options.ListAssemblyFolderPath) { // dll files scanner.RegisterAssemblies(services, assemblyFolderPath, $"{rootAssemblyName}.dll"); // dll prefix files scanner.RegisterAssemblies(services, assemblyFolderPath, $"{rootAssemblyName}.*.dll"); } } return(services); }
/// <summary> /// Auto scan and register implementation of service follow /// <see cref="Elect.DI.Attributes" /> life time setup. /// </summary> public static IServiceCollection AddElectDI(this IServiceCollection services, [NotNull] ElectDIOptions configure) { return(services.AddElectDI(_ => { _.ListAssemblyFolderPath = configure.ListAssemblyFolderPath; _.ListAssemblyName = configure.ListAssemblyName; })); }
/// <summary> /// Auto scan and register implementation of service follow /// <see cref="Elect.DI.Attributes" /> life time setup. /// </summary> public static IServiceCollection AddElectDI(this IServiceCollection services, [NotNull] Action <ElectDIOptions> configure) { services.Configure(configure); ElectDIOptions options = configure.GetValue(); var scanner = new Scanner(); foreach (var assemblyName in options.ListAssemblyName) { foreach (var assemblyFolderPath in options.ListAssemblyFolderPath) { scanner.RegisterAssemblies(services, assemblyFolderPath, $"{assemblyName}.dll"); scanner.RegisterAssemblies(services, assemblyFolderPath, $"{assemblyName}.*.dll"); } } return(services); }