// 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; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using OwlCore.ComponentModel; using OwlCore.Events; using StrixMusic.Sdk.AppModels; using StrixMusic.Sdk.CoreModels; namespace StrixMusic.Sdk.Plugins.Model { /// /// An implementation of which delegates all member access to the implementation, /// unless the member is overridden in a derived class which changes the behavior. /// public class ImageCollectionPluginBase : IModelPlugin, IImageCollection, IDelegatable { /// /// Creates a new instance of . /// /// Metadata about the plugin which was provided during registration. /// The implementation which all member access is delegated to, unless the member is overridden in a derived class which changes the behavior. internal protected ImageCollectionPluginBase(ModelPluginMetadata registration, IImageCollection inner) { Metadata = registration; Inner = inner; } /// public ModelPluginMetadata Metadata { get; } /// public IImageCollection Inner { get; set; } /// public event EventHandler? SourcesChanged { add => Inner.SourcesChanged += value; remove => Inner.SourcesChanged -= value; } /// public virtual int TotalImageCount => Inner.TotalImageCount; /// public IReadOnlyList Sources => Inner.Sources; /// public virtual event CollectionChangedEventHandler? ImagesChanged { add => Inner.ImagesChanged += value; remove => Inner.ImagesChanged -= value; } /// public virtual event EventHandler? ImagesCountChanged { add => Inner.ImagesCountChanged += value; remove => Inner.ImagesCountChanged -= value; } /// public virtual Task AddImageAsync(IImage image, int index, CancellationToken cancellationToken = default) => Inner.AddImageAsync(image, index, cancellationToken); /// public virtual ValueTask DisposeAsync() => Inner.DisposeAsync(); /// public virtual bool Equals(ICoreImageCollection other) => Inner.Equals(other); /// public virtual IAsyncEnumerable GetImagesAsync(int limit, int offset, CancellationToken cancellationToken = default) => Inner.GetImagesAsync(limit, offset, cancellationToken); /// public virtual Task IsAddImageAvailableAsync(int index, CancellationToken cancellationToken = default) => Inner.IsAddImageAvailableAsync(index, cancellationToken); /// public virtual Task IsRemoveImageAvailableAsync(int index, CancellationToken cancellationToken = default) => Inner.IsRemoveImageAvailableAsync(index, cancellationToken); /// public virtual Task RemoveImageAsync(int index, CancellationToken cancellationToken = default) => Inner.RemoveImageAsync(index, cancellationToken); } }