public static IServiceCollection AddDefaults(this IServiceCollection services, IConfiguration configuration) { var protocolSetting = new ProtocolSetting(); var protocolSection = configuration.GetSection("ProtocolSetting"); if (protocolSection != null) { protocolSection.Bind(protocolSetting); } services.Configure <ProtocolSetting>(protocolSection); var smtpSetting = new SMTPSetting(); var smtpSection = configuration.GetSection("SmtpSetting"); if (smtpSection != null) { smtpSection.Bind(smtpSetting); } services.Configure <SMTPSetting>(smtpSection); var ldapSetting = new LDAPSetting(); var ldapSection = configuration.GetSection("LdapSetting"); if (ldapSection != null) { ldapSection.Bind(ldapSetting); } services.Configure <SMTPSetting>(ldapSection); services.AddControllers(options => { options.CacheProfiles.Add("Never", new CacheProfile() { Location = ResponseCacheLocation.None, NoStore = true, Duration = 0 }); options.SuppressOutputFormatterBuffering = true; options.OutputFormatters.Insert(0, new DBItemOutputFormatter()); }).AddJsonOptions(options => { options.JsonSerializerOptions.InitDefaults(); }); foreach (var validator in services.Where(s => s.ServiceType == typeof(IObjectModelValidator)).ToList()) { services.Remove(validator); } services.AddSingleton <IObjectModelValidator>(new DBItemValidator()); return(services); }
public LDAPSetting() { Current = this; }