Skip to content

Commit

Permalink
Optional parameter in Model.ToIFC method added
Browse files Browse the repository at this point in the history
  • Loading branch information
samil-akhmedov committed Feb 6, 2024
1 parent c64bb7c commit ec31b92
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Elements.Serialization.IFC/src/IFCModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,21 @@ public static void ToIFC(this Model model,
/// <param name="model">The model to convert to an IFC document.</param>
/// <param name="stream">The stream in which to write the IFC document.</param>
/// <param name="updateElementsRepresentation">Indicates whether UpdateRepresentation should be called for all elements.</param>

/// <param name="leaveOpen">Indicates whether the underlying stream should be left open.</param>
/// <remarks>
/// This method provides two options for stream handling:
/// 1. When the stream is left open for further access (using leaveOpen: true with StreamWriter).
/// Users must ensure proper resource management and close the StreamWriter when done.
/// 2. When the StreamWriter is closed (default - using leaveOpen: false with StreamWriter), ensuring proper resource cleanup.
/// Users can reopen the stream if further access is needed (use stream.Seek(0, SeekOrigin.Begin) to reset the position).
/// </remarks>
public static void ToIFC(this Model model,
MemoryStream stream,
bool updateElementsRepresentation = true)
bool updateElementsRepresentation = true,
bool leaveOpen = false)
{
var ifc = CreateIfcDocument(model, updateElementsRepresentation);
using (var writer = new StreamWriter(stream, leaveOpen: true))
using (var writer = new StreamWriter(stream, leaveOpen: leaveOpen))
{
writer.Write(ifc.ToSTEP());
}
Expand Down

0 comments on commit ec31b92

Please sign in to comment.