// 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 GenreCollectionPluginBase : IModelPlugin, IGenreCollection, 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 GenreCollectionPluginBase(ModelPluginMetadata registration, IGenreCollection inner)
{
Metadata = registration;
Inner = inner;
}
///
public ModelPluginMetadata Metadata { get; }
///
public IGenreCollection Inner { get; set; }
///
public event EventHandler? SourcesChanged
{
add => Inner.SourcesChanged += value;
remove => Inner.SourcesChanged -= value;
}
///
public virtual int TotalGenreCount => Inner.TotalGenreCount;
///
public IReadOnlyList Sources => Inner.Sources;
///
public virtual event CollectionChangedEventHandler? GenresChanged
{
add => Inner.GenresChanged += value;
remove => Inner.GenresChanged -= value;
}
///
public virtual event EventHandler? GenresCountChanged
{
add => Inner.GenresCountChanged += value;
remove => Inner.GenresCountChanged -= value;
}
///
public virtual Task AddGenreAsync(IGenre gene, int index, CancellationToken cancellationToken = default) => Inner.AddGenreAsync(gene, index, cancellationToken);
///
public virtual ValueTask DisposeAsync() => Inner.DisposeAsync();
///
public virtual bool Equals(ICoreGenreCollection other) => Inner.Equals(other);
///
public virtual IAsyncEnumerable GetGenresAsync(int limit, int offset, CancellationToken cancellationToken = default) => Inner.GetGenresAsync(limit, offset, cancellationToken);
///
public virtual Task IsAddGenreAvailableAsync(int index, CancellationToken cancellationToken = default) => Inner.IsAddGenreAvailableAsync(index, cancellationToken);
///
public virtual Task IsRemoveGenreAvailableAsync(int index, CancellationToken cancellationToken = default) => Inner.IsRemoveGenreAvailableAsync(index, cancellationToken);
///
public virtual Task RemoveGenreAsync(int index, CancellationToken cancellationToken = default) => Inner.RemoveGenreAsync(index, cancellationToken);
}
}