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