public static INightLibBuilder AddDependencies(this INightLibBuilder builder, params Assembly[] assemblies) { QueryType.InAssemblies(assemblies) .AreNotAbstract() .HasAnyAttribute(typeof(SingletonAttribute), typeof(ScopedAttribute), typeof(TransientAttribute)) .ForEach(implementationType => { foreach (var attr in MainUtil.GetAttributes <SingletonAttribute>(implementationType)) { var serviceDescriptor = new ServiceDescriptor(attr.Type, implementationType, ServiceLifetime.Singleton); builder.Services.Add(serviceDescriptor); } foreach (var attr in MainUtil.GetAttributes <ScopedAttribute>(implementationType)) { var serviceDescriptor = new ServiceDescriptor(attr.Type, implementationType, ServiceLifetime.Scoped); builder.Services.Add(serviceDescriptor); } foreach (var attr in MainUtil.GetAttributes <TransientAttribute>(implementationType)) { var serviceDescriptor = new ServiceDescriptor(attr.Type, implementationType, ServiceLifetime.Transient); builder.Services.Add(serviceDescriptor); } }); return(builder); }