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