using Hotline.Share.Enums.Settings;
using XF.Domain.Dependency;

namespace Hotline.Settings.TimeLimitDomain.ExpireTimeSupplier;
public class ExpireTimeFactory : IScopeDependency
{
    private readonly IEnumerable<IExpireTimeSupplier> _expireTimeSuppliers;

    public ExpireTimeFactory(IEnumerable<IExpireTimeSupplier> expireTimeSuppliers)
    {
        _expireTimeSuppliers = expireTimeSuppliers;
    }

    public IExpireTimeSupplier GetSupplier(ETimeType timeType)
        => _expireTimeSuppliers
        .FirstOrDefault(supplier => supplier.GetType().Name == timeType.ToString() + "Supplier")
        ?? _expireTimeSuppliers.First();
}
