Cleaning up warning
This commit is contained in:
@@ -23,7 +23,7 @@ public class ContainerSizeSizeScanProvider : ContentProviderBase, IContainerSize
|
|||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<IItem> GetItemByFullNameAsync(
|
public override Task<IItem> GetItemByFullNameAsync(
|
||||||
FullName fullName,
|
FullName fullName,
|
||||||
PointInTime pointInTime,
|
PointInTime pointInTime,
|
||||||
bool forceResolve = false,
|
bool forceResolve = false,
|
||||||
@@ -32,14 +32,14 @@ public class ContainerSizeSizeScanProvider : ContentProviderBase, IContainerSize
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (fullName.Path == ContentProviderName)
|
if (fullName.Path == ContentProviderName)
|
||||||
return this;
|
return Task.FromResult((IItem)this);
|
||||||
|
|
||||||
var pathParts = fullName.Path.Split(Constants.SeparatorChar);
|
var pathParts = fullName.Path.Split(Constants.SeparatorChar);
|
||||||
|
|
||||||
var item = _sizeScanTasks.FirstOrDefault(t => t.SizeSizeScanContainer.Name == pathParts[1])?.SizeSizeScanContainer;
|
var item = _sizeScanTasks.FirstOrDefault(t => t.SizeSizeScanContainer.Name == pathParts[1])?.SizeSizeScanContainer;
|
||||||
|
|
||||||
if (pathParts.Length == 2)
|
if (pathParts.Length == 2)
|
||||||
return item ?? throw new ItemNotFoundException(fullName);
|
return Task.FromResult((IItem)item!) ?? throw new ItemNotFoundException(fullName);
|
||||||
|
|
||||||
for (var i = 2; i < pathParts.Length - 1 && item != null; i++)
|
for (var i = 2; i < pathParts.Length - 1 && item != null; i++)
|
||||||
{
|
{
|
||||||
@@ -47,22 +47,8 @@ public class ContainerSizeSizeScanProvider : ContentProviderBase, IContainerSize
|
|||||||
item = item.ChildContainers.FirstOrDefault(c => c.Name == childName);
|
item = item.ChildContainers.FirstOrDefault(c => c.Name == childName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is not null)
|
var childItem = item?.SizeItems.FirstOrDefault(c => c.Name == pathParts[^1]);
|
||||||
{
|
if (childItem != null) return Task.FromResult((IItem)childItem);
|
||||||
var childItem = item.SizeItems.FirstOrDefault(c => c.Name == pathParts[^1]);
|
|
||||||
if (childItem is not null) return childItem;
|
|
||||||
|
|
||||||
/*var childName = item.RealContainer.FullName?.GetChild(pathParts[^1]);
|
|
||||||
if (childName is null) throw new ItemNotFoundException(fullName);
|
|
||||||
|
|
||||||
return await _timelessContentProvider.GetItemByFullNameAsync(
|
|
||||||
childName,
|
|
||||||
pointInTime,
|
|
||||||
forceResolve,
|
|
||||||
forceResolvePathType,
|
|
||||||
itemInitializationSettings
|
|
||||||
);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ItemNotFoundException(fullName);
|
throw new ItemNotFoundException(fullName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public interface ITabViewModel : IInitable<ITab, int>, IDisposable
|
|||||||
IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; }
|
IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; }
|
||||||
IDeclarativeProperty<ObservableCollection<IItemViewModel>?> CurrentItems { get; }
|
IDeclarativeProperty<ObservableCollection<IItemViewModel>?> CurrentItems { get; }
|
||||||
IDeclarativeProperty<ObservableCollection<FullName>> MarkedItems { get; }
|
IDeclarativeProperty<ObservableCollection<FullName>> MarkedItems { get; }
|
||||||
IDeclarativeProperty<ObservableCollection<IItemViewModel>> SelectedsChildren { get; }
|
IDeclarativeProperty<ObservableCollection<IItemViewModel>?> SelectedsChildren { get; }
|
||||||
IDeclarativeProperty<ObservableCollection<IItemViewModel>> ParentsChildren { get; }
|
IDeclarativeProperty<ObservableCollection<IItemViewModel>?> ParentsChildren { get; }
|
||||||
IDeclarativeProperty<int?> CurrentSelectedItemIndex { get; set; }
|
IDeclarativeProperty<int?> CurrentSelectedItemIndex { get; set; }
|
||||||
|
|
||||||
void ClearMarkedItems();
|
void ClearMarkedItems();
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace FileTime.App.Core.Services;
|
|||||||
public abstract class DialogServiceBase : IDialogServiceBase
|
public abstract class DialogServiceBase : IDialogServiceBase
|
||||||
{
|
{
|
||||||
private readonly IModalService _modalService;
|
private readonly IModalService _modalService;
|
||||||
private OcConsumer _readInputConsumer = new();
|
private readonly OcConsumer _readInputConsumer = new();
|
||||||
private OcConsumer _lastMessageBoxConsumer = new();
|
private readonly OcConsumer _lastMessageBoxConsumer = new();
|
||||||
public ScalarComputing<ReadInputsViewModel?> ReadInput { get; }
|
public ScalarComputing<ReadInputsViewModel?> ReadInput { get; }
|
||||||
public ScalarComputing<MessageBoxViewModel?> LastMessageBox { get; }
|
public ScalarComputing<MessageBoxViewModel?> LastMessageBox { get; }
|
||||||
|
|
||||||
@@ -20,14 +20,14 @@ public abstract class DialogServiceBase : IDialogServiceBase
|
|||||||
.OpenModals
|
.OpenModals
|
||||||
.OfTypeComputing<ReadInputsViewModel>()
|
.OfTypeComputing<ReadInputsViewModel>()
|
||||||
.FirstComputing()
|
.FirstComputing()
|
||||||
.For(_readInputConsumer);
|
.For(_readInputConsumer)!;
|
||||||
|
|
||||||
LastMessageBox =
|
LastMessageBox =
|
||||||
modalService
|
modalService
|
||||||
.OpenModals
|
.OpenModals
|
||||||
.OfTypeComputing<MessageBoxViewModel>()
|
.OfTypeComputing<MessageBoxViewModel>()
|
||||||
.LastComputing()
|
.LastComputing()
|
||||||
.For(_lastMessageBoxConsumer);
|
.For(_lastMessageBoxConsumer)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadInputs(
|
private void ReadInputs(
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class TabPersistenceService : ITabPersistenceService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tab = await _serviceProvider
|
var tab = await _serviceProvider
|
||||||
.GetAsyncInitableResolver<IContainer>(currentDirectory ?? _localContentProvider)
|
.GetAsyncInitableResolver(currentDirectory ?? _localContentProvider)
|
||||||
.GetRequiredServiceAsync<ITab>();
|
.GetRequiredServiceAsync<ITab>();
|
||||||
var tabViewModel = _serviceProvider.GetInitableResolver(tab, 1).GetRequiredService<ITabViewModel>();
|
var tabViewModel = _serviceProvider.GetInitableResolver(tab, 1).GetRequiredService<ITabViewModel>();
|
||||||
|
|
||||||
@@ -191,8 +191,8 @@ public class TabPersistenceService : ITabPersistenceService
|
|||||||
if (tab.Path == null) continue;
|
if (tab.Path == null) continue;
|
||||||
if (_contentProvidersNotToRestore.Any(p => tab.Path.StartsWith(p))) continue;
|
if (_contentProvidersNotToRestore.Any(p => tab.Path.StartsWith(p))) continue;
|
||||||
|
|
||||||
IContainer? container = null;
|
IContainer? container;
|
||||||
var path = FullName.CreateSafe(tab.Path);
|
var path = FullName.CreateSafe(tab.Path)!;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -213,7 +213,7 @@ public class TabPersistenceService : ITabPersistenceService
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
path = path?.GetParent();
|
path = path.GetParent();
|
||||||
if (path == null)
|
if (path == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"Could not find an initializable path along {tab.Path}");
|
throw new Exception($"Could not find an initializable path along {tab.Path}");
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
|||||||
if (selectedCommandBinding != null)
|
if (selectedCommandBinding != null)
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
await CallCommandAsync(_identifiableUserCommandService.GetCommand(selectedCommandBinding.Command));
|
await CallCommandAsync(_identifiableUserCommandService.GetCommand(selectedCommandBinding.Command)!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
|
|
||||||
SearchText = _searchText.AsObservable();
|
SearchText = _searchText.AsObservable();
|
||||||
SelectedTab = DeclarativePropertyHelpers.CombineLatest<ObservableCollection<ITabViewModel>, ITabViewModel, ITabViewModel>(
|
SelectedTab = DeclarativePropertyHelpers.CombineLatest<ObservableCollection<ITabViewModel>, ITabViewModel, ITabViewModel>(
|
||||||
_tabs.Watch(),
|
_tabs.Watch()!,
|
||||||
_selectedTab,
|
_selectedTab!,
|
||||||
(tabs, selectedTab) => Task.FromResult(GetSelectedTab(tabs, selectedTab))
|
(tabs, selectedTab) => Task.FromResult(GetSelectedTab(tabs, selectedTab)!)
|
||||||
);
|
)!;
|
||||||
|
|
||||||
Tabs = new ReadOnlyObservableCollection<ITabViewModel>(_tabs);
|
Tabs = new ReadOnlyObservableCollection<ITabViewModel>(_tabs);
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
.Map(t => t?.CurrentLocation)
|
.Map(t => t?.CurrentLocation)
|
||||||
.Switch()
|
.Switch()
|
||||||
.Map(c => c?.GetExtension<StatusProviderContainerExtension>()?.GetStatusProperty())
|
.Map(c => c?.GetExtension<StatusProviderContainerExtension>()?.GetStatusProperty())
|
||||||
.Switch();
|
.Switch()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTab(ITabViewModel tabViewModel)
|
public void AddTab(ITabViewModel tabViewModel)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
|
|
||||||
var sourceCollection = itemViewModelType switch
|
var sourceCollection = itemViewModelType switch
|
||||||
{
|
{
|
||||||
ItemViewModelType.Main => parentTab.CurrentItems,
|
ItemViewModelType.Main => parentTab.CurrentItems!,
|
||||||
ItemViewModelType.Parent => parentTab.ParentsChildren,
|
ItemViewModelType.Parent => parentTab.ParentsChildren,
|
||||||
ItemViewModelType.SelectedChild => parentTab.SelectedsChildren,
|
ItemViewModelType.SelectedChild => parentTab.SelectedsChildren,
|
||||||
_ => throw new InvalidEnumArgumentException()
|
_ => throw new InvalidEnumArgumentException()
|
||||||
@@ -59,15 +59,15 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
? (IReadOnlyList<ItemNamePart>) await nameConverterProvider.GetItemNamePartsAsync(item)
|
? (IReadOnlyList<ItemNamePart>) await nameConverterProvider.GetItemNamePartsAsync(item)
|
||||||
: _itemNameConverterService.GetDisplayName(item.DisplayName, s)
|
: _itemNameConverterService.GetDisplayName(item.DisplayName, s)
|
||||||
),
|
),
|
||||||
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new(item.DisplayName)}),
|
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new(item.DisplayName)})!,
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseItem = item;
|
BaseItem = item;
|
||||||
DisplayName = displayName;
|
DisplayName = displayName!;
|
||||||
DisplayNameText = item.DisplayName;
|
DisplayNameText = item.DisplayName;
|
||||||
|
|
||||||
IsMarked = itemViewModelType is ItemViewModelType.Main
|
IsMarked = itemViewModelType is ItemViewModelType.Main
|
||||||
? parentTab.MarkedItems.Map(m => m.Any(i => i.Path == item.FullName?.Path))
|
? parentTab.MarkedItems!.Map(m => m!.Any(i => i.Path == item.FullName?.Path))
|
||||||
: new DeclarativeProperty<bool>(false);
|
: new DeclarativeProperty<bool>(false);
|
||||||
|
|
||||||
IsSelected = itemViewModelType is ItemViewModelType.Main
|
IsSelected = itemViewModelType is ItemViewModelType.Main
|
||||||
@@ -78,7 +78,7 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
: new DeclarativeProperty<bool>(IsInDeepestPath());
|
: new DeclarativeProperty<bool>(IsInDeepestPath());
|
||||||
|
|
||||||
IsAlternative = sourceCollection
|
IsAlternative = sourceCollection
|
||||||
.Debounce(TimeSpan.FromMilliseconds(100))
|
.Debounce(TimeSpan.FromMilliseconds(100))!
|
||||||
.Map(c =>
|
.Map(c =>
|
||||||
c?.Index().FirstOrDefault(i => EqualsTo(i.Value)).Key % 2 == 1
|
c?.Index().FirstOrDefault(i => EqualsTo(i.Value)).Key % 2 == 1
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace FileTime.App.Core.ViewModels;
|
|||||||
public partial class TabViewModel : ITabViewModel
|
public partial class TabViewModel : ITabViewModel
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private readonly IAppState _appState;
|
|
||||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||||
private readonly IRefreshSmoothnessCalculator _refreshSmoothnessCalculator;
|
private readonly IRefreshSmoothnessCalculator _refreshSmoothnessCalculator;
|
||||||
private readonly ObservableCollection<FullName> _markedItems = new();
|
private readonly ObservableCollection<FullName> _markedItems = new();
|
||||||
@@ -34,16 +33,16 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
public ITab? Tab { get; private set; }
|
public ITab? Tab { get; private set; }
|
||||||
public int TabNumber { get; private set; }
|
public int TabNumber { get; private set; }
|
||||||
|
|
||||||
public IDeclarativeProperty<bool> IsSelected { get; }
|
public IDeclarativeProperty<bool> IsSelected { get; } = null!;
|
||||||
|
|
||||||
public IDeclarativeProperty<IContainer?> CurrentLocation { get; private set; }
|
public IDeclarativeProperty<IContainer?> CurrentLocation { get; private set; } = null!;
|
||||||
public IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; private set; }
|
public IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; private set; } = null!;
|
||||||
public IDeclarativeProperty<int?> CurrentSelectedItemIndex { get; set; }
|
public IDeclarativeProperty<int?> CurrentSelectedItemIndex { get; set; } = null!;
|
||||||
public IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; private set; }
|
public IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; private set; } = null!;
|
||||||
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> CurrentItems { get; private set; }
|
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> CurrentItems { get; private set; } = null!;
|
||||||
public IDeclarativeProperty<ObservableCollection<FullName>> MarkedItems { get; }
|
public IDeclarativeProperty<ObservableCollection<FullName>> MarkedItems { get; } = null!;
|
||||||
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> SelectedsChildren { get; private set; }
|
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> SelectedsChildren { get; private set; } = null!;
|
||||||
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> ParentsChildren { get; private set; }
|
public IDeclarativeProperty<ObservableCollection<IItemViewModel>?> ParentsChildren { get; private set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
public TabViewModel(
|
public TabViewModel(
|
||||||
@@ -53,10 +52,9 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
IRefreshSmoothnessCalculator refreshSmoothnessCalculator)
|
IRefreshSmoothnessCalculator refreshSmoothnessCalculator)
|
||||||
{
|
{
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_appState = appState;
|
|
||||||
|
|
||||||
MarkedItems = _markedItems.Watch();
|
MarkedItems = _markedItems.Watch()!;
|
||||||
IsSelected = _appState.SelectedTab.Map(s => s == this);
|
IsSelected = appState.SelectedTab.Map(s => s == this);
|
||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
_refreshSmoothnessCalculator = refreshSmoothnessCalculator;
|
_refreshSmoothnessCalculator = refreshSmoothnessCalculator;
|
||||||
}
|
}
|
||||||
@@ -117,7 +115,7 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
return Task.FromResult<int?>(-1);
|
return Task.FromResult<int?>(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
CurrentSelectedItem.Subscribe((v) =>
|
CurrentSelectedItem.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
_refreshSmoothnessCalculator.RegisterChange();
|
_refreshSmoothnessCalculator.RegisterChange();
|
||||||
_refreshSmoothnessCalculator.RecalculateSmoothness();
|
_refreshSmoothnessCalculator.RecalculateSmoothness();
|
||||||
@@ -176,12 +174,6 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
computing.For(consumer);
|
computing.For(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SortExpressionComparer<IItemViewModel> SortItems()
|
|
||||||
//TODO: Order
|
|
||||||
=> SortExpressionComparer<IItemViewModel>
|
|
||||||
.Ascending(i => i.BaseItem?.Type ?? AbsolutePathType.Unknown)
|
|
||||||
.ThenByAscending(i => i.DisplayNameText?.ToLower() ?? "");
|
|
||||||
|
|
||||||
private static IItem MapItem(AbsolutePath item)
|
private static IItem MapItem(AbsolutePath item)
|
||||||
{
|
{
|
||||||
var t = Task.Run(async () =>
|
var t = Task.Run(async () =>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class FrequencyNavigationViewModel : FuzzyPanelViewModel<string>, IFreque
|
|||||||
if (keyEventArgs.Key == Keys.Enter)
|
if (keyEventArgs.Key == Keys.Enter)
|
||||||
{
|
{
|
||||||
keyEventArgs.Handled = true;
|
keyEventArgs.Handled = true;
|
||||||
var targetContainer = await _timelessContentProvider.GetItemByFullNameAsync(new FullName(SelectedItem), PointInTime.Present);
|
var targetContainer = await _timelessContentProvider.GetItemByFullNameAsync(new FullName(SelectedItem!), PointInTime.Present);
|
||||||
var openContainerCommand = new OpenContainerCommand(new AbsolutePath(_timelessContentProvider, targetContainer));
|
var openContainerCommand = new OpenContainerCommand(new AbsolutePath(_timelessContentProvider, targetContainer));
|
||||||
await _userCommandHandlerService.HandleCommandAsync(openContainerCommand);
|
await _userCommandHandlerService.HandleCommandAsync(openContainerCommand);
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
@@ -71,7 +71,9 @@ public class SearchTask : ISearchTask
|
|||||||
_isSearching = true;
|
_isSearching = true;
|
||||||
_searchingLock.Release();
|
_searchingLock.Release();
|
||||||
|
|
||||||
|
#pragma warning disable CS4014
|
||||||
Task.Run(BootstrapSearch);
|
Task.Run(BootstrapSearch);
|
||||||
|
#pragma warning restore CS4014
|
||||||
|
|
||||||
async Task BootstrapSearch()
|
async Task BootstrapSearch()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace FileTime.ConsoleUI.App;
|
|||||||
|
|
||||||
public interface IConsoleAppState : IAppState
|
public interface IConsoleAppState : IAppState
|
||||||
{
|
{
|
||||||
string ErrorText { get; set; }
|
|
||||||
ObservableCollection<string> PopupTexts { get; }
|
ObservableCollection<string> PopupTexts { get; }
|
||||||
ItemPreviewType? PreviewType { get; set; }
|
ItemPreviewType? PreviewType { get; set; }
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ namespace FileTime.ConsoleUI.App;
|
|||||||
|
|
||||||
public partial class ConsoleAppState : AppStateBase, IConsoleAppState
|
public partial class ConsoleAppState : AppStateBase, IConsoleAppState
|
||||||
{
|
{
|
||||||
[Notify] private string? _errorText;
|
|
||||||
//TODO: make it thread safe
|
//TODO: make it thread safe
|
||||||
public ObservableCollection<string> PopupTexts { get; } = new();
|
public ObservableCollection<string> PopupTexts { get; } = new();
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,6 @@ static bool HandleInfoProviders(string[] args, IServiceProvider serviceProvider)
|
|||||||
|
|
||||||
public partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
public static string AppDataRoot { get; private set; }
|
public static string AppDataRoot { get; private set; } = null!;
|
||||||
public static string EnvironmentName { get; private set; }
|
public static string EnvironmentName { get; private set; } = null!;
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@ namespace FileTime.Core.Interactions;
|
|||||||
|
|
||||||
public interface IOptionsInputElement : IInputElement
|
public interface IOptionsInputElement : IInputElement
|
||||||
{
|
{
|
||||||
object Value { get; set; }
|
object? Value { get; set; }
|
||||||
IReadOnlyCollection<IOptionElement> Options { get; }
|
IReadOnlyCollection<IOptionElement> Options { get; }
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
|||||||
var statusList = statuses.ToList();
|
var statusList = statuses.ToList();
|
||||||
var done = statusList.Count(s => s) + 1;
|
var done = statusList.Count(s => s) + 1;
|
||||||
if (done > statusList.Count) done = statusList.Count;
|
if (done > statusList.Count) done = statusList.Count;
|
||||||
|
|
||||||
return Task.FromResult($"Copy - {done} / {statusList.Count}");
|
return Task.FromResult($"Copy - {done} / {statusList.Count}");
|
||||||
})
|
})
|
||||||
.Subscribe(async (v, _) => await SetDisplayLabelAsync(v));
|
.Subscribe(async (v, _) => await SetDisplayLabelAsync(v));
|
||||||
|
|||||||
@@ -325,32 +325,20 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int Capacity
|
public int Capacity => _buffer.Length;
|
||||||
{
|
|
||||||
get { return _buffer.Length; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool IsFull
|
public bool IsFull => Count == Capacity;
|
||||||
{
|
|
||||||
get { return Count == Capacity; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool IsEmpty
|
public bool IsEmpty => Count == 0;
|
||||||
{
|
|
||||||
get { return Count == 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[Obsolete("Use Count property instead")]
|
[Obsolete("Use Count property instead")]
|
||||||
public int Size => Count;
|
public int Size => Count;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int Count
|
public int Count => _size;
|
||||||
{
|
|
||||||
get { return _size; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[Obsolete("Use First() method instead")]
|
[Obsolete("Use First() method instead")]
|
||||||
@@ -381,30 +369,30 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
{
|
{
|
||||||
if (IsEmpty)
|
if (IsEmpty)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer is empty", index));
|
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer is empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= _size)
|
if (index >= _size)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer size is {1}", index, _size));
|
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer size is {_size}");
|
||||||
}
|
}
|
||||||
|
|
||||||
int actualIndex = InternalIndex(index);
|
var actualIndex = InternalIndex(index);
|
||||||
return _buffer[actualIndex];
|
return _buffer[actualIndex];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (IsEmpty)
|
if (IsEmpty)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer is empty", index));
|
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer is empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= _size)
|
if (index >= _size)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer size is {1}", index, _size));
|
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer size is {_size}");
|
||||||
}
|
}
|
||||||
|
|
||||||
int actualIndex = InternalIndex(index);
|
var actualIndex = InternalIndex(index);
|
||||||
_buffer[actualIndex] = value;
|
_buffer[actualIndex] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -449,7 +437,7 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
ThrowIfEmpty("Cannot take elements from an empty buffer.");
|
ThrowIfEmpty("Cannot take elements from an empty buffer.");
|
||||||
Decrement(ref _end);
|
Decrement(ref _end);
|
||||||
var value = _buffer[_start];
|
var value = _buffer[_start];
|
||||||
_buffer[_end] = default(T);
|
_buffer[_end] = default!;
|
||||||
--_size;
|
--_size;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -459,7 +447,7 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
{
|
{
|
||||||
ThrowIfEmpty("Cannot take elements from an empty buffer.");
|
ThrowIfEmpty("Cannot take elements from an empty buffer.");
|
||||||
var value = _buffer[_start];
|
var value = _buffer[_start];
|
||||||
_buffer[_start] = default(T);
|
_buffer[_start] = default!;
|
||||||
Increment(ref _start);
|
Increment(ref _start);
|
||||||
--_size;
|
--_size;
|
||||||
return value;
|
return value;
|
||||||
@@ -478,7 +466,7 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public T[] ToArray()
|
public T[] ToArray()
|
||||||
{
|
{
|
||||||
T[] newArray = new T[Count];
|
var newArray = new T[Count];
|
||||||
CopyToInternal(newArray, 0);
|
CopyToInternal(newArray, 0);
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
@@ -553,24 +541,15 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IList<ArraySegment<T>> ToArraySegments()
|
public IList<ArraySegment<T>> ToArraySegments() => new[] {ArrayOne(), ArrayTwo()};
|
||||||
{
|
|
||||||
return new[] {ArrayOne(), ArrayTwo()};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
|
#if (NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public SpanTuple<T> ToSpan()
|
public SpanTuple<T> ToSpan() => new(SpanOne(), SpanTwo());
|
||||||
{
|
|
||||||
return new SpanTuple<T>(SpanOne(), SpanTwo());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public (ReadOnlyMemory<T> A, ReadOnlyMemory<T> B) ToMemory()
|
public (ReadOnlyMemory<T> A, ReadOnlyMemory<T> B) ToMemory() => (MemoryOne(), MemoryTwo());
|
||||||
{
|
|
||||||
return (MemoryOne(), MemoryTwo());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -583,11 +562,11 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
var segments = ToArraySegments();
|
var segments = ToArraySegments();
|
||||||
foreach (ArraySegment<T> segment in segments)
|
foreach (var segment in segments)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < segment.Count; i++)
|
for (var i = 0; i < segment.Count; i++)
|
||||||
{
|
{
|
||||||
yield return segment.Array[segment.Offset + i];
|
yield return segment.Array![segment.Offset + i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -596,24 +575,15 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
|
|
||||||
#region IEnumerable implementation
|
#region IEnumerable implementation
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
{
|
|
||||||
return (IEnumerator) GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if (NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
|
#if (NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
|
||||||
|
|
||||||
private void CopyToInternal(T[] array, int index)
|
private void CopyToInternal(T[] array, int index) => CopyToInternal(array.AsSpan(index));
|
||||||
{
|
|
||||||
CopyToInternal(array.AsSpan(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyToInternal(Memory<T> memory)
|
private void CopyToInternal(Memory<T> memory) => CopyToInternal(memory.Span);
|
||||||
{
|
|
||||||
CopyToInternal(memory.Span);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyToInternal(Span<T> span)
|
private void CopyToInternal(Span<T> span)
|
||||||
{
|
{
|
||||||
@@ -639,10 +609,10 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
{
|
{
|
||||||
var segments = ToArraySegments();
|
var segments = ToArraySegments();
|
||||||
var segment = segments[0];
|
var segment = segments[0];
|
||||||
Array.Copy(segment.Array, segment.Offset, array, index, segment.Count);
|
Array.Copy(segment.Array!, segment.Offset, array, index, segment.Count);
|
||||||
index += segment.Count;
|
index += segment.Count;
|
||||||
segment = segments[1];
|
segment = segments[1];
|
||||||
Array.Copy(segment.Array, segment.Offset, array, index, segment.Count);
|
Array.Copy(segment.Array!, segment.Offset, array, index, segment.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThrowIfEmpty(string message = "Cannot access an empty buffer.")
|
private void ThrowIfEmpty(string message = "Cannot access an empty buffer.")
|
||||||
@@ -690,10 +660,7 @@ public class CircularBuffer<T> : ICircularBuffer<T>
|
|||||||
/// <param name='index'>
|
/// <param name='index'>
|
||||||
/// External index.
|
/// External index.
|
||||||
/// </param>
|
/// </param>
|
||||||
private int InternalIndex(int index)
|
private int InternalIndex(int index) => _start + (index < (Capacity - _start) ? index : index - Capacity);
|
||||||
{
|
|
||||||
return _start + (index < (Capacity - _start) ? index : index - Capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// doing ArrayOne and ArrayTwo methods returning ArraySegment<T> as seen here:
|
// doing ArrayOne and ArrayTwo methods returning ArraySegment<T> as seen here:
|
||||||
// http://www.boost.org/doc/libs/1_37_0/libs/circular_buffer/doc/circular_buffer.html#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d
|
// http://www.boost.org/doc/libs/1_37_0/libs/circular_buffer/doc/circular_buffer.html#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class CombineAllProperty<T, TResult> : DeclarativePropertyBase<TResult>
|
|||||||
_sources = sourcesList;
|
_sources = sourcesList;
|
||||||
_combiner = combiner;
|
_combiner = combiner;
|
||||||
|
|
||||||
var initialValueTask = _combiner(sourcesList.Select(p => p.Value));
|
var initialValueTask = _combiner(sourcesList.Select(p => p.Value)!);
|
||||||
initialValueTask.Wait();
|
initialValueTask.Wait();
|
||||||
SetNewValueSync(initialValueTask.Result);
|
SetNewValueSync(initialValueTask.Result);
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ public class CombineAllProperty<T, TResult> : DeclarativePropertyBase<TResult>
|
|||||||
private async Task Update()
|
private async Task Update()
|
||||||
{
|
{
|
||||||
var values = _sources.Select(p => p.Value);
|
var values = _sources.Select(p => p.Value);
|
||||||
var result = await _combiner(values);
|
var result = await _combiner(values!);
|
||||||
|
|
||||||
await SetNewValueAsync(result);
|
await SetNewValueAsync(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public static class DeclarativePropertyHelpers
|
|||||||
IDeclarativeProperty<T2> prop2,
|
IDeclarativeProperty<T2> prop2,
|
||||||
Func<T1, T2, Task<TResult>> func,
|
Func<T1, T2, Task<TResult>> func,
|
||||||
Action<TResult?>? setValueHook = null)
|
Action<TResult?>? setValueHook = null)
|
||||||
=> new(prop1, prop2, func, setValueHook);
|
=> new(prop1, prop2, func!, setValueHook);
|
||||||
|
|
||||||
public static CombineLatestProperty<T1, T2, T3, TResult> CombineLatest<T1, T2, T3, TResult>(
|
public static CombineLatestProperty<T1, T2, T3, TResult> CombineLatest<T1, T2, T3, TResult>(
|
||||||
IDeclarativeProperty<T1> prop1,
|
IDeclarativeProperty<T1> prop1,
|
||||||
@@ -15,7 +15,7 @@ public static class DeclarativePropertyHelpers
|
|||||||
IDeclarativeProperty<T3> prop3,
|
IDeclarativeProperty<T3> prop3,
|
||||||
Func<T1, T2, T3, Task<TResult>> func,
|
Func<T1, T2, T3, Task<TResult>> func,
|
||||||
Action<TResult?>? setValueHook = null)
|
Action<TResult?>? setValueHook = null)
|
||||||
=> new(prop1, prop2, prop3, func, setValueHook);
|
=> new(prop1, prop2, prop3, func!, setValueHook);
|
||||||
|
|
||||||
public static MergeProperty<T> Merge<T>(params IDeclarativeProperty<T>[] props)
|
public static MergeProperty<T> Merge<T>(params IDeclarativeProperty<T>[] props)
|
||||||
=> new(props);
|
=> new(props);
|
||||||
@@ -46,6 +46,7 @@ public sealed class DeclarativeProperty<T> : DeclarativePropertyBase<T>
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
// ignored
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public abstract class DeclarativePropertyBase<T> : IDeclarativeProperty<T>
|
|||||||
{
|
{
|
||||||
lock (_subscriberLock)
|
lock (_subscriberLock)
|
||||||
{
|
{
|
||||||
_subscribers.Remove(onChange);
|
_subscribers.Remove(onChange!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public abstract class DeclarativePropertyBase<T> : IDeclarativeProperty<T>
|
|||||||
IDisposable IObservable<T>.Subscribe(IObserver<T> observer)
|
IDisposable IObservable<T>.Subscribe(IObserver<T> observer)
|
||||||
=> Subscribe((v, _) =>
|
=> Subscribe((v, _) =>
|
||||||
{
|
{
|
||||||
observer.OnNext(v);
|
observer.OnNext(v!);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ public static class DeclarativePropertyExtensions
|
|||||||
public static IDeclarativeProperty<T> DistinctUntilChanged<T>(this IDeclarativeProperty<T> from)
|
public static IDeclarativeProperty<T> DistinctUntilChanged<T>(this IDeclarativeProperty<T> from)
|
||||||
=> new DistinctUntilChangedProperty<T>(from);
|
=> new DistinctUntilChangedProperty<T>(from);
|
||||||
|
|
||||||
public static IDeclarativeProperty<TTo?> Map<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, CancellationToken, Task<TTo?>> mapper)
|
public static IDeclarativeProperty<TTo> Map<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, CancellationToken, Task<TTo?>> mapper)
|
||||||
=> new MapProperty<TFrom?, TTo?>(mapper, from);
|
=> new MapProperty<TFrom?, TTo>(mapper, from);
|
||||||
|
|
||||||
public static IDeclarativeProperty<TTo?> Map<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, TTo?> mapper)
|
public static IDeclarativeProperty<TTo?> Map<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, TTo?> mapper)
|
||||||
=> new MapProperty<TFrom?, TTo?>((next, _) => Task.FromResult(mapper(next)), from);
|
=> new MapProperty<TFrom?, TTo?>((next, _) => Task.FromResult(mapper(next)), from);
|
||||||
|
|
||||||
public static async Task<IDeclarativeProperty<TTo?>> MapAsync<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, CancellationToken, Task<TTo?>> mapper)
|
public static async Task<IDeclarativeProperty<TTo>> MapAsync<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, CancellationToken, Task<TTo?>> mapper)
|
||||||
=> await MapProperty<TFrom?, TTo?>.CreateAsync(mapper, from);
|
=> await MapProperty<TFrom, TTo>.CreateAsync(mapper, from);
|
||||||
|
|
||||||
public static async Task<IDeclarativeProperty<TTo?>> MapAsync<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, TTo?> mapper)
|
public static async Task<IDeclarativeProperty<TTo?>> MapAsync<TFrom, TTo>(this IDeclarativeProperty<TFrom?> from, Func<TFrom?, TTo?> mapper)
|
||||||
=> await MapProperty<TFrom?, TTo?>.CreateAsync((next, _) => Task.FromResult(mapper(next)), from);
|
=> await MapProperty<TFrom?, TTo?>.CreateAsync((next, _) => Task.FromResult(mapper(next)), from);
|
||||||
@@ -65,38 +65,38 @@ public static class DeclarativePropertyExtensions
|
|||||||
)
|
)
|
||||||
=> new ExtractorProperty<T>(from, extractor);
|
=> new ExtractorProperty<T>(from, extractor);
|
||||||
|
|
||||||
public static IDeclarativeProperty<TCollection?> Watch<TCollection, TItem>(
|
public static IDeclarativeProperty<TCollection> Watch<TCollection, TItem>(
|
||||||
this IDeclarativeProperty<TCollection?> collection)
|
this IDeclarativeProperty<TCollection?> collection)
|
||||||
where TCollection : IList<TItem>, INotifyCollectionChanged
|
where TCollection : IList<TItem>, INotifyCollectionChanged
|
||||||
=> new CollectionRepeaterProperty<TCollection?, TItem>(collection);
|
=> new CollectionRepeaterProperty<TCollection, TItem>(collection);
|
||||||
|
|
||||||
public static IDeclarativeProperty<TCollection?> Watch<TCollection, TItem>(
|
public static IDeclarativeProperty<TCollection> Watch<TCollection, TItem>(
|
||||||
this TCollection collection)
|
this TCollection collection)
|
||||||
where TCollection : IList<TItem>, INotifyCollectionChanged
|
where TCollection : IList<TItem>, INotifyCollectionChanged
|
||||||
=> new CollectionRepeaterProperty<TCollection?, TItem>(collection);
|
=> new CollectionRepeaterProperty<TCollection, TItem>(collection);
|
||||||
|
|
||||||
public static IDeclarativeProperty<ObservableCollection<TItem>?> Watch<TItem>(
|
public static IDeclarativeProperty<ObservableCollection<TItem>> Watch<TItem>(
|
||||||
this ObservableCollection<TItem> collection)
|
this ObservableCollection<TItem> collection)
|
||||||
=> new CollectionRepeaterProperty<ObservableCollection<TItem>?, TItem>(collection);
|
=> new CollectionRepeaterProperty<ObservableCollection<TItem>, TItem>(collection);
|
||||||
|
|
||||||
public static IDeclarativeProperty<ReadOnlyObservableCollection<TItem>?> Watch<TItem>(
|
public static IDeclarativeProperty<ReadOnlyObservableCollection<TItem>> Watch<TItem>(
|
||||||
this ReadOnlyObservableCollection<TItem> collection)
|
this ReadOnlyObservableCollection<TItem> collection)
|
||||||
=> new CollectionRepeaterProperty<ReadOnlyObservableCollection<TItem>?, TItem>(collection);
|
=> new CollectionRepeaterProperty<ReadOnlyObservableCollection<TItem>, TItem>(collection);
|
||||||
|
|
||||||
|
|
||||||
public static IDeclarativeProperty<TResult?> CombineLatest<T1, T2, TResult>(
|
public static IDeclarativeProperty<TResult> CombineLatest<T1, T2, TResult>(
|
||||||
this IDeclarativeProperty<T1> prop1,
|
this IDeclarativeProperty<T1> prop1,
|
||||||
IDeclarativeProperty<T2> prop2,
|
IDeclarativeProperty<T2> prop2,
|
||||||
Func<T1, T2, Task<TResult?>> func,
|
Func<T1, T2, Task<TResult?>> func,
|
||||||
Action<TResult?>? setValueHook = null)
|
Action<TResult?>? setValueHook = null)
|
||||||
=> new CombineLatestProperty<T1,T2,TResult?>(prop1, prop2, func, setValueHook);
|
=> new CombineLatestProperty<T1,T2,TResult>(prop1, prop2, func!, setValueHook);
|
||||||
|
|
||||||
public static IDeclarativeProperty<T> Switch<T>(this IDeclarativeProperty<IDeclarativeProperty<T>?> from)
|
public static IDeclarativeProperty<T?> Switch<T>(this IDeclarativeProperty<IDeclarativeProperty<T?>?> from)
|
||||||
=> new SwitchProperty<T>(from);
|
=> new SwitchProperty<T?>(from);
|
||||||
|
|
||||||
public static IDeclarativeProperty<TResult?> CombineAll<T, TResult>(
|
public static IDeclarativeProperty<TResult> CombineAll<T, TResult>(
|
||||||
this IEnumerable<IDeclarativeProperty<T>> sources,
|
this IEnumerable<IDeclarativeProperty<T>> sources,
|
||||||
Func<IEnumerable<T>, Task<TResult?>> combiner,
|
Func<IEnumerable<T>, Task<TResult?>> combiner,
|
||||||
Action<TResult?>? setValueHook = null)
|
Action<TResult?>? setValueHook = null)
|
||||||
=> new CombineAllProperty<T,TResult?>(sources, combiner, setValueHook);
|
=> new CombineAllProperty<T,TResult>(sources, combiner, setValueHook);
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
public sealed class MapProperty<TFrom, TTo> : DeclarativePropertyBase<TTo>
|
public sealed class MapProperty<TFrom, TTo> : DeclarativePropertyBase<TTo>
|
||||||
{
|
{
|
||||||
private readonly Func<TFrom?, CancellationToken, Task<TTo?>> _mapper;
|
private readonly Func<TFrom, CancellationToken, Task<TTo>> _mapper;
|
||||||
|
|
||||||
public MapProperty(
|
public MapProperty(
|
||||||
Func<TFrom?, CancellationToken, Task<TTo?>> mapper,
|
Func<TFrom, CancellationToken, Task<TTo>> mapper,
|
||||||
IDeclarativeProperty<TFrom?> from,
|
IDeclarativeProperty<TFrom?> from,
|
||||||
Action<TTo?>? setValueHook = null) : base(setValueHook)
|
Action<TTo?>? setValueHook = null) : base(setValueHook)
|
||||||
{
|
{
|
||||||
@@ -15,16 +15,16 @@ public sealed class MapProperty<TFrom, TTo> : DeclarativePropertyBase<TTo>
|
|||||||
|
|
||||||
private async Task SetValue(TFrom? next, CancellationToken cancellationToken = default)
|
private async Task SetValue(TFrom? next, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var newValue = await _mapper(next, cancellationToken);
|
var newValue = await _mapper(next!, cancellationToken);
|
||||||
await SetNewValueAsync(newValue, cancellationToken);
|
await SetNewValueAsync(newValue, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<MapProperty<TFrom?, TTo?>> CreateAsync(
|
public static async Task<MapProperty<TFrom, TTo>> CreateAsync(
|
||||||
Func<TFrom?, CancellationToken, Task<TTo?>> mapper,
|
Func<TFrom, CancellationToken, Task<TTo>> mapper,
|
||||||
IDeclarativeProperty<TFrom?> from,
|
IDeclarativeProperty<TFrom?> from,
|
||||||
Action<TTo?>? setValueHook = null)
|
Action<TTo?>? setValueHook = null)
|
||||||
{
|
{
|
||||||
var prop = new MapProperty<TFrom?, TTo?>(mapper, from, setValueHook);
|
var prop = new MapProperty<TFrom, TTo>(mapper, from, setValueHook);
|
||||||
await prop.SetValue(from.Value);
|
await prop.SetValue(from.Value);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public sealed class Binding<TDataContext, TExpressionResult, TResult> : Property
|
|||||||
{
|
{
|
||||||
if (couldCompute)
|
if (couldCompute)
|
||||||
{
|
{
|
||||||
value = _converter(_dataContextMapper(_dataSourceView.DataContext));
|
value = _converter(_dataContextMapper(_dataSourceView.DataContext!));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TerminalUI.Extensions;
|
using TerminalUI.Extensions;
|
||||||
using TerminalUI.Models;
|
using TerminalUI.Models;
|
||||||
@@ -339,17 +340,6 @@ public sealed class Grid<T> : ChildCollectionView<Grid<T>, T>, IVisibilityChange
|
|||||||
return (x, y);
|
return (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithCalculatedSize(in RenderContext renderContext, Option<Size> size, WithSizes actionWithSizes)
|
|
||||||
{
|
|
||||||
WithCalculatedSize(renderContext, size, Helper);
|
|
||||||
|
|
||||||
object? Helper(in RenderContext renderContext1, ReadOnlySpan<int> widths, ReadOnlySpan<int> heights)
|
|
||||||
{
|
|
||||||
actionWithSizes(renderContext1, widths, heights);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TResult WithCalculatedSize<TResult>(in RenderContext renderContext, Option<Size> size, WithSizes<TResult> actionWithSizes)
|
private TResult WithCalculatedSize<TResult>(in RenderContext renderContext, Option<Size> size, WithSizes<TResult> actionWithSizes)
|
||||||
{
|
{
|
||||||
//TODO: Optimize it, dont calculate all of these, only if there is Auto value(s)
|
//TODO: Optimize it, dont calculate all of these, only if there is Auto value(s)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public sealed partial class TextBox<T> : View<TextBox<T>, T>, IFocusable, IDispl
|
|||||||
((INotifyPropertyChanged) this).PropertyChanged += OnPropertyChangedEventHandler;
|
((INotifyPropertyChanged) this).PropertyChanged += OnPropertyChangedEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPropertyChangedEventHandler(object sender, PropertyChangedEventArgs args)
|
private void OnPropertyChangedEventHandler(object? sender, PropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.PropertyName == nameof(Text))
|
if (args.PropertyName == nameof(Text))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using GeneralInputKey;
|
using GeneralInputKey;
|
||||||
using PropertyChanged.SourceGenerator;
|
using PropertyChanged.SourceGenerator;
|
||||||
@@ -14,6 +15,7 @@ namespace TerminalUI.Controls;
|
|||||||
|
|
||||||
public delegate string TextTransformer(string text, Position position, Size size);
|
public delegate string TextTransformer(string text, Position position, Size size);
|
||||||
|
|
||||||
|
[SuppressMessage("Performance", "EPS02:Non-readonly struct used as in-parameter")]
|
||||||
public abstract partial class View<TConcrete, T> : IView<T> where TConcrete : View<TConcrete, T>
|
public abstract partial class View<TConcrete, T> : IView<T> where TConcrete : View<TConcrete, T>
|
||||||
{
|
{
|
||||||
private readonly List<IDisposable> _disposables = new();
|
private readonly List<IDisposable> _disposables = new();
|
||||||
@@ -511,7 +513,6 @@ public abstract partial class View<TConcrete, T> : IView<T> where TConcrete : Vi
|
|||||||
ProcessParentKeyHandlers(keyEventArgs);
|
ProcessParentKeyHandlers(keyEventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void ProcessKeyHandlers(GeneralKeyEventArgs keyEventArgs)
|
protected void ProcessKeyHandlers(GeneralKeyEventArgs keyEventArgs)
|
||||||
{
|
{
|
||||||
foreach (var keyHandler in KeyHandlers)
|
foreach (var keyHandler in KeyHandlers)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class ConditionalTracker : ExpressionTrackerBase
|
|||||||
{
|
{
|
||||||
true => _ifTrueExpressionTracker.GetValue(),
|
true => _ifTrueExpressionTracker.GetValue(),
|
||||||
false => _ifFalseExpressionTracker.GetValue(),
|
false => _ifFalseExpressionTracker.GetValue(),
|
||||||
_ => throw new NotSupportedException($"Conditional expression must evaluate to a boolean value, but {testValue} ({testValue.GetType().Name}) is not that.")
|
_ => throw new NotSupportedException($"Conditional expression must evaluate to a boolean value, but {testValue} ({testValue?.GetType().Name}) is not that.")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public abstract class ExpressionTrackerBase : IExpressionTracker
|
|||||||
useNull = true;
|
useNull = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
useNull = true;
|
useNull = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ public static class ViewExtensions
|
|||||||
Expression<Func<TItem, TExpressionResult>> dataSourceExpression,
|
Expression<Func<TItem, TExpressionResult>> dataSourceExpression,
|
||||||
Action<bool, TExpressionResult> handler)
|
Action<bool, TExpressionResult> handler)
|
||||||
{
|
{
|
||||||
new PropertyChangedHandler<TItem, TExpressionResult>
|
_ = new PropertyChangedHandler<TItem, TExpressionResult>
|
||||||
(
|
(
|
||||||
dataSource,
|
dataSource,
|
||||||
dataSourceExpression,
|
dataSourceExpression,
|
||||||
handler
|
handler!
|
||||||
);
|
);
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public class RenderEngine : IRenderEngine
|
|||||||
private bool[,]? _updatedCells;
|
private bool[,]? _updatedCells;
|
||||||
private bool[,]? _filledCells;
|
private bool[,]? _filledCells;
|
||||||
private bool[,]? _lastFilledCells;
|
private bool[,]? _lastFilledCells;
|
||||||
private DateTime _renderRequestDetected;
|
|
||||||
private ITheme? _lastTheme;
|
private ITheme? _lastTheme;
|
||||||
|
|
||||||
public RenderEngine(IApplicationContext applicationContext, IEventLoop eventLoop)
|
public RenderEngine(IApplicationContext applicationContext, IEventLoop eventLoop)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using GeneralInputKey;
|
using TerminalUI.ConsoleDrivers;
|
||||||
using TerminalUI.ConsoleDrivers;
|
|
||||||
using TerminalUI.Controls;
|
using TerminalUI.Controls;
|
||||||
|
|
||||||
namespace TerminalUI.Traits;
|
namespace TerminalUI.Traits;
|
||||||
@@ -9,5 +8,4 @@ public interface IFocusable : IView
|
|||||||
void Focus();
|
void Focus();
|
||||||
void UnFocus();
|
void UnFocus();
|
||||||
void SetCursorPosition(IConsoleDriver consoleDriver);
|
void SetCursorPosition(IConsoleDriver consoleDriver);
|
||||||
void HandleKeyInput(GeneralKeyEventArgs keyEventArgs);
|
|
||||||
}
|
}
|
||||||
@@ -15,13 +15,13 @@ public partial class RootDriveInfo
|
|||||||
|
|
||||||
[Notify] private string? _label;
|
[Notify] private string? _label;
|
||||||
|
|
||||||
[Notify] private long _size = 0;
|
[Notify] private long _size;
|
||||||
|
|
||||||
[Notify] private long _free = 0;
|
[Notify] private long _free;
|
||||||
|
|
||||||
[Notify] private long _used = 0;
|
[Notify] private long _used;
|
||||||
|
|
||||||
[Notify] public long UsedPercentage => Size == 0 ? 0 : Used * 100 / Size;
|
public long UsedPercentage => Size == 0 ? 0 : Used * 100 / Size;
|
||||||
|
|
||||||
public FullName Path { get; }
|
public FullName Path { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -298,7 +298,9 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
|||||||
var lockObj = new object();
|
var lockObj = new object();
|
||||||
var loadingIndicatorCancellation = new CancellationTokenSource();
|
var loadingIndicatorCancellation = new CancellationTokenSource();
|
||||||
|
|
||||||
|
#pragma warning disable CS4014
|
||||||
Task.Run(async () => await DelayedLoadingIndicator());
|
Task.Run(async () => await DelayedLoadingIndicator());
|
||||||
|
#pragma warning restore CS4014
|
||||||
await LoadChildrenInternal();
|
await LoadChildrenInternal();
|
||||||
|
|
||||||
lock (lockObj)
|
lock (lockObj)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public class AdminElevationConfiguration
|
|||||||
{
|
{
|
||||||
public const string SectionName = "AdminElevation";
|
public const string SectionName = "AdminElevation";
|
||||||
public string? ServerExecutablePath { get; set; }
|
public string? ServerExecutablePath { get; set; }
|
||||||
public string LinuxElevationTool { get; set; }
|
public string LinuxElevationTool { get; set; } = null!;
|
||||||
public int? ServerPort { get; set; }
|
public int? ServerPort { get; set; }
|
||||||
public bool? StartProcess { get; set; }
|
public bool? StartProcess { get; set; }
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ public class CompressionUserCommandHandler : AggregatedUserCommandHandler
|
|||||||
IClipboardService clipboardService)
|
IClipboardService clipboardService)
|
||||||
{
|
{
|
||||||
_clipboardService = clipboardService;
|
_clipboardService = clipboardService;
|
||||||
_markedItems = appState.SelectedTab.Map(t => t?.MarkedItems).Switch();
|
_markedItems = appState.SelectedTab.Map(t => t?.MarkedItems)!.Switch();
|
||||||
_selectedItem = appState.SelectedTab.Map(t => t?.CurrentSelectedItem).Switch();
|
_selectedItem = appState.SelectedTab.Map(t => t?.CurrentSelectedItem).Switch();
|
||||||
|
|
||||||
AddCommandHandler(new IUserCommandHandler[]
|
AddCommandHandler(new IUserCommandHandler[]
|
||||||
|
|||||||
Reference in New Issue
Block a user