Moved PathFragments from SetupTmplCode to extra class.
This commit is contained in:
25
Creator/PathFragments.cs
Normal file
25
Creator/PathFragments.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace KattekerCreator
|
||||
{
|
||||
public class PathFragments
|
||||
{
|
||||
private readonly string[] _fragments;
|
||||
|
||||
public PathFragments(string path)
|
||||
{
|
||||
_fragments = path.Split(Path.PathSeparator);
|
||||
}
|
||||
|
||||
public int FragmentLength => _fragments.Length;
|
||||
|
||||
public override bool Equals(object obj) => string.Equals(ToString(), obj?.ToString());
|
||||
|
||||
public override int GetHashCode() => (_fragments != null ? _fragments.GetHashCode() : 0);
|
||||
|
||||
public override string ToString() => string.Join(Path.PathSeparator.ToString(), _fragments.Take(_fragments.Length - 1));
|
||||
|
||||
protected bool Equals(PathFragments other) => Equals(_fragments, other._fragments);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user