Skip to content

Commit

Permalink
Merge branch 'feature/BMST-279-internal-docs' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
BalintBende committed Jul 19, 2024
2 parents 4713137 + 4cd6322 commit 5a07009
Show file tree
Hide file tree
Showing 93 changed files with 436 additions and 190 deletions.
10 changes: 9 additions & 1 deletion bcf-toolkit.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">/Users/balintbende/Library/Caches/JetBrains/Rider2024.1/resharper-host/temp/Rider/vAny/CoverageData/_bcf-toolkit.-1315391344/Snapshot/snapshot.utdcvr</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=55118c1b_002Dff37_002D4440_002Db322_002D21d585baf52f/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=00488d9b_002Ddfb9_002D47fc_002Da7da_002D60da862eab61/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>

Expand All @@ -11,9 +11,16 @@









<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/=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 Expand Up @@ -44,6 +51,7 @@







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
2 changes: 1 addition & 1 deletion src/bcf-toolkit/Converter/Bcf21/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using BcfToolkit.Utils;
using BcfToolkit.Model;
using BcfToolkit.Model.Bcf21;
using Version = BcfToolkit.Model.Bcf21.Version;
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
34 changes: 33 additions & 1 deletion src/bcf-toolkit/Model/Bcf21/MarkupExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +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 @@ -12,6 +14,36 @@ public ITopic GetTopic() {
public IViewPoint? GetFirstViewPoint() {
return Viewpoints?.FirstOrDefault();
}

public void SetViewPoints<TVisualizationInfo>(
Dictionary<string, TVisualizationInfo>? visInfos,
Dictionary<string, FileData>? snapshots) where TVisualizationInfo : IVisualizationInfo {
this.Viewpoints.ToList().ForEach(viewPoint => {
if (visInfos is not null) {
visInfos.TryGetValue(viewPoint.Viewpoint, out var visInfo);
if (visInfo is not null && visInfo is VisualizationInfo visualizationInfo)
viewPoint.VisualizationInfo = visualizationInfo;
}
if (snapshots is not null) {
snapshots.TryGetValue(viewPoint.Snapshot, out var snapshot);
if (snapshot is not null)
viewPoint.SnapshotData = snapshot;
}
});
}

public void SetViewPoint(
Dictionary<string, IVisualizationInfo> visInfos,
Dictionary<string, FileData> snapshots) {
this.Viewpoints.ToList().ForEach(viewPoint => {
visInfos.TryGetValue(viewPoint.Viewpoint, out var visInfo);
if (visInfo is not null)
viewPoint.VisualizationInfo = (VisualizationInfo)visInfo;
snapshots.TryGetValue(viewPoint.Snapshot, out var snapshot);
if (snapshot is not null)
viewPoint.SnapshotData = snapshot;
});
}
}

public partial class Topic : ITopic { }
Expand All @@ -32,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
Loading

0 comments on commit 5a07009

Please sign in to comment.