Container traits to extensions

This commit is contained in:
2023-08-03 10:48:39 +02:00
parent 86cffa6aa4
commit 558a0a08bb
32 changed files with 258 additions and 158 deletions

View File

@@ -1,6 +0,0 @@
namespace FileTime.Core.Models.ContainerTraits;
public interface IEscHandlerContainer
{
Task<ContainerEscapeResult> HandleEsc();
}

View File

@@ -1,8 +0,0 @@
using DeclarativeProperty;
namespace FileTime.Core.Models.ContainerTraits;
public interface IStatusProviderContainer
{
IDeclarativeProperty<string> Status { get; }
}

View File

@@ -6,20 +6,12 @@ namespace FileTime.Core.Models;
public class ExtensionCollection : IEnumerable<object>
{
private readonly List<object> _extensions = new();
private readonly HashSet<object> _extensions = new();
public ExtensionCollection()
{
}
public ExtensionCollection(IEnumerable<object> objects)
{
foreach (var obj in objects)
{
AddSafe(obj);
}
}
private void AddSafe(object obj)
{
var objType = obj.GetType();
@@ -35,12 +27,7 @@ public class ExtensionCollection : IEnumerable<object>
AddSafe(obj);
}
public void Remove<T>()
{
_extensions.RemoveAll(i => i is T);
}
public ReadOnlyExtensionCollection AsReadOnly() => new ReadOnlyExtensionCollection(this);
public ReadOnlyExtensionCollection AsReadOnly() => new(this);
public IEnumerator<object> GetEnumerator() => _extensions.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => _extensions.GetEnumerator();

View File

@@ -0,0 +1,12 @@
namespace FileTime.Core.Models.Extensions;
public class EscHandlerContainerExtension
{
private readonly Func<Task<ContainerEscapeResult>> _handleEsc;
public EscHandlerContainerExtension(Func<Task<ContainerEscapeResult>> handleEsc)
{
_handleEsc = handleEsc;
}
public async Task<ContainerEscapeResult> HandleEsc() => await _handleEsc();
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.Core.Models.Extensions;
public class NonRestorableContainerExtension
{
}

View File

@@ -0,0 +1,11 @@
namespace FileTime.Core.Models.Extensions;
public class RealContainerProviderExtension
{
public RealContainerProviderExtension(Func<AbsolutePath> realContainer)
{
RealContainer = realContainer;
}
public Func<AbsolutePath> RealContainer { get; }
}

View File

@@ -0,0 +1,13 @@
using DeclarativeProperty;
namespace FileTime.Core.Models.Extensions;
public class StatusProviderContainerExtension
{
public StatusProviderContainerExtension(Func<IDeclarativeProperty<string>> getStatusProperty)
{
GetStatusProperty = getStatusProperty;
}
public Func<IDeclarativeProperty<string>> GetStatusProperty { get; }
}

View File

@@ -4,10 +4,10 @@ namespace FileTime.Core.Models;
public class TabLocationChanged : EventArgs
{
public FullName Location { get; }
public IContainer Location { get; }
public ITab Tab { get; }
public TabLocationChanged(FullName location, ITab tab)
public TabLocationChanged(IContainer location, ITab tab)
{
Location = location;
Tab = tab;

View File

@@ -5,5 +5,5 @@ namespace FileTime.Core.Services;
public interface ITabEvents
{
event EventHandler<TabLocationChanged> LocationChanged;
void OnLocationChanged(ITab tab, FullName location);
void OnLocationChanged(ITab tab, IContainer location);
}