Skip to content

Commit

Permalink
[BMSPT-174] refactoring, fixed comments, added project info conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
BalintBende committed May 7, 2024
1 parent 89a9415 commit 654a1a5
Show file tree
Hide file tree
Showing 32 changed files with 121 additions and 110 deletions.
4 changes: 4 additions & 0 deletions bcf-toolkit.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<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/Rider2023.3/resharper-host/temp/Rider/vAny/CoverageData/_bcf-toolkit.-1315391344/Snapshot/snapshot.utdcvr</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=10e924f2_002Ddfad_002D4c9c_002Dbceb_002Dba57c3e92114/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution #4" 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/=1d23a89c_002D2836_002D406a_002Db3d1_002Dba9b60b999b4/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
Expand All @@ -11,6 +14,7 @@
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>


<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=f23341d3_002De9f8_002D4cc8_002Db98f_002Dd4283d5ad0db/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution #3" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>
Expand Down
6 changes: 3 additions & 3 deletions src/bcf-toolkit/Builder/Bcf21/BcfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BcfToolkit.Builder.Bcf21;
public partial class BcfBuilder : IBcfBuilder<
BcfBuilder,
MarkupBuilder,
ProjectBuilder>,
ProjectExtensionBuilder>,
IDefaultBuilder<BcfBuilder> {
private readonly Bcf _bcf = new();

Expand All @@ -20,9 +20,9 @@ public BcfBuilder AddMarkup(Action<MarkupBuilder> builder) {
return this;
}

public BcfBuilder SetProject(Action<ProjectBuilder> builder) {
public BcfBuilder SetProject(Action<ProjectExtensionBuilder> builder) {
var project =
(ProjectExtension)BuilderUtils.BuildItem<ProjectBuilder, IProject>(
(ProjectExtension)BuilderUtils.BuildItem<ProjectExtensionBuilder, IProject>(
builder);
_bcf.Project = project;
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/bcf-toolkit/Builder/Bcf21/CommentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CommentBuilder SetComment(string comment) {
return this;
}

public CommentBuilder SetViewPoint(string guid) {
public CommentBuilder SetViewPointGuid(string guid) {
_comment.Viewpoint.Guid = guid;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

namespace BcfToolkit.Builder.Bcf21;

public class ColorBuilder :
IColorBuilder<ColorBuilder, ComponentBuilder>,
IDefaultBuilder<ColorBuilder> {
public class ComponentColoringColorBuilder :
IComponentColoringColorBuilder<ComponentColoringColorBuilder, ComponentBuilder>,
IDefaultBuilder<ComponentColoringColorBuilder> {
private readonly ComponentColoringColor _color = new();

public ColorBuilder SetColor(string color) {
public ComponentColoringColorBuilder SetColor(string color) {
_color.Color = color;
return this;
}

public ColorBuilder AddComponent(Action<ComponentBuilder> builder) {
public ComponentColoringColorBuilder AddComponent(Action<ComponentBuilder> builder) {
var component =
(Component)BuilderUtils.BuildItem<ComponentBuilder, IComponent>(builder);
_color.Component.Add(component);
return this;
}

public ColorBuilder WithDefaults() {
public ComponentColoringColorBuilder WithDefaults() {
this
.SetColor("40E0D0")
.AddComponent(comp => comp.WithDefaults());
Expand Down
8 changes: 4 additions & 4 deletions src/bcf-toolkit/Builder/Bcf21/HeaderFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace BcfToolkit.Builder.Bcf21;
public class HeaderFileBuilder : IHeaderFileBuilder<HeaderFileBuilder> {
private readonly HeaderFile _file = new();

public HeaderFileBuilder SetIfcProject(string id) {
_file.IfcProject = id;
public HeaderFileBuilder SetIfcProject(string ifcProjectId) {
_file.IfcProject = ifcProjectId;
return this;
}

public HeaderFileBuilder SetIfcSpatialStructureElement(string id) {
_file.IfcSpatialStructureElement = id;
public HeaderFileBuilder SetIfcSpatialStructureElement(string ifcSpatialStructureElementId) {
_file.IfcSpatialStructureElement = ifcSpatialStructureElementId;
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/bcf-toolkit/Builder/Bcf21/Interfaces/ICommentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public interface ICommentBuilder<out TBuilder> : IBuilder<Comment> {
TBuilder SetComment(string comment);

/// <summary>
/// Returns the builder object set with the `ViewPoint`.
/// Returns the builder object set with the `ViewPoint.Guid`.
/// </summary>
/// <param name="guid">Back reference to the viewpoint GUID.</param>
/// <returns>Returns the builder object.</returns>
TBuilder SetViewPoint(string guid);
TBuilder SetViewPointGuid(string guid);

/// <summary>
/// Returns the builder object set with the `ModifiedDate`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace BcfToolkit.Builder.Bcf21.Interfaces;

public interface
IColorBuilder<out TBuilder, out TComponentBuilder>
: IBuilder<ComponentColoringColor> {
public interface IComponentColoringColorBuilder<
out TBuilder,
out TComponentBuilder> :
IBuilder<ComponentColoringColor> {
/// <summary>
/// Returns the builder object extended with `Color`. For example, 40E0D0
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ public interface IHeaderFileBuilder<out TBuilder> : IBuilder<HeaderFile> {
/// <summary>
/// Returns the builder object set with the `IfcProject`.
/// </summary>
/// <param name="id">
/// <param name="ifcProjectId">
/// `IfcGuid` Reference to the project to which this topic is related in
/// the IFC file.
/// </param>
/// <returns>Returns the builder object.</returns>
TBuilder SetIfcProject(string id);
TBuilder SetIfcProject(string ifcProjectId);

/// <summary>
/// Returns the builder object set with the `IfcSpatialStructureElement`.
/// </summary>
/// <param name="id">
/// <param name="ifcSpatialStructureElementId">
/// `IfcGuid` IfcGuid Reference to the spatial structure element, e.g.
/// IfcBuildingStorey, to which this topic is related.
/// </param>
/// <returns>Returns the builder object.</returns>
TBuilder SetIfcSpatialStructureElement(string id);
TBuilder SetIfcSpatialStructureElement(string ifcSpatialStructureElementId);

/// <summary>
/// Returns the builder object set with the `IsExternal`.
Expand Down
8 changes: 4 additions & 4 deletions src/bcf-toolkit/Builder/Bcf21/Interfaces/IMarkupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public interface IMarkupBuilder<
/// <summary>
/// Returns the builder object set with the `Index`.
/// </summary>
/// <param name="inx">Number to maintain the order of the topics.</param>
/// <param name="index">Number to maintain the order of the topics.</param>
/// <returns>Returns the builder object.</returns>
TBuilder SetIndex(int inx);
TBuilder SetIndex(int index);

/// <summary>
/// Returns the builder object extended with `Label`.
Expand Down Expand Up @@ -160,8 +160,8 @@ public interface IMarkupBuilder<
/// <param name="viewpoint">Viewpoint file name.</param>
/// <param name="snapshot">Snapshot file name.</param>
/// <param name="snapshotData">Snapshot data.</param>
/// <param name="index">Index.</param>
/// <param name="guid">Guid.</param>
/// <param name="index">Index parameter for sorting.</param>
/// <param name="guid">Guid of the viewpoint.</param>
/// <param name="builder">The builder for `ViewPoint`.</param>
/// <returns>Returns the builder object.</returns>
TBuilder AddViewPoint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BcfToolkit.Builder.Bcf21.Interfaces;

public interface IProjectBuilder<out TBuilder> : IBuilder<ProjectExtension> {
public interface IProjectExtensionBuilder<out TBuilder> : IBuilder<ProjectExtension> {
/// <summary>
/// Returns the builder object set with the `ProjectName`.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/bcf-toolkit/Builder/Bcf21/MarkupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public MarkupBuilder SetPriority(string priority) {
return this;
}

public MarkupBuilder SetIndex(int inx) {
_markup.Topic.Index = inx;
public MarkupBuilder SetIndex(int index) {
_markup.Topic.Index = index;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@

namespace BcfToolkit.Builder.Bcf21;

public partial class ProjectBuilder :
IProjectBuilder<ProjectBuilder>,
IDefaultBuilder<ProjectBuilder> {
public class ProjectExtensionBuilder :
IProjectExtensionBuilder<ProjectExtensionBuilder>,
IDefaultBuilder<ProjectExtensionBuilder> {
private readonly ProjectExtension _project = new();

public ProjectBuilder() {
public ProjectExtensionBuilder() {
_project.Project = new Project();
}

public ProjectBuilder SetProjectName(string name) {
public ProjectExtensionBuilder SetProjectName(string name) {
_project.Project.Name = name;
return this;
}

public ProjectBuilder SetProjectId(string id) {
public ProjectExtensionBuilder SetProjectId(string id) {
_project.Project.ProjectId = id;
return this;
}

public ProjectBuilder SetExtensionSchema(string schema) {
public ProjectExtensionBuilder SetExtensionSchema(string schema) {
_project.ExtensionSchema = schema;
return this;
}

public ProjectBuilder WithDefaults() {
public ProjectExtensionBuilder WithDefaults() {
this
.SetProjectId(Guid.NewGuid().ToString())
.SetExtensionSchema("extensions.xsd");
Expand Down
6 changes: 3 additions & 3 deletions src/bcf-toolkit/Builder/Bcf21/VisualizationInfoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class VisualizationInfoBuilder :
VisualizationInfoBuilder,
ComponentBuilder,
VisibilityBuilder,
ColorBuilder,
ComponentColoringColorBuilder,
OrthogonalCameraBuilder,
PerspectiveCameraBuilder,
LineBuilder,
Expand Down Expand Up @@ -42,9 +42,9 @@ public VisualizationInfoBuilder SetVisibility(
return this;
}

public VisualizationInfoBuilder AddColoring(Action<ColorBuilder> builder) {
public VisualizationInfoBuilder AddColoring(Action<ComponentColoringColorBuilder> builder) {
var color =
(ComponentColoringColor)BuilderUtils.BuildItem<ColorBuilder, IColor>(
(ComponentColoringColor)BuilderUtils.BuildItem<ComponentColoringColorBuilder, IColor>(
builder);
_visualizationInfo.Components.Coloring.Add(color);
return this;
Expand Down
6 changes: 3 additions & 3 deletions src/bcf-toolkit/Builder/Bcf30/BcfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BcfToolkit.Builder.Bcf30;
public partial class BcfBuilder : IBcfBuilder<
BcfBuilder,
MarkupBuilder,
ProjectBuilder,
ProjectInfoBuilder,
ExtensionsBuilder,
DocumentInfoBuilder>,
IDefaultBuilder<BcfBuilder> {
Expand All @@ -23,9 +23,9 @@ public BcfBuilder AddMarkup(Action<MarkupBuilder> builder) {
return this;
}

public BcfBuilder SetProject(Action<ProjectBuilder> builder) {
public BcfBuilder SetProjectInfo(Action<ProjectInfoBuilder> builder) {
var projectInfo =
BuilderUtils.BuildItem<ProjectBuilder, ProjectInfo>(builder);
BuilderUtils.BuildItem<ProjectInfoBuilder, ProjectInfo>(builder);
_bcf.Project = projectInfo;
return this;
}
Expand Down
18 changes: 10 additions & 8 deletions src/bcf-toolkit/Builder/Bcf30/BcfBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void UpdateExtensions(Topic topic) {
c.ModifiedAuthor
});

var ext = new {
var extensions = new {
topic.TopicType,
topic.TopicStatus,
topic.Priority,
Expand All @@ -73,13 +73,15 @@ private void UpdateExtensions(Topic topic) {
};

_bcf.Extensions = new Extensions();
_bcf.Extensions.TopicTypes.AddIfNotExists(ext.TopicType);
_bcf.Extensions.TopicStatuses.AddIfNotExists(ext.TopicStatus);
_bcf.Extensions.Priorities.AddIfNotExists(ext.Priority);
_bcf.Extensions.SnippetTypes.AddIfNotExists(ext.SnippetType);
_bcf.Extensions.Stages.AddIfNotExists(ext.Stage);
_bcf.Extensions.TopicTypes.AddIfNotExists(extensions.TopicType);
_bcf.Extensions.TopicStatuses.AddIfNotExists(extensions.TopicStatus);
_bcf.Extensions.Priorities.AddIfNotExists(extensions.Priority);
_bcf.Extensions.SnippetTypes.AddIfNotExists(extensions.SnippetType);
_bcf.Extensions.Stages.AddIfNotExists(extensions.Stage);

ext.Labels.ForEach(l => _bcf.Extensions.TopicLabels.AddIfNotExists(l));
ext.Users.ForEach(u => _bcf.Extensions.Users.AddIfNotExists(u));
extensions.Labels.ForEach(l =>
_bcf.Extensions.TopicLabels.AddIfNotExists(l));
extensions.Users.ForEach(u =>
_bcf.Extensions.Users.AddIfNotExists(u));
}
}
2 changes: 1 addition & 1 deletion src/bcf-toolkit/Builder/Bcf30/CommentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CommentBuilder SetComment(string comment) {
return this;
}

public CommentBuilder SetViewPoint(string? guid) {
public CommentBuilder SetViewPointGuid(string? guid) {
if (guid == null) return this;
_comment.Viewpoint ??= new CommentViewpoint();
_comment.Viewpoint.Guid = guid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace BcfToolkit.Builder.Bcf30;

public partial class ColorBuilder {
public ColorBuilder AddComponents(List<Component> components) {
public partial class ComponentColoringComponentColoringColorBuilder {
public ComponentColoringComponentColoringColorBuilder AddComponents(List<Component> components) {
components.ForEach(_color.Components.Add);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

namespace BcfToolkit.Builder.Bcf30;

public partial class ColorBuilder :
IColorBuilder<ColorBuilder, ComponentBuilder>,
IDefaultBuilder<ColorBuilder> {
public partial class ComponentColoringComponentColoringColorBuilder :
IComponentColoringColorBuilder<ComponentColoringComponentColoringColorBuilder, ComponentBuilder>,
IDefaultBuilder<ComponentColoringComponentColoringColorBuilder> {
private readonly ComponentColoringColor _color = new();

public ColorBuilder SetColor(string color) {
public ComponentColoringComponentColoringColorBuilder SetColor(string color) {
_color.Color = color;
return this;
}

public ColorBuilder AddComponent(Action<ComponentBuilder> builder) {
public ComponentColoringComponentColoringColorBuilder AddComponent(Action<ComponentBuilder> builder) {
var component =
(Component)BuilderUtils.BuildItem<ComponentBuilder, IComponent>(builder);
_color.Components.Add(component);
Expand All @@ -27,7 +27,7 @@ public ComponentColoringColor Build() {
return BuilderUtils.ValidateItem(_color);
}

public ColorBuilder WithDefaults() {
public ComponentColoringComponentColoringColorBuilder WithDefaults() {
this
.SetColor("40E0D0")
.AddComponent(comp => comp.WithDefaults());
Expand Down
3 changes: 1 addition & 2 deletions src/bcf-toolkit/Builder/Bcf30/DocumentReferenceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public DocumentReferenceBuilder SetDescription(string description) {
}

public DocumentReferenceBuilder SetDocumentGuid(string? guid) {
if (guid != null)
_documentReference.DocumentGuid = guid;
_documentReference.DocumentGuid = guid;
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions src/bcf-toolkit/Builder/Bcf30/FileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace BcfToolkit.Builder.Bcf30;
public class FileBuilder : IFileBuilder<FileBuilder> {
private readonly File _file = new();

public FileBuilder SetIfcProject(string id) {
_file.IfcProject = id;
public FileBuilder SetIfcProject(string ifcProjectId) {
_file.IfcProject = ifcProjectId;
return this;
}

public FileBuilder SetIfcSpatialStructureElement(string id) {
_file.IfcSpatialStructureElement = id;
public FileBuilder SetIfcSpatialStructureElement(string ifcSpatialStructureElementId) {
_file.IfcSpatialStructureElement = ifcSpatialStructureElementId;
return this;
}

Expand Down
Loading

0 comments on commit 654a1a5

Please sign in to comment.