Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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");
    }
}
Source by www.roundthecode.com #
 
PREVIOUS NEXT
Tagged: #Options #Pattern
ADD COMMENT
Topic
Name
6+7 =