rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
+17 -7
View File
@@ -3,14 +3,24 @@ using Newtonsoft.Json.Bson;
namespace adas_core.Domain.Utils;
/// <summary>
/// Provides extension methods for JSON-related operations.
/// </summary>
public static class JsonExtensions
{
/// <summary>
/// Reads JSON content from the specified input file and writes it as BSON to the output file.
/// By default, uses <see cref="FileMode.CreateNew"/>, which requires the output file to not already exist.
/// </summary>
/// <param name="inputPath">The path to the source JSON file to read from.</param>
/// <param name="outputPath">The path to the destination BSON file to write to.</param>
/// <param name="fileMode">The file mode used to open the output file. Defaults to <see cref="FileMode.CreateNew"/>.</param>
public static void CopyToBson(string inputPath, string outputPath, FileMode fileMode = FileMode.CreateNew)
{
using var textReader = File.OpenText(inputPath);
using var jsonReader = new JsonTextReader(textReader);
using var oFileStream = new FileStream(outputPath, fileMode);
using var dataWriter = new BsonDataWriter(oFileStream);
dataWriter.WriteToken(jsonReader);
}
{
using var textReader = File.OpenText(inputPath);
using var jsonReader = new JsonTextReader(textReader);
using var oFileStream = new FileStream(outputPath, fileMode);
using var dataWriter = new BsonDataWriter(oFileStream);
dataWriter.WriteToken(jsonReader);
}
}