Make ILibraryChangedNotifier sealed

pull/10592/head
Patrick Barron 1 year ago
parent 8f5f0a0310
commit 7e645dcfc0

@ -25,7 +25,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.EntryPoints namespace Emby.Server.Implementations.EntryPoints
{ {
public class LibraryChangedNotifier : IServerEntryPoint public sealed class LibraryChangedNotifier : IServerEntryPoint
{ {
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IServerConfigurationManager _configurationManager; private readonly IServerConfigurationManager _configurationManager;
@ -405,36 +405,21 @@ namespace Emby.Server.Implementations.EntryPoints
return Array.Empty<T>(); return Array.Empty<T>();
} }
/// <summary> /// <inheritdoc />
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose() public void Dispose()
{ {
Dispose(true); _libraryManager.ItemAdded -= OnLibraryItemAdded;
GC.SuppressFinalize(this); _libraryManager.ItemUpdated -= OnLibraryItemUpdated;
} _libraryManager.ItemRemoved -= OnLibraryItemRemoved;
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
if (dispose)
{
if (LibraryUpdateTimer is not null)
{
LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null;
}
_libraryManager.ItemAdded -= OnLibraryItemAdded; _providerManager.RefreshCompleted -= OnProviderRefreshCompleted;
_libraryManager.ItemUpdated -= OnLibraryItemUpdated; _providerManager.RefreshStarted -= OnProviderRefreshStarted;
_libraryManager.ItemRemoved -= OnLibraryItemRemoved; _providerManager.RefreshProgress -= OnProviderRefreshProgress;
_providerManager.RefreshCompleted -= OnProviderRefreshCompleted; if (LibraryUpdateTimer is not null)
_providerManager.RefreshStarted -= OnProviderRefreshStarted; {
_providerManager.RefreshProgress -= OnProviderRefreshProgress; LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null;
} }
} }
} }

Loading…
Cancel
Save