GUI async refactor

This commit is contained in:
2022-01-20 23:31:57 +01:00
parent 215503a4e3
commit 031d07613b
12 changed files with 204 additions and 200 deletions

View File

@@ -42,8 +42,8 @@ namespace FileTime.Core.Components
} */
public int CurrentSelectedIndex { get; private set; }
public event EventHandler CurrentLocationChanged;
public event EventHandler CurrentSelectedItemChanged;
public AsyncEventHandler CurrentLocationChanged = new();
public AsyncEventHandler CurrentSelectedItemChanged = new();
public async Task Init(IContainer currentPath)
{
@@ -65,7 +65,7 @@ namespace FileTime.Core.Components
}
_currentLocation = value;
CurrentLocationChanged?.Invoke(this, EventArgs.Empty);
await CurrentLocationChanged?.InvokeAsync(this, AsyncEventArgs.Empty);
var currentLocationItems = (await (await GetCurrentLocation()).GetItems())!;
await SetCurrentSelectedItem(currentLocationItems.Count > 0 ? currentLocationItems[0] : null);
@@ -87,7 +87,7 @@ namespace FileTime.Core.Components
_currentSelectedItem = value;
CurrentSelectedIndex = await GetItemIndex(value);
CurrentSelectedItemChanged?.Invoke(this, EventArgs.Empty);
await CurrentSelectedItemChanged?.InvokeAsync(this, AsyncEventArgs.Empty);
}
}

View File

@@ -45,22 +45,10 @@ namespace FileTime.Core.Providers
public Task<bool> IsExists(string name) => throw new NotImplementedException();
public Task Refresh()
{
return Task.CompletedTask;
}
public async Task Refresh() => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default)
{
return Task.FromResult(_items);
}
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default)
{
return Task.FromResult(_containers);
}
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default)
{
return Task.FromResult(_elements);
}
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default) => Task.FromResult(_items);
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default) => Task.FromResult(_containers);
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default) => Task.FromResult(_elements);
}
}

View File

@@ -1,4 +1,5 @@
using FileTime.Core.Components;
using AsyncEvent;
using FileTime.Core.Components;
using FileTime.Core.Models;
using FileTime.Providers.Local;
using FileTime.Uno.ViewModels;
@@ -6,7 +7,9 @@ using MvvmGen;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileTime.Uno.Application
{
@@ -28,32 +31,39 @@ namespace FileTime.Uno.Application
[PropertyCallMethod(nameof(SelectedItemChanged))]
private IItemViewModel _selectedItem;
partial void OnInitialize()
public async Task Init()
{
Tab.CurrentLocationChanged += Tab_CurrentLocationChanged;
Tab.CurrentSelectedItemChanged += Tab_CurrentSelectedItemChanged;
Tab.CurrentLocationChanged.Add(Tab_CurrentLocationChanged);
Tab.CurrentSelectedItemChanged.Add(Tab_CurrentSelectedItemChanged);
CurrentLocation = new ContainerViewModel(Tab.CurrentLocation);
var parent = Tab.CurrentLocation.GetParent();
CurrentLocation = new ContainerViewModel(await Tab.GetCurrentLocation());
await CurrentLocation.Init();
var parent = (await Tab.GetCurrentLocation()).GetParent();
if (parent != null)
{
Parent = new ContainerViewModel(parent);
await Parent.Init();
}
else
{
Parent = null;
}
UpdateCurrentSelectedItem();
await UpdateCurrentSelectedItem();
}
private void Tab_CurrentLocationChanged(object sender, EventArgs e)
private async Task Tab_CurrentLocationChanged(object sender, AsyncEventArgs e)
{
CurrentLocation = new ContainerViewModel(Tab.CurrentLocation);
var parent = Tab.CurrentLocation.GetParent();
var currentLocation = await Tab.GetCurrentLocation();
CurrentLocation = new ContainerViewModel(currentLocation);
await CurrentLocation.Init();
var parent = currentLocation.GetParent();
if (parent != null)
{
Parent = new ContainerViewModel(parent);
await Parent.Init();
}
else
{
@@ -61,30 +71,32 @@ namespace FileTime.Uno.Application
}
}
private void Tab_CurrentSelectedItemChanged(object sender, EventArgs e)
private async Task Tab_CurrentSelectedItemChanged(object sender, AsyncEventArgs e)
{
UpdateCurrentSelectedItem();
await UpdateCurrentSelectedItem();
}
private void UpdateCurrentSelectedItem()
private async Task UpdateCurrentSelectedItem()
{
var tabCurrentSelectenItem = await Tab.GetCurrentSelectedItem();
IItemViewModel currentSelectenItem = null;
if (Tab.CurrentSelectedItem == null)
if (tabCurrentSelectenItem == null)
{
SelectedItem = null;
ChildContainer = null;
}
else
{
currentSelectenItem = _currentLocation.Items.Find(i => i.Item.Name == Tab.CurrentSelectedItem.Name);
currentSelectenItem = _currentLocation.Items.FirstOrDefault(i => i.Item.Name == tabCurrentSelectenItem.Name);
if (currentSelectenItem is ContainerViewModel currentSelectedContainer)
{
SelectedItem = ChildContainer = currentSelectedContainer;
SelectedItem = currentSelectedContainer;
ChildContainer = currentSelectedContainer;
}
else if (currentSelectenItem is ElementViewModel element)
{
ChildContainer = null;
SelectedItem = element;
ChildContainer = null;
}
else
{
@@ -99,79 +111,79 @@ namespace FileTime.Uno.Application
}
}
private void SelectedItemChanged()
private async void SelectedItemChanged()
{
Tab.CurrentSelectedItem = SelectedItem?.Item;
await Tab.SetCurrentSelectedItem(SelectedItem?.Item);
}
public void Open()
public async Task Open()
{
if (ChildContainer != null)
{
Tab.Open();
UpdateCurrentSelectedItem();
await Tab.Open();
await UpdateCurrentSelectedItem();
}
}
public void GoUp()
public async Task GoUp()
{
Tab.GoUp();
UpdateCurrentSelectedItem();
await Tab.GoUp();
await UpdateCurrentSelectedItem();
}
public void MoveCursorDown()
public async Task MoveCursorDown()
{
Tab.SelectNextItem();
await Tab.SelectNextItem();
}
public void MoveCursorDownPage()
public async Task MoveCursorDownPage()
{
Tab.SelectNextItem(10);
await Tab.SelectNextItem(10);
}
public void MoveCursorUp()
public async Task MoveCursorUp()
{
Tab.SelectPreviousItem();
await Tab.SelectPreviousItem();
}
public void MoveCursorUpPage()
public async Task MoveCursorUpPage()
{
Tab.SelectPreviousItem(10);
await Tab.SelectPreviousItem(10);
}
public void MoveCursorToFirst()
public async Task MoveCursorToFirst()
{
Tab.SelectFirstItem();
await Tab.SelectFirstItem();
}
public void MoveCursorToLast()
public async Task MoveCursorToLast()
{
Tab.SelectLastItem();
await Tab.SelectLastItem();
}
public void GotToProvider()
public async Task GotToProvider()
{
Tab.GoToProvider();
await Tab.GoToProvider();
}
public void GotToRoot()
public async Task GotToRoot()
{
Tab.GoToRoot();
await Tab.GoToRoot();
}
public void GotToHome()
public async Task GotToHome()
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(Path.DirectorySeparatorChar, Constants.SeparatorChar);
var resolvedPath = LocalContentProvider.GetByPath(path);
if(resolvedPath is IContainer homeFolder)
if (resolvedPath is IContainer homeFolder)
{
Tab.OpenContainer(homeFolder);
await Tab.OpenContainer(homeFolder);
}
}
public void CreateContainer(string name)
public async Task CreateContainer(string name)
{
Tab.CurrentLocation.CreateContainer(name);
(await Tab.GetCurrentLocation())?.CreateContainer(name);
}
}
}

View File

@@ -4,27 +4,28 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileTime.Uno.Command
{
public class CommandBinding
{
private readonly Action _commandHandler;
private readonly Func<Task> _commandHandler;
public string Name { get; }
public Commands? Command { get; }
public KeyWithModifiers[] Keys { get; }
public void Invoke() => _commandHandler();
public string KeysDisplayText => GetKeysDisplayText();
public CommandBinding(string name, Commands? command, KeyWithModifiers[] keys, Action commandHandler)
public CommandBinding(string name, Commands? command, KeyWithModifiers[] keys, Func<Task> commandHandler)
{
_commandHandler = commandHandler;
Name = name;
Command = command;
Keys = keys;
}
public async Task InvokeAsync() => await _commandHandler();
public string GetKeysDisplayText()
{

View File

@@ -62,9 +62,9 @@ namespace FileTime.Uno
e.Handled = ViewModel.ProcessKeyDown(e.Key) || e.Handled;
}
private void CurrentItems_KeyUp(object sender, KeyRoutedEventArgs e)
private async void CurrentItems_KeyUp(object sender, KeyRoutedEventArgs e)
{
e.Handled = ViewModel.ProcessKeyUp(e.Key) || e.Handled;
e.Handled = await ViewModel.ProcessKeyUp(e.Key) || e.Handled;
}
private void InputText_KeyDown(object sender, KeyRoutedEventArgs e)

View File

@@ -1,15 +1,20 @@
using FileTime.Core.Models;
using AsyncEvent;
using FileTime.Core.Models;
using MvvmGen;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileTime.Uno.ViewModels
{
[ViewModel]
public partial class ContainerViewModel : IItemViewModel
{
private bool isRefreshing;
[Property]
private IContainer _container;
@@ -19,13 +24,13 @@ namespace FileTime.Uno.ViewModels
public IItem Item => _container;
//[Property]
private List<ContainerViewModel> _containers;
private readonly ObservableCollection<ContainerViewModel> _containers = new ObservableCollection<ContainerViewModel>();
//[Property]
private List<ElementViewModel> _elements;
private readonly ObservableCollection<ElementViewModel> _elements = new ObservableCollection<ElementViewModel>();
//[Property]
private List<IItemViewModel> _items;
private readonly ObservableCollection<IItemViewModel> _items = new ObservableCollection<IItemViewModel>();
[Property]
private bool _isAlternative;
@@ -40,77 +45,88 @@ namespace FileTime.Uno.ViewModels
? ItemViewMode.Alternative
: ItemViewMode.Default;
public List<ContainerViewModel> Containers
public ObservableCollection<ContainerViewModel> Containers
{
get
{
if(_containers == null) Refresh();
if (_containers == null) Task.Run(Refresh);
return _containers;
}
set
{
if(_containers != value)
{
_containers = value;
OnPropertyChanged(nameof(_containers));
}
}
}
public List<ElementViewModel> Elements
public ObservableCollection<ElementViewModel> Elements
{
get
{
if(_elements == null) Refresh();
if (_elements == null) Task.Run(Refresh);
return _elements;
}
set
{
if(_elements != value)
{
_elements = value;
OnPropertyChanged(nameof(_elements));
}
}
}
public List<IItemViewModel> Items
public ObservableCollection<IItemViewModel> Items
{
get
{
if(_items == null) Refresh();
if (_items == null) Task.Run(Refresh);
return _items;
}
set
{
if(_items != value)
{
_items = value;
OnPropertyChanged(nameof(_items));
}
}
}
public ContainerViewModel(IContainer container)
public ContainerViewModel(IContainer container) : this()
{
Container = container;
Container.Refreshed += Container_Refreshed;
Container.Refreshed.Add(Container_Refreshed);
}
private void Container_Refreshed(object sender, EventArgs e)
public async Task Init(bool initializeChildren = true)
{
Refresh();
await Refresh(initializeChildren);
}
private void Refresh()
private async Task Container_Refreshed(object sender, AsyncEventArgs e)
{
Containers = _container.Containers.Select(c => new ContainerViewModel(c)).ToList();
Elements = _container.Elements.Select(e => new ElementViewModel(e)).ToList();
Items = Containers.Cast<IItemViewModel>().Concat(Elements).ToList();
for(var i = 0;i<Items.Count;i++)
{
Items[i].IsAlternative = i % 2 == 1;
await Refresh(false);
}
private async Task Refresh()
{
await Refresh(true);
}
private async Task Refresh(bool initializeChildren)
{
if (isRefreshing) return;
try
{
isRefreshing = true;
var containers = (await _container.GetContainers()).Select(c => new ContainerViewModel(c)).ToList();
var elements = (await _container.GetElements()).Select(e => new ElementViewModel(e)).ToList();
_containers.Clear();
_elements.Clear();
_items.Clear();
foreach (var container in containers)
{
if (initializeChildren) await container.Init(false);
_containers.Add(container);
_items.Add(container);
}
foreach (var element in elements)
{
_elements.Add(element);
_items.Add(element);
}
for (var i = 0; i < _items.Count; i++)
{
_items[i].IsAlternative = i % 2 == 1;
}
}
catch { }
isRefreshing = false;
}
}
}

View File

@@ -10,6 +10,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.System;
namespace FileTime.Uno.ViewModels
@@ -20,6 +21,7 @@ namespace FileTime.Uno.ViewModels
public partial class MainPageViewModel
{
private readonly List<KeyWithModifiers> _previousKeys = new List<KeyWithModifiers>();
private readonly List<KeyWithModifiers[]> _keysToSkip = new List<KeyWithModifiers[]>();
private bool _isAltPressed = false;
private bool _isShiftPressed = false;
private bool _isCtrlPressed = false;
@@ -46,19 +48,28 @@ namespace FileTime.Uno.ViewModels
public Action FocusDefaultElement { get; set; }
partial void OnInitialize()
async partial void OnInitialize()
{
InitCommandBindings();
_keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(VirtualKey.Up) });
_keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(VirtualKey.Down) });
_keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(VirtualKey.Tab) });
var tab = new Tab();
await tab.Init(LocalContentProvider);
var tabContainer = new TabContainer(tab, LocalContentProvider);
await tabContainer.Init();
AppState.Tabs = new List<TabContainer>()
{
new TabContainer(new Tab(LocalContentProvider), LocalContentProvider)
tabContainer
};
var driveInfos = new List<RootDriveInfo>();
foreach (var drive in DriveInfo.GetDrives())
{
var container = LocalContentProvider.RootContainers.FirstOrDefault(d => d.Name == drive.Name.TrimEnd(Path.DirectorySeparatorChar));
var container = (await LocalContentProvider.GetRootContainers()).FirstOrDefault(d => d.Name == drive.Name.TrimEnd(Path.DirectorySeparatorChar));
if (container != null)
{
var driveInfo = new RootDriveInfo(drive, container);
@@ -69,73 +80,75 @@ namespace FileTime.Uno.ViewModels
RootDriveInfos = driveInfos;
}
public void OpenContainer()
public async Task OpenContainer()
{
AppState.SelectedTab.Open();
await AppState.SelectedTab.Open();
}
public void GoUp()
public async Task GoUp()
{
AppState.SelectedTab.GoUp();
await AppState.SelectedTab.GoUp();
}
public void MoveCursorUp()
public async Task MoveCursorUp()
{
AppState.SelectedTab.MoveCursorUp();
await AppState.SelectedTab.MoveCursorUp();
}
public void MoveCursorDown()
public async Task MoveCursorDown()
{
AppState.SelectedTab.MoveCursorDown();
await AppState.SelectedTab.MoveCursorDown();
}
public void MoveCursorUpPage()
public async Task MoveCursorUpPage()
{
AppState.SelectedTab.MoveCursorUpPage();
await AppState.SelectedTab.MoveCursorUpPage();
}
public void MoveCursorDownPage()
public async Task MoveCursorDownPage()
{
AppState.SelectedTab.MoveCursorDownPage();
await AppState.SelectedTab.MoveCursorDownPage();
}
public void MoveToFirst()
public async Task MoveToFirst()
{
AppState.SelectedTab.MoveCursorToFirst();
await AppState.SelectedTab.MoveCursorToFirst();
}
public void MoveToLast()
public async Task MoveToLast()
{
AppState.SelectedTab.MoveCursorToLast();
await AppState.SelectedTab.MoveCursorToLast();
}
public void GotToProvider()
public async Task GotToProvider()
{
AppState.SelectedTab.GotToProvider();
await AppState.SelectedTab.GotToProvider();
}
public void GotToRoot()
public async Task GotToRoot()
{
AppState.SelectedTab.GotToRoot();
await AppState.SelectedTab.GotToRoot();
}
public void GotToHome()
public async Task GotToHome()
{
AppState.SelectedTab.GotToHome();
await AppState.SelectedTab.GotToHome();
}
public void CreateContainer()
public Task CreateContainer()
{
var handler = () =>
{
if (Inputs != null)
{
AppState.SelectedTab.CreateContainer(Inputs[0].Value);
AppState.SelectedTab.CreateContainer(Inputs[0].Value).Wait();
Inputs = null;
}
};
ReadInputs(new List<InputElement>() { new InputElement("Container name", InputType.Text) }, handler);
return Task.CompletedTask;
}
[Command]
@@ -172,7 +185,7 @@ namespace FileTime.Uno.ViewModels
return false;
}
public bool ProcessKeyUp(VirtualKey key)
public async Task<bool> ProcessKeyUp(VirtualKey key)
{
if (key == VirtualKey.Menu)
{
@@ -198,15 +211,9 @@ namespace FileTime.Uno.ViewModels
_previousKeys.Clear();
PossibleCommands = new();
}
else if (_previousKeys.Count == 2 && selectedCommandBinding == null)
{
NoCommandFound = true;
_previousKeys.Clear();
PossibleCommands = new();
}
else if (selectedCommandBinding != null)
{
selectedCommandBinding.Invoke();
await selectedCommandBinding.InvokeAsync();
_previousKeys.Clear();
PossibleCommands = new();
@@ -215,6 +222,17 @@ namespace FileTime.Uno.ViewModels
FocusDefaultElement?.Invoke();
}
}
else if (_keysToSkip.Any(k => AreKeysEqual(k, _previousKeys)))
{
_previousKeys.Clear();
PossibleCommands = new();
}
else if (_previousKeys.Count == 2)
{
NoCommandFound = true;
_previousKeys.Clear();
PossibleCommands = new();
}
else
{
var possibleCommands = _commandBindings.Where(c => AreKeysEqual(c.Keys[0], keyWithModifiers)).ToList();
@@ -275,11 +293,11 @@ namespace FileTime.Uno.ViewModels
new CommandBinding("cursor down", FileTime.App.Core.Command.Commands.MoveCursorDown, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Down)}, MoveCursorDown),
new CommandBinding("cursor page up", FileTime.App.Core.Command.Commands.MoveCursorUpPage, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.PageUp)}, MoveCursorUpPage),
new CommandBinding("cursor page down", FileTime.App.Core.Command.Commands.MoveCursorDownPage, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.PageDown)}, MoveCursorDownPage),*/
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Up)}, () =>{ }),
/*new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Up)}, () =>{ }),
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Down)}, () =>{ }),
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.PageUp)}, () =>{ }),
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.PageDown)}, () =>{ }),
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Tab)}, () =>{ }),
new CommandBinding("", null, new KeyWithModifiers[]{new KeyWithModifiers(VirtualKey.Tab)}, () =>{ }),*/
new CommandBinding(
"create container",
FileTime.App.Core.Command.Commands.CreateContainer,

View File

@@ -64,8 +64,7 @@ namespace FileTime.Providers.Local
return await rootContainer.GetByPath(string.Join(Constants.SeparatorChar, pathParts.Skip(1)));
}
public Task Refresh() => Task.CompletedTask;
public async Task Refresh() => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
public IContainer? GetParent() => _parent;
public Task<IContainer> CreateContainer(string name) => throw new NotSupportedException();
@@ -78,26 +77,11 @@ namespace FileTime.Providers.Local
public bool CanHandlePath(string path) => _rootContainers.Any(r => path.StartsWith(r.Name));
public void SetParent(IContainer container)
{
_parent = container;
}
public Task<IReadOnlyList<IContainer>?> GetRootContainers(CancellationToken token = default)
{
return Task.FromResult(_rootContainers);
}
public void SetParent(IContainer container) => _parent = container;
public Task<IReadOnlyList<IContainer>> GetRootContainers(CancellationToken token = default) => Task.FromResult(_rootContainers);
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default)
{
return Task.FromResult(_items);
}
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default)
{
return Task.FromResult(_rootContainers);
}
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default)
{
return Task.FromResult(_elements);
}
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default) => Task.FromResult(_items);
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default) => Task.FromResult((IReadOnlyList<IContainer>?)_rootContainers);
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default) => Task.FromResult(_elements);
}
}

View File

@@ -7,7 +7,7 @@ namespace FileTime.Providers.Smb
{
public class SmbContentProvider : IContentProvider
{
private IContainer _parent;
private IContainer? _parent;
private readonly IInputInterface _inputInterface;
private readonly List<IContainer> _rootContainers;
private readonly IReadOnlyList<IContainer> _rootContainersReadOnly;
@@ -64,32 +64,17 @@ namespace FileTime.Providers.Smb
public IContainer? GetParent() => _parent;
public async Task<bool> IsExists(string name) => (await GetItems()).Any(i => i.Name == name);
public async Task<bool> IsExists(string name) => (await GetItems())?.Any(i => i.Name == name) ?? false;
public async Task Refresh()
{
await Refreshed?.InvokeAsync(this, AsyncEventArgs.Empty);
}
public async Task Refresh() => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
public bool CanHandlePath(string path) => path.StartsWith("smb://") || path.StartsWith(@"\\");
public void SetParent(IContainer container) => _parent = container;
public Task<IReadOnlyList<IContainer>?> GetRootContainers(CancellationToken token = default)
{
return Task.FromResult(_rootContainersReadOnly);
}
public Task<IReadOnlyList<IContainer>> GetRootContainers(CancellationToken token = default) => Task.FromResult(_rootContainersReadOnly);
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default)
{
return Task.FromResult(_items);
}
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default)
{
return Task.FromResult(_rootContainersReadOnly);
}
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default)
{
return Task.FromResult(_elements);
}
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);
}
}

View File

@@ -92,7 +92,7 @@ namespace FileTime.Providers.Smb
_elements = elements.AsReadOnly();
_items = _containers.Cast<IItem>().Concat(_elements).ToList().AsReadOnly();
await Refreshed?.InvokeAsync(this, AsyncEventArgs.Empty);
await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
}
public async Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default)

View File

@@ -89,7 +89,7 @@ namespace FileTime.Providers.Smb
_shares = shares.ConvertAll(s => new SmbShare(s, Provider, this, GetSmbClient)).AsReadOnly();
_items = _shares.Cast<IItem>().ToList().AsReadOnly();
await Refreshed?.InvokeAsync(this, AsyncEventArgs.Empty);
await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
}
private async Task<ISMBClient> GetSmbClient()

View File

@@ -108,7 +108,7 @@ namespace FileTime.Providers.Smb
_elements = elements.AsReadOnly();
_items = _containers.Cast<IItem>().Concat(_elements).ToList().AsReadOnly();
await Refreshed?.InvokeAsync(this, AsyncEventArgs.Empty);
await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
}
public async Task<(List<IContainer> containers, List<IElement> elements)> ListFolder(IContainer parent, string shareName, string folderName)