Container traits to extensions
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
namespace FileTime.Core.Models.ContainerTraits;
|
||||
|
||||
public interface IEscHandlerContainer
|
||||
{
|
||||
Task<ContainerEscapeResult> HandleEsc();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using DeclarativeProperty;
|
||||
|
||||
namespace FileTime.Core.Models.ContainerTraits;
|
||||
|
||||
public interface IStatusProviderContainer
|
||||
{
|
||||
IDeclarativeProperty<string> Status { get; }
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FileTime.Core.Models.Extensions;
|
||||
|
||||
public class NonRestorableContainerExtension
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace FileTime.Core.Models.Extensions;
|
||||
|
||||
public class RealContainerProviderExtension
|
||||
{
|
||||
public RealContainerProviderExtension(Func<AbsolutePath> realContainer)
|
||||
{
|
||||
RealContainer = realContainer;
|
||||
}
|
||||
|
||||
public Func<AbsolutePath> RealContainer { get; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
||||
{
|
||||
var elapsed = DateTime.Now - start;
|
||||
|
||||
var size = new ByteSize(total / elapsed.TotalSeconds);
|
||||
var size = ByteSize.FromBytes(total / elapsed.TotalSeconds);
|
||||
return Task.FromResult(size + "/s");
|
||||
});
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class Tab : ITab
|
||||
|
||||
if (newLocation.FullName != null)
|
||||
{
|
||||
_tabEvents.OnLocationChanged(this, newLocation.FullName);
|
||||
_tabEvents.OnLocationChanged(this, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ public class Tab : ITab
|
||||
|
||||
if (newLocation.FullName != null)
|
||||
{
|
||||
_tabEvents.OnLocationChanged(this, newLocation.FullName);
|
||||
_tabEvents.OnLocationChanged(this, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ namespace FileTime.Core.Services;
|
||||
|
||||
public class TabEvents : ITabEvents
|
||||
{
|
||||
public event EventHandler<TabLocationChanged> LocationChanged;
|
||||
public event EventHandler<TabLocationChanged>? LocationChanged;
|
||||
|
||||
public void OnLocationChanged(ITab tab, FullName location)
|
||||
{
|
||||
LocationChanged?.Invoke(this, new TabLocationChanged(location, tab));
|
||||
}
|
||||
public void OnLocationChanged(ITab tab, IContainer location)
|
||||
=> LocationChanged?.Invoke(this, new TabLocationChanged(location, tab));
|
||||
}
|
||||
Reference in New Issue
Block a user