using System.Reactive.Linq; using System.Reactive.Subjects; using FileTime.Core.Enums; using FileTime.Core.Models; namespace FileTime.Core.Services { public abstract class ContentProviderBase : IContentProvider { protected BehaviorSubject> Items { get; } = new BehaviorSubject>(new List()); IObservable> IContainer.Items => Items; public string Name { get; } public string DisplayName { get; } public FullName? FullName => null; public NativePath? NativePath => null; public bool IsHidden => false; public bool IsExists => true; public SupportsDelete CanDelete => SupportsDelete.False; public bool CanRename => false; public IContentProvider Provider => this; public FullName? Parent => null; public DateTime? CreatedAt => null; public string? Attributes => null; protected BehaviorSubject IsLoading { get; } = new(false); IObservable IContainer.IsLoading => IsLoading.AsObservable(); protected ContentProviderBase(string name) { DisplayName = Name = name; } public virtual Task OnEnter() => Task.CompletedTask; public virtual async Task GetItemByFullNameAsync(FullName fullName) => await GetItemByNativePathAsync(GetNativePath(fullName)); public abstract Task GetItemByNativePathAsync(NativePath nativePath); public abstract Task> GetItemsByContainerAsync(FullName fullName); public abstract NativePath GetNativePath(FullName fullName); } }