refactor(PepLib.Core): reorganize files into logical folder structure
Move 38 files from root directory into organized subfolders: - Enums/ (7 files): StatusType, ApplicationType, DrawingType, etc. - Geometry/ (5 files): Vector, Box, Size, Spacing, Node - Models/ (15 files): Nest, Plate, Part, Program, Report, etc. - Utilities/ (7 files): MathHelper, Tolerance, ZipHelper, etc. - Extensions/ (2 files): PartListExtensions, PlateListExtensions - Interfaces/ (1 file): IMovable Update namespaces to follow folder hierarchy (e.g., PepLib.Models). Add GlobalUsings.cs for internal backward compatibility. Update Codes/ and IO/ files with new using statements. Update PepApi.Core consumers to reference new namespaces. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
82
PepLib.Core/Geometry/Node.cs
Normal file
82
PepLib.Core/Geometry/Node.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
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