Add Parent to IItem
This commit is contained in:
@@ -3,6 +3,5 @@ namespace FileTime.Core.Models
|
||||
public static class Constants
|
||||
{
|
||||
public const char SeparatorChar = '/';
|
||||
public const string ContentProviderProtocol = "ctp://";
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace FileTime.Core.Models
|
||||
string DisplayName,
|
||||
FullName FullName,
|
||||
NativePath NativePath,
|
||||
FullName Parent,
|
||||
bool IsHidden,
|
||||
bool IsExists,
|
||||
SupportsDelete CanDelete,
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace FileTime.Core.Models
|
||||
string DisplayName,
|
||||
FullName FullName,
|
||||
NativePath NativePath,
|
||||
FullName Parent,
|
||||
bool IsHidden,
|
||||
bool IsExists,
|
||||
SupportsDelete CanDelete,
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace FileTime.Core.Services
|
||||
|
||||
public IContentProvider Provider => this;
|
||||
|
||||
public FullName? Parent => null;
|
||||
|
||||
protected ContentProviderBase(string name)
|
||||
{
|
||||
DisplayName = Name = name;
|
||||
|
||||
Reference in New Issue
Block a user