/// <summary> /// Create a new <see cref="SharpSettingsMongoSettingsWatcher{TSettingsObject}"/> /// </summary> /// <param name="logger">A <see cref="ILogger"/> for capturing internal log messages.</param> /// <param name="settingsStore">A <see cref="SharpSettingsMongoDataStore{TSettingsObject}"/> that contains the <see cref="TSettingsObject"/></param> /// <param name="settingsId">The <see cref="string"/> Id of the <see cref="TSettingsObject{string}"/> to monitor.</param> /// <param name="settingsUpdatedCallback">A callback for notifying the creator of this object of updates to the <see cref="TSettingsObject"/></param> /// <param name="forcePolling">A <see cref="bool"/> value indicating if Polling should be used instead of auto-selecting between Polling and ChangeStreams</param> /// <param name="customComparers">A <see cref="IEnumerable{BaseTypeComparer}"/> for determining when the <see cref="TSettingsObject"/> has changed. This is not required if ChangeStreams are used.</param> /// <param name="cts">A <see cref="CancellationTokenSource"/> for shutting down the <see cref="ISettingsWatcher{TId, TSettings}"/> when not using the <see cref="IAsyncDisposable"/> pattern.</param> public SharpSettingsMongoSettingsWatcher(ILogger logger, SharpSettingsMongoDataStore <TSettingsObject> settingsStore, string settingsId, Action <TSettingsObject> settingsUpdatedCallback, bool forcePolling = false, IEnumerable <BaseTypeComparer> customComparers = null, CancellationTokenSource cts = default) { _logger = logger; _cancellationTokenSource = cts ?? new CancellationTokenSource(); _forcePolling = forcePolling; _compareLogic = new CompareLogic(); if (customComparers != null) { _compareLogic.Config.CustomComparers.AddRange(customComparers); } _store = settingsStore; _settingsId = settingsId; _settingsUpdatedCallback = settingsUpdatedCallback; CreateWatcherTask(); }
/// <summary> /// Create a new <see cref="SharpSettingsMongoSettingsWatcher{TSettingsObject}"/> /// </summary> /// <param name="logger">A <see cref="ILogger"/> for capturing internal log messages.</param> /// <param name="settingsStore">A <see cref="SharpSettingsMongoDataStore{TSettingsObject}"/> that contains the <see cref="TSettingsObject"/></param> /// <param name="settings">The <see cref="TSettingsObject"/> to monitor</param> /// <param name="settingsUpdatedCallback">A callback for notifying the creator of this object of updates to the <see cref="TSettingsObject"/></param> /// <param name="forcePolling">A <see cref="bool"/> value indicating if Polling should be used instead of auto-selecting between Polling and ChangeStreams</param> /// <param name="customComparers">A <see cref="IEnumerable{BaseTypeComparer}"/> for determining when the <see cref="TSettingsObject"/> has changed. This is not required if ChangeStreams are used.</param> /// <param name="cts">A <see cref="CancellationTokenSource"/> for shutting down the <see cref="ISettingsWatcher{TId, TSettings}"/> when not using the <see cref="IAsyncDisposable"/> pattern.</param> public SharpSettingsMongoSettingsWatcher(ILogger logger, SharpSettingsMongoDataStore <TSettingsObject> settingsStore, TSettingsObject settings, Action <TSettingsObject> settingsUpdatedCallback, bool forcePolling = false, IEnumerable <BaseTypeComparer> customComparers = null, CancellationTokenSource cts = default) : this(logger, settingsStore, settings.Id, settingsUpdatedCallback, forcePolling, customComparers, cts) { }