TimeTravel
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using AsyncEvent;
|
||||
using FileTime.Core.Interactions;
|
||||
using FileTime.Core.Models;
|
||||
@@ -11,7 +12,7 @@ namespace FileTime.Providers.Smb
|
||||
private readonly IInputInterface _inputInterface;
|
||||
private readonly List<IContainer> _rootContainers;
|
||||
private readonly IReadOnlyList<IContainer> _rootContainersReadOnly;
|
||||
private readonly IReadOnlyList<IItem>? _items;
|
||||
private IReadOnlyList<IItem>? _items;
|
||||
private readonly IReadOnlyList<IElement>? _elements = new List<IElement>().AsReadOnly();
|
||||
|
||||
public string Name { get; } = "smb";
|
||||
@@ -19,14 +20,18 @@ namespace FileTime.Providers.Smb
|
||||
public string? FullName { get; }
|
||||
|
||||
public bool IsHidden => false;
|
||||
public bool IsLoaded => true;
|
||||
|
||||
public IContentProvider Provider => this;
|
||||
public bool CanDelete => false;
|
||||
public bool CanRename => false;
|
||||
|
||||
public AsyncEventHandler Refreshed { get; } = new();
|
||||
|
||||
public SmbContentProvider(IInputInterface inputInterface)
|
||||
{
|
||||
_rootContainers = new List<IContainer>();
|
||||
_items = new List<IItem>();
|
||||
_rootContainersReadOnly = _rootContainers.AsReadOnly();
|
||||
_inputInterface = inputInterface;
|
||||
}
|
||||
@@ -40,6 +45,7 @@ namespace FileTime.Providers.Smb
|
||||
{
|
||||
container = new SmbServer(fullName, this, _inputInterface);
|
||||
_rootContainers.Add(container);
|
||||
_items = _rootContainers.OrderBy(c => c.Name).ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
await Refresh();
|
||||
@@ -78,5 +84,7 @@ namespace FileTime.Providers.Smb
|
||||
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default) => Task.FromResult(_items);
|
||||
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default) => Task.FromResult((IReadOnlyList<IContainer>?)_rootContainersReadOnly);
|
||||
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default) => Task.FromResult(_elements);
|
||||
|
||||
public Task Rename(string newName) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,11 @@ namespace FileTime.Providers.Smb
|
||||
public string? FullName { get; }
|
||||
|
||||
public bool IsHidden => false;
|
||||
public bool CanDelete => true;
|
||||
public bool CanRename => true;
|
||||
|
||||
public IContentProvider Provider { get; }
|
||||
private IContainer _parent;
|
||||
|
||||
public SmbFile(string name, SmbContentProvider provider, IContainer parent)
|
||||
{
|
||||
@@ -22,16 +25,23 @@ namespace FileTime.Providers.Smb
|
||||
FullName = parent.FullName + Constants.SeparatorChar + Name;
|
||||
|
||||
Provider = provider;
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
public Task Delete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task Rename(string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetPrimaryAttributeText()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public IContainer? GetParent() => _parent;
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,12 @@ namespace FileTime.Providers.Smb
|
||||
public string? FullName { get; }
|
||||
|
||||
public bool IsHidden => false;
|
||||
public bool IsLoaded => _items != null;
|
||||
|
||||
public SmbContentProvider Provider { get; }
|
||||
IContentProvider IItem.Provider => Provider;
|
||||
public bool CanDelete => true;
|
||||
public bool CanRename => true;
|
||||
|
||||
public AsyncEventHandler Refreshed { get; } = new();
|
||||
|
||||
@@ -77,6 +80,10 @@ namespace FileTime.Providers.Smb
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task Rename(string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task Refresh()
|
||||
{
|
||||
|
||||
@@ -24,10 +24,13 @@ namespace FileTime.Providers.Smb
|
||||
public string? FullName { get; }
|
||||
|
||||
public bool IsHidden => false;
|
||||
public bool IsLoaded => _items != null;
|
||||
|
||||
public SmbContentProvider Provider { get; }
|
||||
|
||||
IContentProvider IItem.Provider => Provider;
|
||||
public bool CanDelete => false;
|
||||
public bool CanRename => false;
|
||||
|
||||
public AsyncEventHandler Refreshed { get; } = new();
|
||||
|
||||
@@ -128,5 +131,7 @@ namespace FileTime.Providers.Smb
|
||||
}
|
||||
return _client;
|
||||
}
|
||||
|
||||
public Task Rename(string newName) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using AsyncEvent;
|
||||
using FileTime.Core.Interactions;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Providers;
|
||||
using SMBLibrary;
|
||||
@@ -20,9 +19,12 @@ namespace FileTime.Providers.Smb
|
||||
public string? FullName { get; }
|
||||
|
||||
public bool IsHidden => false;
|
||||
public bool IsLoaded => _items != null;
|
||||
|
||||
public SmbContentProvider Provider { get; }
|
||||
IContentProvider IItem.Provider => Provider;
|
||||
public bool CanDelete => false;
|
||||
public bool CanRename => false;
|
||||
|
||||
public AsyncEventHandler Refreshed { get; } = new();
|
||||
|
||||
@@ -150,5 +152,7 @@ namespace FileTime.Providers.Smb
|
||||
|
||||
return (containers, elements);
|
||||
}
|
||||
|
||||
public Task Rename(string newName) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user