Answers for "Options Pattern how to use"

C#
0

Options Pattern how to use

// AppSettingsController.cs
[Route("appsettings")]
public class AppSettingsController : Controller
{
    ...
    protected readonly IOptions<RoundTheCodeSync> _roundTheCodeSyncOptions;
 
    public AppSettingsController(..., IOptions<RoundTheCodeSync> roundTheCodeSyncOptions)
    {
        ...
        _roundTheCodeSyncOptions = roundTheCodeSyncOptions;
    }
 
    ...
 
    [Route("second-way")]
    public IActionResult SecondWay()
    {
        return Content(_roundTheCodeSyncOptions.Value.Title, "text/plain");
    }
}
Posted by: Guest on September-30-2021

Code answers related to "Options Pattern how to use"

C# Answers by Framework

Browse Popular Code Answers by Language