// Copyright (c) Arlo Godfrey. All Rights Reserved.
// Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms.
// See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information.
using StrixMusic.Sdk.AppModels;
using StrixMusic.Sdk.Plugins.Model;
namespace StrixMusic.Sdk.Plugins.PopulateEmptyNames;
///
/// A plugin that intercepts null or whitespaces names on playlists and uses a value provided to the plugin instead.
///
internal class PopulateEmptyPlaylistNamePlugin : PlaylistPluginBase
{
private readonly string _playlistName;
///
/// Initializes a new instance of the class.
///
/// Contains metadata for a plugin. Used to identify a plugin before instantiation.
/// An implementation which member access is delegated to, unless the member is overridden in a derived class which changes the behavior.
/// The name to use instead when the existing name is empty.
public PopulateEmptyPlaylistNamePlugin(ModelPluginMetadata metadata, IPlaylist inner, string playlistName)
: base(metadata, inner)
{
_playlistName = playlistName;
}
///
public override string Name => string.IsNullOrWhiteSpace(base.Name) ? _playlistName : base.Name;
}