示例#1
0
        /// <summary>
        /// Configure services in <see cref="Dnc"/> can be used in AspnetCore and remove AspnetCore default logger providers.
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IWebHostBuilder UseCore(this IWebHostBuilder builder, Action <FrameworkConstruction> configureConstruction = null)
        {
            var construction = Fx.Construct <FrameworkConstruction>();

            configureConstruction?.Invoke(construction);
            builder.ConfigureServices((context, services) =>
            {
                services
                .Where(s => s.ServiceType == typeof(ILoggerProvider))
                .ToList()
                .ForEach(i => services.Remove(i));

                foreach (var service in construction.Services)
                {
                    services.Add(service);
                }
            });
            return(builder);
        }