Add Parent to IItem

This commit is contained in:
2022-03-31 15:51:19 +00:00
parent ad5bedf339
commit df23235ce8
7 changed files with 33 additions and 8 deletions

View File

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

View File

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

View File

@@ -9,6 +9,7 @@ namespace FileTime.Core.Models
string DisplayName { get; }
FullName? FullName { get; }
NativePath? NativePath { get; }
FullName? Parent { get; }
bool IsHidden { get; }
bool IsExists { get; }
SupportsDelete CanDelete { get; }