Esempio n. 1
0
 public TodoController(TodoContext todoContext,
                       ILogger <TodoController> logger,
                       IOperationTransien operationTransien,
                       IOperationScope operationScope,
                       IOperationSingleton operationSingleton,
                       IOptionsMonitor <PositionOptions> optionsMonitor,
                       IOptionsSnapshot <TopItemSettings> namedOptionsAccessor,
                       IOptions <MyConfigOptions> options,
                       IHttpClientFactory httpClientFactory,
                       IMemoryCache cache,
                       IDistributedCache distributedCache)
 {
     _todoContext        = todoContext;
     _logger             = logger;
     _operationTransien  = operationTransien;
     _operationScope     = operationScope;
     _operationSingleton = operationSingleton;
     _positionOptions    = optionsMonitor.CurrentValue;
     _monthTopItem       = namedOptionsAccessor.Get(TopItemSettings.Month);
     _yearTopItem        = namedOptionsAccessor.Get(TopItemSettings.Year);
     _myConfigOptions    = options.Value;
     _clientFactory      = httpClientFactory;
     _cache            = cache;
     _distributedCache = distributedCache;
 }
        public ContentResult OnGet()
        {
            var myOpts = new TopItemSettings();

            Configuration.GetSection("TopItem:Month").Bind(myOpts);

            return(Content($"TopItem:Month:Model: { myOpts.Model} \n" +
                           $"TopItem:Month.Name :{ myOpts.Name}"));
        }
Esempio n. 3
0
 public OptionsBindController(IConfiguration configuration,
                              IOptionsMonitor <PositionOptions> options,
                              IOptionsSnapshot <TopItemSettings> optionsSnapshot,
                              ILogger <OptionsBindController> logger
                              )
 {
     Configuration = configuration;
     _options      = options.CurrentValue;
     _monthTopItem = optionsSnapshot.Get(TopItemSettings.Month);
     _yearTopItem  = optionsSnapshot.Get(TopItemSettings.Year);
     _logger       = logger;
 }
Esempio n. 4
0
 public TestNOModel(IOptionsSnapshot <TopItemSettings> namedOptionsAccessor)
 {
     _monthTopItem = namedOptionsAccessor.Get(TopItemSettings.Month);
     _yearTopItem  = namedOptionsAccessor.Get(TopItemSettings.Year);
 }
 public NamedOptionsModel(IOptionsSnapshot <TopItemSettings> optionDelegate)
 {
     _monthTopItem = optionDelegate.Get(TopItemSettings.Year);
     _yearTopItem  = optionDelegate.Get(TopItemSettings.Month);
 }