mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-24 11:38:29 +00:00
Extracted IFileWriter for OSCADObject.ToFile
Included default implementation for IFileWriter and replaceable reference in Settings.cs
This commit is contained in:
parent
4532e7b20d
commit
7e5160d701
@ -328,8 +328,8 @@ namespace OSCADSharp
|
|||||||
{
|
{
|
||||||
path += ".scad";
|
path += ".scad";
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllLines(path, new string[]
|
Settings.FileWriter.WriteAllLines(path, new string[]
|
||||||
{
|
{
|
||||||
Settings.OSCADSharpHeader,
|
Settings.OSCADSharpHeader,
|
||||||
Settings.Globals.ToString(),
|
Settings.Globals.ToString(),
|
||||||
|
|||||||
@ -42,6 +42,8 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Scripting\DefaultFileWriter.cs" />
|
||||||
|
<Compile Include="Scripting\IFileWriter.cs" />
|
||||||
<Compile Include="Ids.cs" />
|
<Compile Include="Ids.cs" />
|
||||||
<Compile Include="Scripting\StatementBuilder.cs" />
|
<Compile Include="Scripting\StatementBuilder.cs" />
|
||||||
<Compile Include="Settings.cs" />
|
<Compile Include="Settings.cs" />
|
||||||
|
|||||||
17
OSCADSharp/OSCADSharp/Scripting/DefaultFileWriter.cs
Normal file
17
OSCADSharp/OSCADSharp/Scripting/DefaultFileWriter.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Scripting
|
||||||
|
{
|
||||||
|
internal class DefaultFileWriter : IFileWriter
|
||||||
|
{
|
||||||
|
public void WriteAllLines(string path, string[] contents)
|
||||||
|
{
|
||||||
|
File.WriteAllLines(path, contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
OSCADSharp/OSCADSharp/Scripting/IFileWriter.cs
Normal file
21
OSCADSharp/OSCADSharp/Scripting/IFileWriter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Scripting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class that takes text and writes to file
|
||||||
|
/// </summary>
|
||||||
|
public interface IFileWriter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Writes lines of text to a file at the path specified
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="contents"></param>
|
||||||
|
void WriteAllLines(string path, string[] contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,5 +23,10 @@ namespace OSCADSharp
|
|||||||
/// top of OpenSCAD scripts
|
/// top of OpenSCAD scripts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Variables Globals = new Variables();
|
public static Variables Globals = new Variables();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to write scripts to file
|
||||||
|
/// </summary>
|
||||||
|
public static IFileWriter FileWriter = new DefaultFileWriter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user