Table of Contents

Class ApqCfgOptionsMonitor<TOptions>

Namespace
Apq.Cfg.DependencyInjection
Assembly
Apq.Cfg.dll

支持配置变更自动更新的 IOptionsMonitor 实现

public sealed class ApqCfgOptionsMonitor<TOptions> : IOptionsMonitor<TOptions>, IDisposable where TOptions : class, new()

Type Parameters

TOptions

配置选项类型

Inheritance
ApqCfgOptionsMonitor<TOptions>
Implements
IOptionsMonitor<TOptions>
Inherited Members

Constructors

ApqCfgOptionsMonitor(ICfgRoot, string)

创建 ApqCfgOptionsMonitor 实例

public ApqCfgOptionsMonitor(ICfgRoot cfgRoot, string sectionKey)

Parameters

cfgRoot ICfgRoot

配置根

sectionKey string

配置节键名

Properties

CurrentValue

Returns the current TOptions instance with the DefaultName.

public TOptions CurrentValue { get; }

Property Value

TOptions

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Get(string?)

Returns a configured TOptions instance with the given name.

public TOptions Get(string? name)

Parameters

name string

The name of the TOptions instance, if a null DefaultName is used.

Returns

TOptions

The TOptions instance that matches the given name.

GetChangeToken()

获取变更令牌

public IChangeToken GetChangeToken()

Returns

IChangeToken

OnChange(Action<TOptions, string?>)

Registers a listener to be called whenever a named TOptions changes.

public IDisposable? OnChange(Action<TOptions, string?> listener)

Parameters

listener Action<TOptions, string>

The action to be invoked when TOptions has changed.

Returns

IDisposable

An IDisposable which should be disposed to stop listening for changes.