refactor(PepLib.Core): move Node classes to Utilities namespace
Node and KeyNode are INI parsing helpers used by IniConfig, not geometry types. Move from Geometry/ to Utilities/. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
namespace PepLib.Geometry
|
||||
{
|
||||
public class Node
|
||||
{
|
||||
private Node parent;
|
||||
|
||||
public List<Node> Children;
|
||||
|
||||
public Node()
|
||||
{
|
||||
Children = new List<Node>();
|
||||
}
|
||||
|
||||
public Node Parent
|
||||
{
|
||||
get { return parent; }
|
||||
set
|
||||
{
|
||||
parent = value;
|
||||
UpdateDepth();
|
||||
}
|
||||
}
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
private void UpdateDepth()
|
||||
{
|
||||
if (Parent != null)
|
||||
Level = Parent.Level + 1;
|
||||
else
|
||||
Level = 0;
|
||||
|
||||
foreach (var node in Children)
|
||||
node.Parent = this;
|
||||
}
|
||||
|
||||
public int Level { get; protected set; }
|
||||
|
||||
public void AddChild(Node node)
|
||||
{
|
||||
node.Parent = this;
|
||||
Children.Add(node);
|
||||
}
|
||||
|
||||
public void Write(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("".PadLeft(Level * 2) + this.ToString());
|
||||
|
||||
foreach (var node in Children)
|
||||
node.Write(writer);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyNode : Node
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public static KeyNode Parse(Node node)
|
||||
{
|
||||
var index = node.Value.IndexOf('=');
|
||||
|
||||
if (index == -1)
|
||||
return null;
|
||||
|
||||
return new KeyNode()
|
||||
{
|
||||
Name = node.Value.Remove(index),
|
||||
Value = node.Value.Remove(0, index + 1).Trim()
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}={1}", Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user