Skip to content

Commit

Permalink
[BMSPT-279] filedata for internal documents, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
BalintBende committed Jul 19, 2024
1 parent 62b8b2e commit 4cd6322
Show file tree
Hide file tree
Showing 90 changed files with 311 additions and 156 deletions.
7 changes: 4 additions & 3 deletions bcf-toolkit.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@






<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=87607a24_002D24bc_002D46e1_002Da035_002D28c18ba9b643/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=970b5a86_002D220f_002D4852_002Da8e2_002D88c1c17f952c/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #3" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>

<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b2d5c176_002Dc751_002D42d4_002Da842_002D3ad7ad02438d/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="WorkerTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;NUnit3x::8113526D-8A68-4E3E-B4DB-CE235875DDD1::net8.0::Tests.WorkerTests&lt;/TestId&gt;
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Builder/Bcf21/BcfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf21/Interfaces/IMarkupBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;

namespace BcfToolkit.Builder.Bcf21.Interfaces;
Expand Down Expand Up @@ -173,7 +174,7 @@ public interface IMarkupBuilder<
TBuilder AddViewPoint(
string viewpoint,
string snapshot,
string snapshotData,
FileData snapshotData,
int index,
string guid,
Action<TVisualizationInfoBuilder> builder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;

namespace BcfToolkit.Builder.Bcf21.Interfaces;
Expand Down Expand Up @@ -28,7 +29,7 @@ public interface IViewPointBuilder<out TBuilder, out TVisualizationInfoBuilder>
/// </summary>
/// <param name="snapshotData">Base64 string of snapshot data.</param>
/// <returns>Returns the builder object.</returns>
TBuilder SetSnapshotData(string snapshotData);
TBuilder SetSnapshotData(FileData snapshotData);

/// <summary>
/// Returns the builder object set with the `Index`, which is the
Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf21/MarkupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down Expand Up @@ -136,7 +137,7 @@ public MarkupBuilder AddComment(Action<CommentBuilder> builder) {
}

public MarkupBuilder AddViewPoint(string viewpoint, string snapshot,
string snapshotData, int index, string guid,
FileData snapshotData, int index, string guid,
Action<VisualizationInfoBuilder> builder) {
var visInfo =
(VisualizationInfo)BuilderUtils
Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf21/ViewPointBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BcfToolkit.Builder.Bcf21.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down Expand Up @@ -43,7 +44,7 @@ public ViewPointBuilder SetGuid(string guid) {
return this;
}

public ViewPointBuilder SetSnapshotData(string? snapshotData) {
public ViewPointBuilder SetSnapshotData(FileData? snapshotData) {
_viewPoint.SnapshotData = snapshotData;
return this;
}
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Builder/Bcf21/VisibilityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BcfToolkit.Builder.Bcf21.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Builder/Bcf21/VisualizationInfoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf21;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf30;

Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Builder/Bcf30/DocumentInfoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BcfToolkit.Builder.Bcf30.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf30;

Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf30/Interfaces/IMarkupBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;

namespace BcfToolkit.Builder.Bcf30.Interfaces;
Expand Down Expand Up @@ -173,7 +174,7 @@ public interface IMarkupBuilder<
TBuilder AddViewPoint(
string viewpoint,
string snapshot,
string snapshotData,
FileData snapshotData,
int index,
string guid,
Action<TVisualizationInfoBuilder> builder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;

namespace BcfToolkit.Builder.Bcf30.Interfaces;
Expand Down Expand Up @@ -28,7 +29,7 @@ public interface IViewPointBuilder<out TBuilder, out TVisualizationInfoBuilder>
/// </summary>
/// <param name="snapshotData">Base64 string of snapshot data.</param>
/// <returns>Returns the builder object.</returns>
TBuilder SetSnapshotData(string snapshotData);
TBuilder SetSnapshotData(FileData snapshotData);

/// <summary>
/// Returns the builder object set with the `Index`, which is the
Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf30/MarkupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BcfToolkit.Builder.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf30;

Expand Down Expand Up @@ -138,7 +139,7 @@ public MarkupBuilder AddComment(Action<CommentBuilder> builder) {
public MarkupBuilder AddViewPoint(
string viewpoint,
string snapshot,
string snapshotData,
FileData snapshotData,
int index,
string guid,
Action<VisualizationInfoBuilder> builder) {
Expand Down
3 changes: 2 additions & 1 deletion src/bcf-toolkit/Builder/Bcf30/ViewPointBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BcfToolkit.Builder.Bcf30.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf30;

Expand Down Expand Up @@ -38,7 +39,7 @@ public ViewPointBuilder SetGuid(string guid) {
return this;
}

public ViewPointBuilder SetSnapshotData(string? snapshotData) {
public ViewPointBuilder SetSnapshotData(FileData? snapshotData) {
_viewPoint.SnapshotData = snapshotData;
return this;
}
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Builder/Bcf30/VisibilityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BcfToolkit.Builder.Bcf30.Interfaces;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Builder.Bcf30;

Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Converter/Bcf21/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using BcfToolkit.Utils;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Converter.Bcf21;

Expand Down
16 changes: 5 additions & 11 deletions src/bcf-toolkit/Converter/Bcf21/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using BcfToolkit.Model.Interfaces;
using BcfToolkit.Utils;
using Version = BcfToolkit.Model.Bcf21.Version;

Expand Down Expand Up @@ -114,11 +115,9 @@ public static void SerializeAndWriteBcfToStream(
zip.CreateEntryFromObject($"{topicFolder}/viewpoint.bcfv", visInfo);

var snapshotFileName = markup.GetFirstViewPoint()?.Snapshot;
var base64String = markup.GetFirstViewPoint()?.SnapshotData;
var base64String = markup.GetFirstViewPoint()?.SnapshotData?.Data;
if (snapshotFileName == null || base64String == null) continue;
const string pattern = @"^data:image\/[a-zA-Z]+;base64,";
var result = Regex.Replace(base64String, pattern, string.Empty);
var bytes = Convert.FromBase64String(result);
var bytes = Convert.FromBase64String(base64String);
zip.CreateEntryFromBytes($"{topicFolder}/{snapshotFileName}", bytes);
}

Expand Down Expand Up @@ -190,16 +189,11 @@ public static async Task<string> SerializeAndWriteBcfToFolder(
visInfo));

var snapshotFileName = markup.GetFirstViewPoint()?.Snapshot;

var base64String = markup.GetFirstViewPoint()?.SnapshotData;

var base64String = markup.GetFirstViewPoint()?.SnapshotData?.Data;
if (snapshotFileName == null || base64String == null) continue;
const string pattern = @"^data:image\/[a-zA-Z]+;base64,";
var result = Regex.Replace(base64String,
pattern, string.Empty);
writeTasks.Add(File.WriteAllBytesAsync(
$"{topicFolder}/{snapshotFileName}",
Convert.FromBase64String(result)));
Convert.FromBase64String(base64String)));
}

writeTasks.Add(
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Converter/Bcf30/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using BcfToolkit.Utils;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;
using Version = BcfToolkit.Model.Bcf30.Version;

namespace BcfToolkit.Converter.Bcf30;
Expand Down
14 changes: 5 additions & 9 deletions src/bcf-toolkit/Converter/Bcf30/FileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Xml.Serialization;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf30;
using BcfToolkit.Model.Interfaces;
using BcfToolkit.Utils;
using File = System.IO.File;
using Version = BcfToolkit.Model.Bcf30.Version;
Expand Down Expand Up @@ -134,11 +135,9 @@ public static void SerializeAndWriteBcfToStream(IBcf bcf, ZipArchive zip,

// Write snapshot
var snapshotFileName = markup.GetFirstViewPoint()?.Snapshot;
var base64String = markup.GetFirstViewPoint()?.SnapshotData;
var base64String = markup.GetFirstViewPoint()?.SnapshotData?.Data;
if (snapshotFileName == null || base64String == null) continue;
const string pattern = @"^data:image\/[a-zA-Z]+;base64,";
var result = Regex.Replace(base64String, pattern, string.Empty);
var bytes = Convert.FromBase64String(result);
var bytes = Convert.FromBase64String(base64String);
zip.CreateEntryFromBytes($"{topicFolder}/{snapshotFileName}", bytes);
}

Expand Down Expand Up @@ -208,14 +207,11 @@ public static async Task<string> SerializeAndWriteBcfToFolder(
visInfo));

var snapshotFileName = markup.GetFirstViewPoint()?.Snapshot;
var base64String = markup.GetFirstViewPoint()?.SnapshotData;
var base64String = markup.GetFirstViewPoint()?.SnapshotData?.Data;
if (snapshotFileName == null || base64String == null) continue;
const string pattern = @"^data:image\/[a-zA-Z]+;base64,";
var result = Regex.Replace(base64String,
pattern, string.Empty);
writeTasks.Add(File.WriteAllBytesAsync(
$"{topicFolder}/{snapshotFileName}",
Convert.FromBase64String(result)));
Convert.FromBase64String(base64String)));
}

writeTasks.Add(BcfExtensions.SerializeAndWriteXmlFile(tmpFolder,
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Converter/IConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using BcfToolkit.Model;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Converter;

Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Model/Bcf21/Bcf.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf21;

Expand Down
7 changes: 4 additions & 3 deletions src/bcf-toolkit/Model/Bcf21/MarkupExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using BcfToolkit.Model.Interfaces;
using Newtonsoft.Json;

namespace BcfToolkit.Model.Bcf21;
Expand All @@ -16,7 +17,7 @@ public ITopic GetTopic() {

public void SetViewPoints<TVisualizationInfo>(
Dictionary<string, TVisualizationInfo>? visInfos,
Dictionary<string, string>? snapshots) where TVisualizationInfo : IVisualizationInfo {
Dictionary<string, FileData>? snapshots) where TVisualizationInfo : IVisualizationInfo {
this.Viewpoints.ToList().ForEach(viewPoint => {
if (visInfos is not null) {
visInfos.TryGetValue(viewPoint.Viewpoint, out var visInfo);
Expand All @@ -33,7 +34,7 @@ public void SetViewPoints<TVisualizationInfo>(

public void SetViewPoint(
Dictionary<string, IVisualizationInfo> visInfos,
Dictionary<string, string> snapshots) {
Dictionary<string, FileData> snapshots) {
this.Viewpoints.ToList().ForEach(viewPoint => {
visInfos.TryGetValue(viewPoint.Viewpoint, out var visInfo);
if (visInfo is not null)
Expand Down Expand Up @@ -63,7 +64,7 @@ public void SetVisualizationInfo(IVisualizationInfo? visInfo) {
/// </summary>
[XmlIgnore]
[JsonProperty("snapshot_data")]
public string? SnapshotData { get; set; }
public FileData? SnapshotData { get; set; }
}

public partial class HeaderFile : IHeaderFile { }
Expand Down
2 changes: 2 additions & 0 deletions src/bcf-toolkit/Model/Bcf21/ProjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf21;

public partial class ProjectExtension : IProject {
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Model/Bcf21/Root.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf21;

Expand Down
2 changes: 2 additions & 0 deletions src/bcf-toolkit/Model/Bcf21/VersionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf21;

public partial class Version : IVersion {
Expand Down
2 changes: 2 additions & 0 deletions src/bcf-toolkit/Model/Bcf21/VisInfoExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf21;

public partial class VisualizationInfo : IVisualizationInfo {
Expand Down
1 change: 1 addition & 0 deletions src/bcf-toolkit/Model/Bcf30/Bcf.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using BcfToolkit.Model.Interfaces;

namespace BcfToolkit.Model.Bcf30;

Expand Down
Loading

0 comments on commit 4cd6322

Please sign in to comment.