File scoped namespace

This commit is contained in:
2022-05-07 19:40:54 +02:00
parent b161ded92e
commit 9bf95ebe4e
126 changed files with 2562 additions and 2598 deletions

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Behaviors
namespace FileTime.Core.Behaviors;
public interface IOnContainerEnter
{
public interface IOnContainerEnter
{
Task OnEnter();
}
Task OnEnter();
}

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Command
namespace FileTime.Core.Command;
public interface ICommand
{
public interface ICommand
{
}
}

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Command
namespace FileTime.Core.Command;
public interface ITransportationCommand : ICommand
{
public interface ITransportationCommand : ICommand
{
}
}

View File

@@ -1,9 +1,8 @@
namespace FileTime.Core.Enums
namespace FileTime.Core.Enums;
public enum AbsolutePathType
{
public enum AbsolutePathType
{
Unknown,
Container,
Element
}
Unknown,
Container,
Element
}

View File

@@ -1,9 +1,8 @@
namespace FileTime.Core.Enums
namespace FileTime.Core.Enums;
public enum SupportsDelete
{
public enum SupportsDelete
{
False,
True,
HardDeleteOnly,
}
False,
True,
HardDeleteOnly,
}

View File

@@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamicData" Version="7.6.7" />
<PackageReference Include="System.Reactive" Version="5.0.0" />

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Models
namespace FileTime.Core.Models;
public static class Constants
{
public static class Constants
{
public const char SeparatorChar = '/';
}
public const char SeparatorChar = '/';
}

View File

@@ -1,17 +1,16 @@
namespace FileTime.Core.Models
{
public record FullName(string Path)
{
public FullName? GetParent()
{
if (Path is null) return null;
namespace FileTime.Core.Models;
var pathParts = Path.TrimEnd(Constants.SeparatorChar).Split(Constants.SeparatorChar);
return pathParts.Length switch
{
> 1 => new(string.Join(Constants.SeparatorChar, pathParts.SkipLast(1))),
_ => null
};
}
public record FullName(string Path)
{
public FullName? GetParent()
{
if (Path is null) return null;
var pathParts = Path.TrimEnd(Constants.SeparatorChar).Split(Constants.SeparatorChar);
return pathParts.Length switch
{
> 1 => new(string.Join(Constants.SeparatorChar, pathParts.SkipLast(1))),
_ => null
};
}
}

View File

@@ -1,16 +1,15 @@
using FileTime.Core.Enums;
using FileTime.Core.Services;
namespace FileTime.Core.Models
{
public interface IAbsolutePath
{
IContentProvider ContentProvider { get; }
IContentProvider? VirtualContentProvider { get; }
FullName Path { get; }
AbsolutePathType Type { get; }
namespace FileTime.Core.Models;
Task<IItem> ResolveAsync(bool forceResolve = false, ItemInitializationSettings itemInitializationSettings = default);
Task<IItem?> ResolveAsyncSafe(bool forceResolve = false, ItemInitializationSettings itemInitializationSettings = default);
}
public interface IAbsolutePath
{
IContentProvider ContentProvider { get; }
IContentProvider? VirtualContentProvider { get; }
FullName Path { get; }
AbsolutePathType Type { get; }
Task<IItem> ResolveAsync(bool forceResolve = false, ItemInitializationSettings itemInitializationSettings = default);
Task<IItem?> ResolveAsyncSafe(bool forceResolve = false, ItemInitializationSettings itemInitializationSettings = default);
}

View File

@@ -1,10 +1,9 @@
using DynamicData;
namespace FileTime.Core.Models
namespace FileTime.Core.Models;
public interface IContainer : IItem
{
public interface IContainer : IItem
{
IObservable<IObservable<IChangeSet<IAbsolutePath>>?> Items { get; }
IObservable<bool> IsLoading { get; }
}
IObservable<IObservable<IChangeSet<IAbsolutePath>>?> Items { get; }
IObservable<bool> IsLoading { get; }
}

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Models
namespace FileTime.Core.Models;
public interface IElement : IItem
{
public interface IElement : IItem
{
}
}

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Models
namespace FileTime.Core.Models;
public interface IFileElement : IElement
{
public interface IFileElement : IElement
{
long Size { get; }
}
long Size { get; }
}

View File

@@ -1,23 +1,22 @@
using FileTime.Core.Enums;
using FileTime.Core.Services;
namespace FileTime.Core.Models
namespace FileTime.Core.Models;
public interface IItem
{
public interface IItem
{
string Name { get; }
string DisplayName { get; }
FullName? FullName { get; }
NativePath? NativePath { get; }
IAbsolutePath? Parent { get; }
bool IsHidden { get; }
bool IsExists { get; }
DateTime? CreatedAt { get; }
SupportsDelete CanDelete { get; }
bool CanRename { get; }
IContentProvider Provider { get; }
string? Attributes { get; }
AbsolutePathType Type { get; }
IObservable<IEnumerable<Exception>> Exceptions { get; }
}
string Name { get; }
string DisplayName { get; }
FullName? FullName { get; }
NativePath? NativePath { get; }
IAbsolutePath? Parent { get; }
bool IsHidden { get; }
bool IsExists { get; }
DateTime? CreatedAt { get; }
SupportsDelete CanDelete { get; }
bool CanRename { get; }
IContentProvider Provider { get; }
string? Attributes { get; }
AbsolutePathType Type { get; }
IObservable<IEnumerable<Exception>> Exceptions { get; }
}

View File

@@ -1,12 +1,11 @@
namespace FileTime.Core.Models
{
public readonly struct ItemInitializationSettings
{
public readonly bool SkipChildInitialization;
namespace FileTime.Core.Models;
public ItemInitializationSettings(bool skipChildInitialization)
{
SkipChildInitialization = skipChildInitialization;
}
public readonly struct ItemInitializationSettings
{
public readonly bool SkipChildInitialization;
public ItemInitializationSettings(bool skipChildInitialization)
{
SkipChildInitialization = skipChildInitialization;
}
}

View File

@@ -1,7 +1,6 @@
namespace FileTime.Core.Models
{
public record ItemsTransformator(
string Name,
Func<IEnumerable<IItem>, Task<IEnumerable<IItem>>> Transformator
);
}
namespace FileTime.Core.Models;
public record ItemsTransformator(
string Name,
Func<IEnumerable<IItem>, Task<IEnumerable<IItem>>> Transformator
);

View File

@@ -1,4 +1,3 @@
namespace FileTime.Core.Models
{
public record NativePath(string Path);
}
namespace FileTime.Core.Models;
public record NativePath(string Path);

View File

@@ -2,22 +2,21 @@ using FileTime.Core.Behaviors;
using FileTime.Core.Enums;
using FileTime.Core.Models;
namespace FileTime.Core.Services
namespace FileTime.Core.Services;
public interface IContentProvider : IContainer, IOnContainerEnter
{
public interface IContentProvider : IContainer, IOnContainerEnter
{
Task<IItem> GetItemByFullNameAsync(
FullName fullName,
bool forceResolve = false,
AbsolutePathType forceResolvePathType = AbsolutePathType.Unknown,
ItemInitializationSettings itemInitializationSettings = default);
Task<IItem> GetItemByFullNameAsync(
FullName fullName,
bool forceResolve = false,
AbsolutePathType forceResolvePathType = AbsolutePathType.Unknown,
ItemInitializationSettings itemInitializationSettings = default);
Task<IItem> GetItemByNativePathAsync(
NativePath nativePath,
bool forceResolve = false,
AbsolutePathType forceResolvePathType = AbsolutePathType.Unknown,
ItemInitializationSettings itemInitializationSettings = default);
Task<IItem> GetItemByNativePathAsync(
NativePath nativePath,
bool forceResolve = false,
AbsolutePathType forceResolvePathType = AbsolutePathType.Unknown,
ItemInitializationSettings itemInitializationSettings = default);
Task<List<IAbsolutePath>> GetItemsByContainerAsync(FullName fullName);
}
Task<List<IAbsolutePath>> GetItemsByContainerAsync(FullName fullName);
}

View File

@@ -2,18 +2,17 @@ using DynamicData;
using FileTime.Core.Models;
using InitableService;
namespace FileTime.Core.Services
{
public interface ITab : IInitable<IContainer>
{
IObservable<IContainer?> CurrentLocation { get; }
IObservable<IAbsolutePath?> CurrentSelectedItem { get; }
IObservable<IObservable<IChangeSet<IItem>>?> CurrentItems { get; }
namespace FileTime.Core.Services;
void SetCurrentLocation(IContainer newLocation);
void AddSelectedItemsTransformator(ItemsTransformator transformator);
void RemoveSelectedItemsTransformator(ItemsTransformator transformator);
void RemoveSelectedItemsTransformatorByName(string name);
void SetSelectedItem(IAbsolutePath newSelectedItem);
}
public interface ITab : IInitable<IContainer>
{
IObservable<IContainer?> CurrentLocation { get; }
IObservable<IAbsolutePath?> CurrentSelectedItem { get; }
IObservable<IObservable<IChangeSet<IItem>>?> CurrentItems { get; }
void SetCurrentLocation(IContainer newLocation);
void AddSelectedItemsTransformator(ItemsTransformator transformator);
void RemoveSelectedItemsTransformator(ItemsTransformator transformator);
void RemoveSelectedItemsTransformatorByName(string name);
void SetSelectedItem(IAbsolutePath newSelectedItem);
}