67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using System.Linq;
|
|
using System.Text;
|
|
namespace ln.types.odb.ng.index
|
|
{
|
|
public class Path
|
|
{
|
|
public String Element { get; }
|
|
public Path Next { get; }
|
|
public Path Parent { get; }
|
|
|
|
private Path(Path parent,IEnumerator<string> path)
|
|
{
|
|
Parent = parent;
|
|
|
|
if (path.MoveNext())
|
|
{
|
|
Element = path.Current;
|
|
Next = new Path(this,path);
|
|
}
|
|
else
|
|
{
|
|
Element = null;
|
|
Next = null;
|
|
}
|
|
}
|
|
public Path(String[] path)
|
|
:this(null,((IEnumerable<string>)path).GetEnumerator())
|
|
{
|
|
}
|
|
|
|
public string Complete
|
|
{
|
|
get
|
|
{
|
|
List<string> path = new List<string>();
|
|
Climb(path);
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append(path[0]);
|
|
path.RemoveAt(0);
|
|
|
|
foreach (String pe in path)
|
|
{
|
|
if (!pe.Equals("[]"))
|
|
sb.Append('_');
|
|
sb.Append(pe);
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
|
|
private void Climb(List<string> path)
|
|
{
|
|
if (Parent != null)
|
|
Parent.Climb(path);
|
|
if (Element != null)
|
|
path.Add(Element);
|
|
}
|
|
|
|
}
|
|
}
|