❗ Overview:
GET: /API/Enums/GetAllByAssembly Returns all enums in entry and referenced assemblies that have EnumAttribute. 😀
❓ How to implement:
We have a based interface called IEnumsProvider in uBeac.Core.Enums:
public interface IEnumsProvider
{
IEnumerable<EnumModel> GetAll();
}
So can have different types of providers for enums!
We currently need an implementation of the IEnumProvider that exposes the enums of an assembly, I call this AssemblyEnumsProvider:
public interface IAssemblyEnumsProvider : IEnumsProvider
{
}
Inside the code you can see the full details.
❓ How to use in end projects:
Just call AddAssemblyEnumsProvider in Program.cs and enjoy :)
builder.Services.AddAssemblyEnumsProvider();
EnumsController is available in uBeac.Core.Web.Common.
public class EnumsController : BaseController
{
private readonly IAssemblyEnumsProvider _assemblyEnums;
public EnumsController(IAssemblyEnumsProvider assemblyEnums)
{
_assemblyEnums = assemblyEnums;
}
[HttpGet]
public IListResult<EnumModel> GetAllByAssembly() => _assemblyEnums.GetAll().ToListResult();
}
❗ Overview: GET: /API/Enums/GetAllByAssembly Returns all enums in entry and referenced assemblies that have EnumAttribute. 😀
❓ How to implement: We have a based interface called IEnumsProvider in uBeac.Core.Enums:
So can have different types of providers for enums! We currently need an implementation of the IEnumProvider that exposes the enums of an assembly, I call this AssemblyEnumsProvider:
Inside the code you can see the full details.
❓ How to use in end projects: Just call AddAssemblyEnumsProvider in Program.cs and enjoy :)
EnumsController is available in uBeac.Core.Web.Common.