private static INightLibBuilder RegisterHandlers(Type handlerType, ServiceLifetime lifetime, INightLibBuilder builder, Assembly[] assemblies) { QueryType.InAssemblies(assemblies) .AreNotAbstract() .InheritFromInterface(handlerType) .ForEach(implementationType => { var argTypes = MainUtil.GetGenericArgumentsFromOpenGenericInterface(implementationType, handlerType); var serviceType = handlerType.MakeGenericType(argTypes); builder.Services.Add(new ServiceDescriptor(serviceType, implementationType, lifetime)); }); return(builder); }