Skip to content

Commit

Permalink
[BMSPT-24] added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
BalintBende committed Oct 6, 2023
1 parent 0257af7 commit 42be43c
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 19 deletions.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,89 @@ is a zipped file as per the standard.
```

### As A Library
This C# NuGet library allows you to easily build up convert data into BCF files.
It gives you a straightforward API to build your BCF objects exactly how you want
in your order.

#### Installation
You can install the `BcfConverter` library via NuGet Package Manager or by adding
it to your project's .csproj file.
```
nuget install BCFConverter
```

#### Usage
##### Creating BCF objects
To create a BCF Model, you can use the BuilderCreator class to obtain a builder object.
Then, you can use various functions provided by the builder to fulfill the BCF model
objects.

**IMPORTANT:** The builder always creates BCF 3.0 models.

Here's an example:

```csharp
using BCFConverter;

// Create a markup builder
var markupBuilder = BuilderCreator.CreateMarkupBuilder();

// Build the BCF Markup
var bcfMarkup = markupBuilder
.AddTitle("Simple title")
.AddDescription("This is a description")
.AddLabel("Architecture")
.AddPriority("Critical")
.AddTopicType("Clash")
.AddTopicStatus("Active")
.AddComment(c => c
.AddComment("This is a comment")
.AddDate(DateTime.Now)
.AddAuthor("[email protected]"))
.AddViewPoint(v => v
.AddPerspectiveCamera(pCam => pCam
.AddCamera(cam => cam
.AddViewPoint(10, 10, 10))),
snapshotData) // Provide snapshot data here
.Build();

// Create a project builder
var projectBuilder = BuilderCreator.CreateProjectBuilder();

// Build the BCF Project
var project = projectBuilder
.AddProjectId("projectId")
.AddProjectName("My project")
.Build();

// Create a document builder
var documentBuilder = BuilderCreator.CreateDocumentBuilder();

// Build the BCF Document
var document = builder
.AddDocument(d => d
.AddFileName("document.pdf")
.AddDescription("This is a document"))
.Build();

// Create an extensions builder
var extBuilder = BuilderCreator.CreateExtensionsBuilder();

// Build the BCF Extensions
var extensions = builder
.AddPriority("Critical")
.AddPriority("Major")
.AddPriority("Normal")
.AddPriority("Minor")
.AddTopicType("Issue")
.AddTopicType("Fault")
.AddTopicType("Clash")
.AddTopicType("Remark")
.AddTopicLabel("Architecture")
.AddTopicLabel("Structure")
.AddTopicLabel("MEP")
.Build();
```

## File Structure

Expand Down
6 changes: 5 additions & 1 deletion bcf-converter.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<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/Rider2022.3/resharper-host/temp/Rider/vAny/CoverageData/_bcf-converter.-403555820/Snapshot/snapshot.utdcvr</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=fa33bbb3_002D98bf_002D494f_002Da627_002D44dd852087bd/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=280bc939_002D0032_002D4fa1_002Dae99_002D736eb8398293/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" 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/=ef3f158f_002D35ff_002D4426_002D8561_002D90a0b7e39c2e/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>




Expand Down
37 changes: 37 additions & 0 deletions src/bcf-converter/Builder/BuilderCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using BcfConverter.Builder.Bcf30;

namespace BcfConverter.Builder;

public static class BuilderCreator {
/// <summary>
/// Creates a new instance of `MarkupBuilder` object.
/// </summary>
/// <returns></returns>
public static MarkupBuilder CreateMarkupBuilder() {
return new MarkupBuilder();
}

/// <summary>
/// Creates a new instance of `ProjectBuilder` object.
/// </summary>
/// <returns></returns>
public static ProjectBuilder CreateProjectBuilder() {
return new ProjectBuilder();
}

/// <summary>
/// Creates a new instance of `ExtensionsBuilder` object.
/// </summary>
/// <returns></returns>
public static ExtensionsBuilder CreateExtensionsBuilder() {
return new ExtensionsBuilder();
}

/// <summary>
/// Creates a new instance of `DocumentInfoBuilder` object.
/// </summary>
/// <returns></returns>
public static DocumentInfoBuilder CreateDocumentBuilder() {
return new DocumentInfoBuilder();
}
}
7 changes: 0 additions & 7 deletions src/bcf-converter/Builder/MarkupBuilderCreator.cs

This file was deleted.

21 changes: 17 additions & 4 deletions src/bcf-converter/Converter/Bcf21/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BcfConverter.Model;
using BcfConverter.Model.Bcf21;
Expand Down Expand Up @@ -62,9 +63,21 @@ await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(
target, markups, root);
}

public async Task ToBcf(string target, ConcurrentBag<IMarkup> markups, IRoot root) {
//TODO fill root
//var root = new Root();
//await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(target, markups, root);
/// <summary>
/// The method writes the specified BCF 2.1 models to BCF 2.1 files.
/// </summary>
/// <param name="target">The target path where the BCF is written.</param>
/// <param name="markups">Array of `IMarkup` interface objects.</param>
/// <param name="root">The `IRoot` interface of the BCF, it contains all the root info.</param>
/// <returns></returns>
public async Task ToBcf(
string target,
ConcurrentBag<IMarkup> markups,
IRoot root) {
var convertedMarkups =
new ConcurrentBag<Markup>(markups.Select(m => (Markup)m));
var convertedRoot = (Root)root;
await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(
target, convertedMarkups, convertedRoot);
}
}
22 changes: 19 additions & 3 deletions src/bcf-converter/Converter/Bcf30/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using BcfConverter.Model;
using BcfConverter.Model.Bcf30;
Expand Down Expand Up @@ -60,10 +61,25 @@ public async Task JsonToBcf(string source, string target) {
var markups = await JsonConverter.ParseMarkups<Markup>(source);

// Writing bcf files
await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(target, markups, root);
await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(
target, markups, root);
}

public async Task ToBcf(string target, ConcurrentBag<IMarkup> markups, IRoot root) {
//await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(target, markups, root);
/// <summary>
/// The method writes the specified BCF 3.0 models to BCF 3.0 files.
/// </summary>
/// <param name="target">The target path where the BCF is written.</param>
/// <param name="markups">Array of `IMarkup` interface objects.</param>
/// <param name="root">The `IRoot` interface of the BCF, it contains all the root info.</param>
/// <returns></returns>
public async Task ToBcf(
string target,
ConcurrentBag<IMarkup> markups,
IRoot root) {
var convertedMarkups =
new ConcurrentBag<Markup>(markups.Select(m => (Markup)m));
var convertedRoot = (Root)root;
await BcfConverter.WriteBcf<Markup, VisualizationInfo, Root, Version>(
target, convertedMarkups, convertedRoot);
}
}
15 changes: 11 additions & 4 deletions src/bcf-converter/Converter/ConverterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ConverterContext {
/// </summary>
private IConverter Converter { get; set; }

private IBuilder<IMarkup> Builder { get; set; }
//public IBuilder<IMarkup> Builder { get; set; }

// private IMarkupBuilder _markupBuilder;

Expand All @@ -47,11 +47,11 @@ private void Init(BcfVersionEnum version) {
switch (version) {
case BcfVersionEnum.Bcf21:
Converter = new Converter.Bcf21.Converter();
Builder = new Builder.Bcf21.MarkupBuilder();
//Builder = new Builder.Bcf21.MarkupBuilder();
break;
case BcfVersionEnum.Bcf30:
Converter = new Converter.Bcf30.Converter();
Builder = new Builder.Bcf30.MarkupBuilder();
//Builder = new Builder.Bcf30.MarkupBuilder();
break;
default:
throw new ArgumentException($"Unsupported BCF version: {version}");
Expand All @@ -70,7 +70,14 @@ public async Task Convert(string source, string target) {
await Converter.JsonToBcf(source, target)!;
}

internal Task ToBcf(string target, ConcurrentBag<IMarkup> markups, IRoot root) {
/// <summary>
/// The method writes the specified BCF models to BCF files.
/// </summary>
/// <param name="target">The target path where the BCF is written.</param>
/// <param name="markups">Array of `IMarkup` interface objects.</param>
/// <param name="root">The `IRoot` interface of the BCF, it contains all the root info.</param>
/// <returns></returns>
public Task ToBcf(string target, ConcurrentBag<IMarkup> markups, IRoot root) {
return Converter.ToBcf(target, markups, root);
}
}
7 changes: 7 additions & 0 deletions src/bcf-converter/Converter/IConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@ public interface IConverter {
/// <returns></returns>
Task JsonToBcf(string source, string target);

/// <summary>
/// The method writes the specified BCF models to BCF files.
/// </summary>
/// <param name="target">The target path where the BCF is written.</param>
/// <param name="markups">Array of `IMarkup` interface objects.</param>
/// <param name="root">The `IRoot` interface of the BCF, it contains all the root info.</param>
/// <returns></returns>
Task ToBcf(string target, ConcurrentBag<IMarkup> markups, IRoot root);
}
5 changes: 5 additions & 0 deletions src/bcf-converter/Model/Bcf21/Bcf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace BcfConverter.Model.Bcf21;

public class Bcf {

}
5 changes: 5 additions & 0 deletions src/bcf-converter/Model/IBcf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace BcfConverter.Model;

public class IBcf {

}

0 comments on commit 42be43c

Please sign in to comment.