mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-12 05:58:34 +00:00
Refactored UnionObject to primarily just use BlockStatementObject for string construction
This commit is contained in:
parent
efc981579f
commit
a34992bfaa
37
OSCADSharp/OSCADSharp/BlockStatementObject.cs
Normal file
37
OSCADSharp/OSCADSharp/BlockStatementObject.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A statement that has multiple child nodes, whose ToString output
|
||||
/// is more or less just an aggregate of the children
|
||||
/// </summary>
|
||||
internal class BlockStatementObject : OSCADObject
|
||||
{
|
||||
private string outerStatement;
|
||||
private IEnumerable<OSCADObject> children;
|
||||
|
||||
internal BlockStatementObject(string outerStatement, IEnumerable<OSCADObject> children)
|
||||
{
|
||||
this.outerStatement = outerStatement;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var child in this.children)
|
||||
{
|
||||
sb.AppendLine(child.ToString());
|
||||
}
|
||||
|
||||
var formatter = new BlockFormatter(this.outerStatement, sb.ToString());
|
||||
return formatter.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,30 +9,14 @@ namespace OSCADSharp.Booleans
|
||||
/// <summary>
|
||||
/// A union of child nodes. This is the sum of all children (logical or).
|
||||
/// </summary>
|
||||
internal class Union : OSCADObject
|
||||
internal class Union : BlockStatementObject
|
||||
{
|
||||
private IEnumerable<OSCADObject> children;
|
||||
|
||||
/// <summary>
|
||||
/// Create a union that is the combination of all children
|
||||
/// </summary>
|
||||
/// <param name="children">OSCADObjects to combine</param>
|
||||
internal Union(IEnumerable<OSCADObject> children)
|
||||
internal Union(IEnumerable<OSCADObject> children) : base("union()", children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string unionCommand = "union()";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var child in this.children)
|
||||
{
|
||||
sb.AppendLine(child.ToString());
|
||||
}
|
||||
|
||||
var formatter = new BlockFormatter(unionCommand, sb.ToString());
|
||||
return formatter.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlockFormatter.cs" />
|
||||
<Compile Include="BlockStatementObject.cs" />
|
||||
<Compile Include="Booleans\Union.cs" />
|
||||
<Compile Include="OSCADObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user