// 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 System.Collections.Generic;
using System.Linq;
using StrixMusic.Sdk.AdapterModels;
using StrixMusic.Sdk.AppModels;
using StrixMusic.Sdk.CoreModels;
using StrixMusic.Sdk.Plugins.Model;
namespace StrixMusic.Sdk.PluginModels;
///
/// Wraps an instance of with the provided plugins.
///
public class RecentlyPlayedPluginWrapper : PlayableCollectionGroupPluginWrapperBase, IRecentlyPlayed, IPluginWrapper
{
private readonly IRecentlyPlayed _recentlyPlayed;
///
/// Initializes a new instance of the class.
///
/// An existing instance to wrap around and provide plugins on top of.
/// The plugins to import and apply to everything returned from this wrapper.
internal RecentlyPlayedPluginWrapper(IRecentlyPlayed recentlyPlayed, params SdkModelPlugin[] plugins)
: base(GlobalModelPluginConnector.Create(plugins.Aggregate((x, y) =>
{
x.Import(y);
return x;
})).RecentlyPlayed.Execute(recentlyPlayed), plugins)
{
foreach (var plugin in plugins)
ActivePlugins.Import(plugin);
ActivePlugins = GlobalModelPluginConnector.Create(ActivePlugins);
_recentlyPlayed = ActivePlugins.RecentlyPlayed.Execute(recentlyPlayed);
}
///
public SdkModelPlugin ActivePlugins { get; } = new(PluginModelWrapperInfo.Metadata);
///
public IReadOnlyList Sources => ((IMerged)_recentlyPlayed).Sources;
///
public bool Equals(ICoreRecentlyPlayed other) => _recentlyPlayed.Equals(other);
}