// 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 SearchHistoryPluginWrapper : PlayableCollectionGroupPluginWrapperBase, ISearchHistory, IPluginWrapper
{
private readonly ISearchHistory _searchHistory;
///
/// 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 SearchHistoryPluginWrapper(ISearchHistory searchHistory, params SdkModelPlugin[] plugins)
: base(GlobalModelPluginConnector.Create(plugins.Aggregate((x, y) =>
{
x.Import(y);
return x;
})).SearchHistory.Execute(searchHistory), plugins)
{
foreach (var plugin in plugins)
ActivePlugins.Import(plugin);
ActivePlugins = GlobalModelPluginConnector.Create(ActivePlugins);
_searchHistory = ActivePlugins.SearchHistory.Execute(searchHistory);
}
///
public SdkModelPlugin ActivePlugins { get; } = new(PluginModelWrapperInfo.Metadata);
///
public IReadOnlyList Sources => ((IMerged)_searchHistory).Sources;
///
public bool Equals(ICoreSearchHistory other) => _searchHistory.Equals(other);
}