Zxd.Core/code/Zxd.Domain/SystemConfigDomain.cs

31 lines
853 B
C#

using Microsoft.Extensions.Options;
namespace Zxd.Domain
{
public class SystemConfigDomain : ISystemConfigDomain
{
private readonly IOptionsSnapshot<SystemConfig> _systemConfig;
public SystemConfigDomain(IOptionsSnapshot<SystemConfig> systemConfig)
{
_systemConfig = systemConfig;
}
/// <summary>
/// 获取配置文件
/// </summary>
/// <returns></returns>
public SystemConfig GetSystemConfig()
{
return _systemConfig.Value;
}
public ClientKey GetClientKey(string clientId)
{
var client = _systemConfig.Value.ClientKey.FirstOrDefault(x => x.Id == clientId);
if (client == null)
throw new Exception("非法客户端访问");
return client;
}
}
}