27 lines
1.2 KiB
C#
27 lines
1.2 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace Flawless.Server.Services;
|
|
|
|
public class SettingFacade
|
|
{
|
|
private readonly IConfiguration _config;
|
|
|
|
public SettingFacade(IConfiguration config) => _config = config;
|
|
|
|
// 系统基础配置
|
|
public string? ServerName => _config[SettingKey.ServerName] ?? null;
|
|
public bool AllowPublicRegistration => _config.GetValue(SettingKey.AllowPublicRegistration, false);
|
|
|
|
// Webhook配置
|
|
public bool UseWebHook => _config.GetValue(SettingKey.UseWebHook, false);
|
|
public int WebhookTimeout => _config.GetValue(SettingKey.WebhookTimeout, 5000);
|
|
public int WebhookMaxRetries => _config.GetValue(SettingKey.WebhookMaxRetries, 3);
|
|
|
|
// SMTP配置
|
|
public bool UseSmtp => _config.GetValue(SettingKey.UseSmtp, false);
|
|
public string SmtpHost => _config[SettingKey.SmtpHost]?.Trim() ?? "localhost";
|
|
public int SmtpPort => _config.GetValue(SettingKey.SmtpPort, 587);
|
|
public bool SmtpUseSsl => _config.GetValue(SettingKey.SmtpUseSsl, false);
|
|
public string SmtpUsername => _config[SettingKey.SmtpUsername]?.Trim() ?? String.Empty;
|
|
public string SmtpPassword => _config[SettingKey.SmtpPassword]?.Trim()?? String.Empty;
|
|
} |