using System.Threading.Tasks; namespace ZB.MOM.WW.CBDDC.Core.Network; /// /// Provides peer node configuration from an in-memory static source. /// public class StaticPeerNodeConfigurationProvider : IPeerNodeConfigurationProvider { private PeerNodeConfiguration _configuration = new(); /// /// Gets or sets the current peer node configuration. /// public PeerNodeConfiguration Configuration { get => _configuration; set { if (_configuration != value) { _configuration = value; OnConfigurationChanged(_configuration); } } } /// /// Initializes a new instance of the class. /// /// The initial peer node configuration. public StaticPeerNodeConfigurationProvider(PeerNodeConfiguration configuration) { Configuration = configuration; } /// /// Occurs when the peer node configuration changes. /// public event PeerNodeConfigurationChangedEventHandler? ConfigurationChanged; /// /// Gets the current peer node configuration. /// /// A task whose result is the current configuration. public Task GetConfiguration() { return Task.FromResult(Configuration); } /// /// Raises the event. /// /// The new peer node configuration. protected virtual void OnConfigurationChanged(PeerNodeConfiguration newConfig) { ConfigurationChanged?.Invoke(this, newConfig); } }