diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..791b954 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/src" # Location of package manifests + schedule: + interval: "daily" + groups: + nuget-dependencies: + patterns: + - "*" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + groups: + actions-dependencies: + patterns: + - "*" \ No newline at end of file diff --git a/.github/workflows/code-ql.yml b/.github/workflows/code-ql.yml new file mode 100644 index 0000000..c92c409 --- /dev/null +++ b/.github/workflows/code-ql.yml @@ -0,0 +1,36 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dotnet-cd.yml b/.github/workflows/dotnet-cd.yml new file mode 100644 index 0000000..23fe50e --- /dev/null +++ b/.github/workflows/dotnet-cd.yml @@ -0,0 +1,84 @@ +name: .NET Continuous Deployment + +on: + push: + branches: [ master ] + paths: + - src/UniversalDiveDataFormat/** + workflow_dispatch: +jobs: + + test: + name: Test Project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Run tests + run: dotnet test --logger GitHubActions ./src/UniversalDiveDataFormat.sln + + semantic-release: + needs: test + name: Create a Package Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 # Need the full commit history for conventional commit + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.tag_version.outputs.new_tag }} + name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + - name: Create Nuget Package + run: dotnet build -c Release ./src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj && dotnet pack -c Release -p:PackageVersion=${{ steps.tag_version.outputs.new_version }} -o . ./src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj + - name: Upload Package for Publishing + uses: actions/upload-artifact@v4 + with: + name: PackedLib + path: ./*.nupkg + + + github-publish: + needs: semantic-release + name: Publish to Github + runs-on: ubuntu-latest + steps: + - name: Download built project + uses: actions/download-artifact@v4 + with: + name: PackedLib + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Push Package to GitHub + run: dotnet nuget push --api-key ${{secrets.GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/hughesjs/index.json" *.nupkg + + + nuget-publish: + needs: semantic-release + name: Publish to Nuget + runs-on: ubuntu-latest + steps: + - name: Download built project + uses: actions/download-artifact@v4 + with: + name: PackedLib + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Push Package to Nuget + run: dotnet nuget push --api-key ${{secrets.NUGET_KEY}} --source "https://api.nuget.org/v3/index.json" *.nupkg \ No newline at end of file diff --git a/.github/workflows/dotnet-ci.yml b/.github/workflows/dotnet-ci.yml new file mode 100644 index 0000000..375bafd --- /dev/null +++ b/.github/workflows/dotnet-ci.yml @@ -0,0 +1,20 @@ +name: .NET Continuous Integration + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + test: + name: Test Project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Run tests + run: dotnet test --logger GitHubActions ./src/UniversalDiveDataFormat.sln \ No newline at end of file diff --git a/README.md b/README.md index 54a98b8..ef06b99 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ This is a C# library for reading and writing the [Universal Dive Data Format](https://www.streit.cc/extern/uddf_v321/en/index.html). -Currently, the library primarily consists of the Models required to deserialize UDDF files using the [XmlSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializer?view=net-7.0). +Currently, the library primarily consists of the Models required to deserialize UDDF files using either the built-in [XmlSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializer?view=net-7.0) or the custom `UddfDeserilizer`. + +The `UddfDeserializer` resolves all links within the UDDF file and maps them onto the object graph. + +If you use the built-in `XmlSerializer`, you have to use the `LinkResolutionService` to resolve these links. Future versions might include extra services for enforcing constraints and validation. @@ -28,9 +32,7 @@ dotnet add package UniversalDiveDataFormat using System.Xml.Serialization; using UniversalDiveDataFormat.Models; -// Deserialize a complete UDDF file -var serializer = new XmlSerializer(typeof(UniversalDiveDataFormat.Models.UniversalDiveDataFormatRoot)); -var uddf = serializer.Deserialize(File.OpenRead("my_dive_log.uddf")); +UniversalDiveDataFormatRoot uddf = _uddfDeserialiser.Deserialise(xml); ``` ## Contributing diff --git a/src/UniversalDiveDataFormat/Models/BuiltTests.cs b/src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs similarity index 80% rename from src/UniversalDiveDataFormat/Models/BuiltTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs index 4774942..1c72c35 100644 --- a/src/UniversalDiveDataFormat/Models/BuiltTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs @@ -1,15 +1,15 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class BuiltTests { private const string Xml = """ - Blohm & Voss + Blohm & Voss 1943-06-14 diff --git a/src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs b/src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs similarity index 85% rename from src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs index 795363c..aff945f 100644 --- a/src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class DiveComputerAlarmTests { @@ -23,6 +23,6 @@ public void CanReadDcAlarm() DiveComputerAlarm dcAlarm = serializer.Deserialize(Xml); dcAlarm.PeriodInSeconds.ShouldBe(10.0f); dcAlarm.AlarmType.ShouldBe(1); - dcAlarm.Acknowledge.ShouldBeNull(); + dcAlarm.Acknowledge.ShouldNotBeNull(); } } \ No newline at end of file diff --git a/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs b/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs index bab50ef..66586c0 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class ExposureToAltitudeTests { diff --git a/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs b/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs index 8ea52cb..2d9134d 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class GlobalAlarmsTests { diff --git a/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs b/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs new file mode 100644 index 0000000..8a3bee3 --- /dev/null +++ b/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs @@ -0,0 +1,23 @@ +using System.Xml.Serialization; +using Shouldly; +using UniversalDiveDataFormat.ExtensionMethods; +using UniversalDiveDataFormat.Models; + +namespace UniversalDiveDataFormat.Tests.Models; + +public class LaunchingDateTests +{ + private const string Xml = """ + + 1943-06-14 + + """; + + [Fact] + public void CanReadLaunchingDate() + { + XmlSerializer serializer = new(typeof(LaunchingDate)); + LaunchingDate launchingDate = serializer.Deserialize(Xml); + launchingDate.DateTime.ShouldBe(new(1943, 6, 14)); + } +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs similarity index 85% rename from src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs index 6a3b448..5827a2a 100644 --- a/src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs @@ -1,15 +1,15 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class SetDiveComputerAlarmTimeTests { private const string Xml = """ - T14:37:00 + 2022-01-01T14:37:00 10.0 diff --git a/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs index cbdcd1d..68a1e93 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class SetDiveComputerDecoModelTests { diff --git a/src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs b/src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs similarity index 86% rename from src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs index 899465b..93e8716 100644 --- a/src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class ShipDimensionTests { @@ -13,7 +13,7 @@ public class ShipDimensionTests 12.6 5.7 123456.7 - 170000.0 + 170000.0 """; diff --git a/src/UniversalDiveDataFormat/Models/WreckTests.cs b/src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs similarity index 91% rename from src/UniversalDiveDataFormat/Models/WreckTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs index a6871dd..f18e5ac 100644 --- a/src/UniversalDiveDataFormat/Models/WreckTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class WreckTests { @@ -13,7 +13,7 @@ public class WreckTests tanker German - Blohm & Voss + Blohm & Voss 1943-06-14 @@ -25,7 +25,7 @@ public class WreckTests 123456.7 - 1985-05-24T15:46 + 1985-05-24T15:46:00 diff --git a/src/UniversalDiveDataFormat.Tests/Services/LinkResolutionServiceTests.cs b/src/UniversalDiveDataFormat.Tests/Services/LinkResolutionServiceTests.cs new file mode 100644 index 0000000..9490589 --- /dev/null +++ b/src/UniversalDiveDataFormat.Tests/Services/LinkResolutionServiceTests.cs @@ -0,0 +1,157 @@ +using System.Xml.Serialization; +using Shouldly; +using UniversalDiveDataFormat.ExtensionMethods; +using UniversalDiveDataFormat.Models; +using UniversalDiveDataFormat.Services; + +namespace UniversalDiveDataFormat.Tests.Services; + +public class LinkResolutionServiceTests +{ + private const string Xml = """ + + + + Arno's flatfeet... + flatfeet.jpg + + + + + + + +
+ +
+ + + + + + 2003-04-12 + + + Dirk + Dusel + Dr. + male + + + +
+ Duddelstr. 34 + Dortmund + 54321 + Deutschland + Nordrhein-Westfalen +
+ + deutsch + 01234/987654 + +
+ passed + + + Flatfeet don't seem to affect dive fitness :-) + + + +
+ + 2004-04-20 + + passed + +
+ + + Bronze + VDST/CMAS + + 1994-03-15 + + + + Orientation + VDST/CMAS + + 1994-03-15 + + + + Silver + VDST/CMAS + + 1997-11-26 + + + + Gold + VDST/CMAS + + 2000-05-10 + + + + + + DiveCard + Austria + + 2004-08-24 + + + 2005-08-23 + + + + Zeeland + Zeeland (The Netherlands) + + 1996-09-03:00 + + + 2001-08-31 + + + +
+ + + Bertie + Bammel + + + airsucker@deepdiving.info + http://www.deepdiving.info/bertie + + + + + Carl + Cabuff + + + lurchi@abcde.com + http://www.deepdiving.info/carl + + +
+
+ """; + + [Fact] + public void CanResolveLinks() + { + XmlSerializer serializer = new(typeof(UniversalDiveDataFormatRoot)); + UniversalDiveDataFormatRoot uddf = serializer.Deserialize(Xml); + + LinkResolutionService lrs = new(); + lrs.ResolveAllLinksInObjectGraph(uddf); + + var linkedImage = uddf.MediaData!.ImageFiles[0]; + uddf.Diver!.Owner!.Medical!.Examinations[0].Notes!.Links[0].LinkedObject.ShouldBe(linkedImage); + } +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat.Tests/Services/UddfDeserialiserTests.cs b/src/UniversalDiveDataFormat.Tests/Services/UddfDeserialiserTests.cs new file mode 100644 index 0000000..7e5e20f --- /dev/null +++ b/src/UniversalDiveDataFormat.Tests/Services/UddfDeserialiserTests.cs @@ -0,0 +1,188 @@ +using System.Text; +using Shouldly; +using UniversalDiveDataFormat.Models; +using UniversalDiveDataFormat.Services; + +namespace UniversalDiveDataFormat.Tests.Services; + +public class UddfDeserialiserTests +{ + private readonly UddfDeserialiser _uddfDeserialiser; + + public UddfDeserialiserTests() + { + _uddfDeserialiser = new(new()); + } + + [Fact] + public void LinksAreResolvedWhenDeserialising() + { + const string xml = """ + + + + Arno's flatfeet... + flatfeet.jpg + + + + + + + +
+ +
+ + + + + + 2003-04-12 + + + Dirk + Dusel + Dr. + male + + + +
+ Duddelstr. 34 + Dortmund + 54321 + Deutschland + Nordrhein-Westfalen +
+ + deutsch + 01234/987654 + +
+ passed + + + Flatfeet don't seem to affect dive fitness :-) + + + +
+ + 2004-04-20 + + passed + +
+ + + Bronze + VDST/CMAS + + 1994-03-15 + + + + Orientation + VDST/CMAS + + 1994-03-15 + + + + Silver + VDST/CMAS + + 1997-11-26 + + + + Gold + VDST/CMAS + + 2000-05-10 + + + + + + DiveCard + Austria + + 2004-08-24 + + + 2005-08-23 + + + + Zeeland + Zeeland (The Netherlands) + + 1996-09-03:00 + + + 2001-08-31 + + + +
+ + + Bertie + Bammel + + + airsucker@deepdiving.info + http://www.deepdiving.info/bertie + + + + + Carl + Cabuff + + + lurchi@abcde.com + http://www.deepdiving.info/carl + + +
+
+ """; + + UniversalDiveDataFormatRoot uddf = _uddfDeserialiser.Deserialise(xml); + Image linkedImage = uddf.MediaData!.ImageFiles[0]; + uddf.Diver!.Owner.Medical!.Examinations[0].Notes!.Links[0].LinkedObject.ShouldBe(linkedImage); + } + + [Fact] + public void CanDeserialiseFromStream() + { + const string xml = """ + + + + + + """; + using MemoryStream stream = new(Encoding.UTF8.GetBytes(xml)); + UniversalDiveDataFormatRoot uddf = _uddfDeserialiser.Deserialise(stream); + uddf.ShouldNotBeNull(); + uddf.MediaData.ShouldNotBeNull(); + } + + [Fact] + public void CanDeserialiseNonRootObject() + { + const string xml = """ + + Arno's flatfeet... + flatfeet.jpg + + """; + Image image = _uddfDeserialiser.Deserialise(xml); + image.Id.ShouldBe("img_flatfeet"); + image.ObjectName.ShouldBe("flatfeet.jpg"); + } +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj b/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj index 6fee83b..dff3c56 100644 --- a/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj +++ b/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj @@ -11,6 +11,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/UniversalDiveDataFormat/Models/Abundance.cs b/src/UniversalDiveDataFormat/Models/Abundance.cs index 9399050..84e784c 100644 --- a/src/UniversalDiveDataFormat/Models/Abundance.cs +++ b/src/UniversalDiveDataFormat/Models/Abundance.cs @@ -1,10 +1,9 @@ -using System.Globalization; using System.Xml.Serialization; namespace UniversalDiveDataFormat.Models; [XmlRoot("abundance")] -public class Abundance +public class Abundance: UddfModel { [XmlAttribute("quality")] public Quality Quality { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Accommodation.cs b/src/UniversalDiveDataFormat/Models/Accommodation.cs index 39c8084..c92077c 100644 --- a/src/UniversalDiveDataFormat/Models/Accommodation.cs +++ b/src/UniversalDiveDataFormat/Models/Accommodation.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("accommodation")] -public class Accommodation +public class Accommodation: UddfModel { [XmlElement("name")] public required string Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Acknowledge.cs b/src/UniversalDiveDataFormat/Models/Acknowledge.cs index a7e9355..8317c0c 100644 --- a/src/UniversalDiveDataFormat/Models/Acknowledge.cs +++ b/src/UniversalDiveDataFormat/Models/Acknowledge.cs @@ -3,4 +3,4 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("acknowledge")] -public class Acknowledge; \ No newline at end of file +public class Acknowledge: UddfModel; \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Address.cs b/src/UniversalDiveDataFormat/Models/Address.cs index d68bf83..b8051a2 100644 --- a/src/UniversalDiveDataFormat/Models/Address.cs +++ b/src/UniversalDiveDataFormat/Models/Address.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("address")] -public class Address +public class Address: UddfModel { [XmlElement("street")] public string? Street { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/AlcoholBeforeDive.cs b/src/UniversalDiveDataFormat/Models/AlcoholBeforeDive.cs index 53f9d95..dbeb601 100644 --- a/src/UniversalDiveDataFormat/Models/AlcoholBeforeDive.cs +++ b/src/UniversalDiveDataFormat/Models/AlcoholBeforeDive.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("alcoholbeforedive")] -public class AlcoholBeforeDive +public class AlcoholBeforeDive: UddfModel { [XmlElement("drink")] public List Drinks { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/AnySymptoms.cs b/src/UniversalDiveDataFormat/Models/AnySymptoms.cs index 1e5de04..3c210e3 100644 --- a/src/UniversalDiveDataFormat/Models/AnySymptoms.cs +++ b/src/UniversalDiveDataFormat/Models/AnySymptoms.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("anysymptoms")] -public class AnySymptoms +public class AnySymptoms: UddfModel { [XmlElement("notes")] public Notes? Notes { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Ascent.cs b/src/UniversalDiveDataFormat/Models/Ascent.cs index e03332f..16b1ace 100644 --- a/src/UniversalDiveDataFormat/Models/Ascent.cs +++ b/src/UniversalDiveDataFormat/Models/Ascent.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("ascent")] -public class Ascent +public class Ascent: UddfModel { [XmlElement("waypoint")] public List Waypoints { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Audio.cs b/src/UniversalDiveDataFormat/Models/Audio.cs index 8819bc8..8427b27 100644 --- a/src/UniversalDiveDataFormat/Models/Audio.cs +++ b/src/UniversalDiveDataFormat/Models/Audio.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("audio")] -public class Audio: ILinkable +public class Audio: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("objectname")] public required string ObjectName { get; init; } [XmlElement("title")] diff --git a/src/UniversalDiveDataFormat/Models/BirthDate.cs b/src/UniversalDiveDataFormat/Models/BirthDate.cs index 87fa805..cdfafe5 100644 --- a/src/UniversalDiveDataFormat/Models/BirthDate.cs +++ b/src/UniversalDiveDataFormat/Models/BirthDate.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("birthdate")] -public class BirthDate +public class BirthDate: UddfModel { [XmlElement("datetime")] public required DateTime DateTime { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/BottomTimeTable.cs b/src/UniversalDiveDataFormat/Models/BottomTimeTable.cs index 2ef773f..8d1877c 100644 --- a/src/UniversalDiveDataFormat/Models/BottomTimeTable.cs +++ b/src/UniversalDiveDataFormat/Models/BottomTimeTable.cs @@ -1,13 +1,14 @@ using System.Xml; using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("bottomtimetable")] -public class BottomTimeTable: ILinkable +public class BottomTimeTable: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("link")] public List Links { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/BottomTimeTableScope.cs b/src/UniversalDiveDataFormat/Models/BottomTimeTableScope.cs index 197654a..06ab45d 100644 --- a/src/UniversalDiveDataFormat/Models/BottomTimeTableScope.cs +++ b/src/UniversalDiveDataFormat/Models/BottomTimeTableScope.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("bottomtimetablescope")] -public class BottomTimeTableScope +public class BottomTimeTableScope: UddfModel { [XmlElement("breathingconsumptionvolumebegin")] public required float BreathingConsumptionVolumeBeginInCubicMetersPerSecond { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Buehlmann.cs b/src/UniversalDiveDataFormat/Models/Buehlmann.cs index 3b0e46e..eb6f786 100644 --- a/src/UniversalDiveDataFormat/Models/Buehlmann.cs +++ b/src/UniversalDiveDataFormat/Models/Buehlmann.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("buehlmann")] -public class Buehlmann: ILinkable +public class Buehlmann: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("gradientfactorhigh")] public float? GradientFactorHigh { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Built.cs b/src/UniversalDiveDataFormat/Models/Built.cs index a4a3311..f3ab580 100644 --- a/src/UniversalDiveDataFormat/Models/Built.cs +++ b/src/UniversalDiveDataFormat/Models/Built.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("built")] -public class Built +public class Built: UddfModel { [XmlElement("shipyard")] public string? Shipyard { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Business.cs b/src/UniversalDiveDataFormat/Models/Business.cs index ecd7ac2..99dfd60 100644 --- a/src/UniversalDiveDataFormat/Models/Business.cs +++ b/src/UniversalDiveDataFormat/Models/Business.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("business")] -public class Business +public class Business: UddfModel { [XmlElement("shop")] public List Shops { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/CalculateBottomTimeTable.cs b/src/UniversalDiveDataFormat/Models/CalculateBottomTimeTable.cs index 2d5a491..2c5fd63 100644 --- a/src/UniversalDiveDataFormat/Models/CalculateBottomTimeTable.cs +++ b/src/UniversalDiveDataFormat/Models/CalculateBottomTimeTable.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("calculatebottomtimetable")] -public class CalculateBottomTimeTable +public class CalculateBottomTimeTable: UddfModel { [XmlElement("bottomtimetable")] public List BottomTimeTables { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/CalculateProfile.cs b/src/UniversalDiveDataFormat/Models/CalculateProfile.cs index 37bd4f3..492021d 100644 --- a/src/UniversalDiveDataFormat/Models/CalculateProfile.cs +++ b/src/UniversalDiveDataFormat/Models/CalculateProfile.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("calculateprofile")] -public class CalculateProfile +public class CalculateProfile: UddfModel { [XmlElement("profile")] public List Profiles { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/CalculateTable.cs b/src/UniversalDiveDataFormat/Models/CalculateTable.cs index 3a0b7ce..cdcb8ad 100644 --- a/src/UniversalDiveDataFormat/Models/CalculateTable.cs +++ b/src/UniversalDiveDataFormat/Models/CalculateTable.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("calculatetable")] -public class CalculateTable +public class CalculateTable: UddfModel { [XmlElement("table")] public List Tables { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Camera.cs b/src/UniversalDiveDataFormat/Models/Camera.cs index 309b6bc..5a66bcd 100644 --- a/src/UniversalDiveDataFormat/Models/Camera.cs +++ b/src/UniversalDiveDataFormat/Models/Camera.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("camera")] -public class Camera: ILinkable +public class Camera: UddfModel, ILinkable { [XmlAttribute("id")] public required string Id{ get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Certification.cs b/src/UniversalDiveDataFormat/Models/Certification.cs index 59a0cf8..024bbee 100644 --- a/src/UniversalDiveDataFormat/Models/Certification.cs +++ b/src/UniversalDiveDataFormat/Models/Certification.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("certification")] -public class Certification +public class Certification: UddfModel { [XmlElement("level")] public string? Level { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Contact.cs b/src/UniversalDiveDataFormat/Models/Contact.cs index f8a1874..58c8f72 100644 --- a/src/UniversalDiveDataFormat/Models/Contact.cs +++ b/src/UniversalDiveDataFormat/Models/Contact.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("contact")] -public class Contact +public class Contact: UddfModel { [XmlElement("email")] public List Emails { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DateOfFlight.cs b/src/UniversalDiveDataFormat/Models/DateOfFlight.cs index 7801906..50167d2 100644 --- a/src/UniversalDiveDataFormat/Models/DateOfFlight.cs +++ b/src/UniversalDiveDataFormat/Models/DateOfFlight.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("dateofflight")] -public class DateOfFlight +public class DateOfFlight: UddfModel { [XmlElement("datetime")] public DateTime? DateTime { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DateOfTrip.cs b/src/UniversalDiveDataFormat/Models/DateOfTrip.cs index 1edbe14..3a982ef 100644 --- a/src/UniversalDiveDataFormat/Models/DateOfTrip.cs +++ b/src/UniversalDiveDataFormat/Models/DateOfTrip.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("dateoftrip")] -public class DateOfTrip +public class DateOfTrip: UddfModel { [XmlAttribute("startdate")] public required DateTime StartDate { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DecoModel.cs b/src/UniversalDiveDataFormat/Models/DecoModel.cs index cd8346d..bf512df 100644 --- a/src/UniversalDiveDataFormat/Models/DecoModel.cs +++ b/src/UniversalDiveDataFormat/Models/DecoModel.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("decomodel")] -public class DecoModel +public class DecoModel: UddfModel { [XmlElement("buehlmann")] public List BuehlmannModels { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Descent.cs b/src/UniversalDiveDataFormat/Models/Descent.cs index c070959..b214b43 100644 --- a/src/UniversalDiveDataFormat/Models/Descent.cs +++ b/src/UniversalDiveDataFormat/Models/Descent.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("descent")] -public class Descent +public class Descent: UddfModel { [XmlElement("waypoint")] public List Waypoints { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Dive.cs b/src/UniversalDiveDataFormat/Models/Dive.cs index 1110688..1d9bdb7 100644 --- a/src/UniversalDiveDataFormat/Models/Dive.cs +++ b/src/UniversalDiveDataFormat/Models/Dive.cs @@ -1,13 +1,14 @@ using System.Xml; using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("dive")] -public class Dive : ILinkable +public class Dive: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("link")] public List Links { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DiveBase.cs b/src/UniversalDiveDataFormat/Models/DiveBase.cs index 13559c1..f8bad11 100644 --- a/src/UniversalDiveDataFormat/Models/DiveBase.cs +++ b/src/UniversalDiveDataFormat/Models/DiveBase.cs @@ -1,12 +1,13 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("divebase")] -public class DiveBase : ILinkable +public class DiveBase: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("name")] public required string Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DiveComputerAlarm.cs b/src/UniversalDiveDataFormat/Models/DiveComputerAlarm.cs index 26acbc2..db4107b 100644 --- a/src/UniversalDiveDataFormat/Models/DiveComputerAlarm.cs +++ b/src/UniversalDiveDataFormat/Models/DiveComputerAlarm.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("dcalarm")] -public class DiveComputerAlarm +public class DiveComputerAlarm: UddfModel { [XmlElement("acknowledge")] public Acknowledge? Acknowledge { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DiveComputerControl.cs b/src/UniversalDiveDataFormat/Models/DiveComputerControl.cs index 867c73a..c4195ab 100644 --- a/src/UniversalDiveDataFormat/Models/DiveComputerControl.cs +++ b/src/UniversalDiveDataFormat/Models/DiveComputerControl.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("divecomputercontrol")] -public class DiveComputerControl +public class DiveComputerControl: UddfModel { [XmlElement("divecomputerdump")] public List DiveComputerDumps { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DiveComputerDump.cs b/src/UniversalDiveDataFormat/Models/DiveComputerDump.cs index 0d8fdf9..25ad45e 100644 --- a/src/UniversalDiveDataFormat/Models/DiveComputerDump.cs +++ b/src/UniversalDiveDataFormat/Models/DiveComputerDump.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("divecomputerdump")] -public class DiveComputerDump +public class DiveComputerDump: UddfModel { [XmlElement("datetime")] public DateTime? DateTime { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DiveInsurances.cs b/src/UniversalDiveDataFormat/Models/DiveInsurances.cs index 28f0e92..7ad9282 100644 --- a/src/UniversalDiveDataFormat/Models/DiveInsurances.cs +++ b/src/UniversalDiveDataFormat/Models/DiveInsurances.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("diveinsurances")] -public class DiveInsurances +public class DiveInsurances: UddfModel { [XmlElement("insurance")] public List Insurances { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DivePermissions.cs b/src/UniversalDiveDataFormat/Models/DivePermissions.cs index eedd99a..5fc17b6 100644 --- a/src/UniversalDiveDataFormat/Models/DivePermissions.cs +++ b/src/UniversalDiveDataFormat/Models/DivePermissions.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("divepermissions")] -public class DivePermissions +public class DivePermissions: UddfModel { [XmlElement("permit")] public List Permits { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DiveSite.cs b/src/UniversalDiveDataFormat/Models/DiveSite.cs index 6e46c15..8ad1988 100644 --- a/src/UniversalDiveDataFormat/Models/DiveSite.cs +++ b/src/UniversalDiveDataFormat/Models/DiveSite.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("divesite")] -public class DiveSite +public class DiveSite: UddfModel { [XmlElement("site")] public List Sites { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/DiveTrips.cs b/src/UniversalDiveDataFormat/Models/DiveTrips.cs index c337e2e..c4a4058 100644 --- a/src/UniversalDiveDataFormat/Models/DiveTrips.cs +++ b/src/UniversalDiveDataFormat/Models/DiveTrips.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("divetrip")] -public class DiveTrips +public class DiveTrips: UddfModel { [XmlElement("trip")] public List Trips { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Diver.cs b/src/UniversalDiveDataFormat/Models/Diver.cs index 8b4f5a9..e3d7777 100644 --- a/src/UniversalDiveDataFormat/Models/Diver.cs +++ b/src/UniversalDiveDataFormat/Models/Diver.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("diver")] -public class Diver +public class Diver: UddfModel { [XmlElement("owner")] public required Owner Owner { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/DiverDetails.cs b/src/UniversalDiveDataFormat/Models/DiverDetails.cs index 991a54d..36fa29b 100644 --- a/src/UniversalDiveDataFormat/Models/DiverDetails.cs +++ b/src/UniversalDiveDataFormat/Models/DiverDetails.cs @@ -2,10 +2,10 @@ namespace UniversalDiveDataFormat.Models; -public abstract class DiverDetails : ILinkable +public abstract class DiverDetails: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("address")] public Address? Address { get; init; } @@ -44,10 +44,10 @@ public abstract class DiverDetails : ILinkable } [XmlRoot("buddy")] -public class Buddy : DiverDetails; +public class Buddy: DiverDetails; [XmlRoot("owner")] -public class Owner : DiverDetails; +public class Owner: DiverDetails; [XmlRoot("student")] -public class Student; \ No newline at end of file +public class Student: UddfModel; \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Doctor.cs b/src/UniversalDiveDataFormat/Models/Doctor.cs index c183f8e..5fe382c 100644 --- a/src/UniversalDiveDataFormat/Models/Doctor.cs +++ b/src/UniversalDiveDataFormat/Models/Doctor.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("doctor")] -public class Doctor: ILinkable +public class Doctor: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("address")] public Address? Address { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Drug.cs b/src/UniversalDiveDataFormat/Models/Drug.cs index a87282a..eeb5b20 100644 --- a/src/UniversalDiveDataFormat/Models/Drug.cs +++ b/src/UniversalDiveDataFormat/Models/Drug.cs @@ -2,7 +2,7 @@ namespace UniversalDiveDataFormat.Models; -public abstract class Drug +public abstract class Drug: UddfModel { [XmlElement("aliasname")] public List AliasNames { get; init; } = []; @@ -21,8 +21,8 @@ public abstract class Drug } [XmlRoot("drink")] -public class Drink : Drug; +public class Drink: Drug; [XmlRoot("medicine")] -public class Medicine : Drug; \ No newline at end of file +public class Medicine: Drug; \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Ecology.cs b/src/UniversalDiveDataFormat/Models/Ecology.cs index 37b5512..c7b7419 100644 --- a/src/UniversalDiveDataFormat/Models/Ecology.cs +++ b/src/UniversalDiveDataFormat/Models/Ecology.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("ecology")] -public class Ecology +public class Ecology: UddfModel { [XmlElement("flora")] public Flora? Flora { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Education.cs b/src/UniversalDiveDataFormat/Models/Education.cs index 3871270..2bf3672 100644 --- a/src/UniversalDiveDataFormat/Models/Education.cs +++ b/src/UniversalDiveDataFormat/Models/Education.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("education")] -public class Education +public class Education: UddfModel { [XmlElement("certification")] public required List Certifications { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Equipment.cs b/src/UniversalDiveDataFormat/Models/Equipment.cs index 8b37303..0f55e45 100644 --- a/src/UniversalDiveDataFormat/Models/Equipment.cs +++ b/src/UniversalDiveDataFormat/Models/Equipment.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("equipment")] -public class Equipment +public class Equipment: UddfModel { [XmlElement("boots")] public List Boots { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/EquipmentConfiguration.cs b/src/UniversalDiveDataFormat/Models/EquipmentConfiguration.cs index bf28c02..3d3d6a5 100644 --- a/src/UniversalDiveDataFormat/Models/EquipmentConfiguration.cs +++ b/src/UniversalDiveDataFormat/Models/EquipmentConfiguration.cs @@ -1,12 +1,13 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("equipmentconfiguration")] -public class EquipmentConfiguration : ILinkable +public class EquipmentConfiguration: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("name")] public required string Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/EquipmentDetails.cs b/src/UniversalDiveDataFormat/Models/EquipmentDetails.cs index 128ed2b..70d42b0 100644 --- a/src/UniversalDiveDataFormat/Models/EquipmentDetails.cs +++ b/src/UniversalDiveDataFormat/Models/EquipmentDetails.cs @@ -1,11 +1,12 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; -public abstract class EquipmentDetails : ILinkable +public abstract class EquipmentDetails: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("name")] public required string Name { get; init; } @@ -40,56 +41,56 @@ public abstract class EquipmentDetails : ILinkable } [XmlRoot("buoyancycontroldevice")] -public class BuoyancyControlDevice : EquipmentDetails; +public class BuoyancyControlDevice: EquipmentDetails; [XmlRoot("boots")] -public class Boots : EquipmentDetails; +public class Boots: EquipmentDetails; [XmlRoot("compass")] -public class Compass : EquipmentDetails; +public class Compass: EquipmentDetails; [XmlRoot("compressor")] -public class Compressor : EquipmentDetails; +public class Compressor: EquipmentDetails; [XmlRoot("divecomputer")] -public class DiveComputer : EquipmentDetails; +public class DiveComputer: EquipmentDetails; [XmlRoot("fins")] -public class Fins : EquipmentDetails; +public class Fins: EquipmentDetails; [XmlRoot("gloves")] -public class Gloves : EquipmentDetails; +public class Gloves: EquipmentDetails; [XmlRoot("knife")] -public class Knife : EquipmentDetails; +public class Knife: EquipmentDetails; [XmlRoot("lead")] -public class Lead : EquipmentDetails; +public class Lead: EquipmentDetails; [XmlRoot("light")] -public class Light : EquipmentDetails; +public class Light: EquipmentDetails; [XmlRoot("mask")] -public class Mask : EquipmentDetails; +public class Mask: EquipmentDetails; [XmlRoot("rebreather")] -public class Rebreather : EquipmentDetails; +public class Rebreather: EquipmentDetails; [XmlRoot("regulator")] -public class Regulator : EquipmentDetails; +public class Regulator: EquipmentDetails; [XmlRoot("scooter")] -public class Scooter : EquipmentDetails; +public class Scooter: EquipmentDetails; [XmlRoot("suit")] -public class Suit : EquipmentDetails +public class Suit: EquipmentDetails { [XmlElement("suittype")] public SuitType? SuitType { get; init; } } [XmlRoot("tank")] -public class Tank : EquipmentDetails +public class Tank: EquipmentDetails { [XmlElement("tankmaterial")] public TankMaterial? TankMaterial { get; init; } @@ -99,19 +100,19 @@ public class Tank : EquipmentDetails } [XmlRoot("variouspieces")] -public class VariousPieces : EquipmentDetails; +public class VariousPieces: EquipmentDetails; [XmlRoot("watch")] -public class Watch : EquipmentDetails; +public class Watch: EquipmentDetails; [XmlRoot("body")] public class Body: EquipmentDetails; [XmlRoot("flash")] -public class Flash : EquipmentDetails; +public class Flash: EquipmentDetails; [XmlRoot("housing")] -public class Housing : EquipmentDetails; +public class Housing: EquipmentDetails; [XmlRoot("lens")] -public class Lens : EquipmentDetails; +public class Lens: EquipmentDetails; diff --git a/src/UniversalDiveDataFormat/Models/EquipmentUsed.cs b/src/UniversalDiveDataFormat/Models/EquipmentUsed.cs index 35bcda9..6485a50 100644 --- a/src/UniversalDiveDataFormat/Models/EquipmentUsed.cs +++ b/src/UniversalDiveDataFormat/Models/EquipmentUsed.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("equipmentused")] -public class EquipmentUsed +public class EquipmentUsed: UddfModel { [XmlElement("leadquantity")] public float? LeadQuantityInKg { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/ExposureToAltitude.cs b/src/UniversalDiveDataFormat/Models/ExposureToAltitude.cs index 17e1b08..28cb9d6 100644 --- a/src/UniversalDiveDataFormat/Models/ExposureToAltitude.cs +++ b/src/UniversalDiveDataFormat/Models/ExposureToAltitude.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("exposuretoaltitude")] -public class ExposureToAltitude +public class ExposureToAltitude: UddfModel { [XmlElement("altitudeofexposure")] diff --git a/src/UniversalDiveDataFormat/Models/Fauna.cs b/src/UniversalDiveDataFormat/Models/Fauna.cs index 02598ef..adf1fb2 100644 --- a/src/UniversalDiveDataFormat/Models/Fauna.cs +++ b/src/UniversalDiveDataFormat/Models/Fauna.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("fauna")] -public class Fauna +public class Fauna: UddfModel { [XmlElement("vertebrata")] public Vertebrata? Vertebrata { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Flora.cs b/src/UniversalDiveDataFormat/Models/Flora.cs index 222bd45..7cc435c 100644 --- a/src/UniversalDiveDataFormat/Models/Flora.cs +++ b/src/UniversalDiveDataFormat/Models/Flora.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("flora")] -public class Flora +public class Flora: UddfModel { [XmlElement("chlorophyceae")] public List Chlorophyceae { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/GasDefinitions.cs b/src/UniversalDiveDataFormat/Models/GasDefinitions.cs index acc799f..31f59f6 100644 --- a/src/UniversalDiveDataFormat/Models/GasDefinitions.cs +++ b/src/UniversalDiveDataFormat/Models/GasDefinitions.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("gasdefinitions")] -public class GasDefinitions +public class GasDefinitions: UddfModel { [XmlElement("mix")] public List Mixes { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Generator.cs b/src/UniversalDiveDataFormat/Models/Generator.cs index d682f1b..9ad431b 100644 --- a/src/UniversalDiveDataFormat/Models/Generator.cs +++ b/src/UniversalDiveDataFormat/Models/Generator.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("generator")] -public class Generator +public class Generator: UddfModel { [XmlElement("name")] public required string Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Geography.cs b/src/UniversalDiveDataFormat/Models/Geography.cs index fbe7c8e..18d678c 100644 --- a/src/UniversalDiveDataFormat/Models/Geography.cs +++ b/src/UniversalDiveDataFormat/Models/Geography.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("geography")] -public class Geography +public class Geography: UddfModel { [XmlElement("address")] public Address? Address { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/GetDiveComputerData.cs b/src/UniversalDiveDataFormat/Models/GetDiveComputerData.cs index 2073fed..77d7dd0 100644 --- a/src/UniversalDiveDataFormat/Models/GetDiveComputerData.cs +++ b/src/UniversalDiveDataFormat/Models/GetDiveComputerData.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("getdcdata")] -public class GetDiveComputerData +public class GetDiveComputerData: UddfModel { [XmlElement("getdcalldata")] public GetDcAllData? GetDiveComputerAllData { get; init; } @@ -32,25 +32,25 @@ public class GetDiveComputerData [XmlRoot("getdcdata")] -public class GetDcAllData; +public class GetDcAllData: UddfModel; [XmlRoot("getdcbuddydata")] -public class GetDcBuddyData; +public class GetDcBuddyData: UddfModel; [XmlRoot("getdcdivesitedata")] -public class GetDcDiveSiteData; +public class GetDcDiveSiteData: UddfModel; [XmlRoot("getdcdivetripdata")] -public class GetDcDiveTripData; +public class GetDcDiveTripData: UddfModel; [XmlRoot("getdcgasdefinitionsdata")] -public class GetDcGasDefinitionsData; +public class GetDcGasDefinitionsData: UddfModel; [XmlRoot("getdcgeneratordata")] -public class GetDcGeneratorData; +public class GetDcGeneratorData: UddfModel; [XmlRoot("getdcownerdata")] -public class GetDcOwnerData; +public class GetDcOwnerData: UddfModel; [XmlRoot("getdcprofiledata")] -public class GetDcProfileData; \ No newline at end of file +public class GetDcProfileData: UddfModel; \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/GlobalAlarmsGiven.cs b/src/UniversalDiveDataFormat/Models/GlobalAlarmsGiven.cs index 6ddcc76..726b38b 100644 --- a/src/UniversalDiveDataFormat/Models/GlobalAlarmsGiven.cs +++ b/src/UniversalDiveDataFormat/Models/GlobalAlarmsGiven.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("globalalarmsgiven")] -public class GlobalAlarmsGiven +public class GlobalAlarmsGiven: UddfModel { [XmlElement("globalalarm")] public List GlobalAlarms { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Guide.cs b/src/UniversalDiveDataFormat/Models/Guide.cs index 2e62452..6ebc2b8 100644 --- a/src/UniversalDiveDataFormat/Models/Guide.cs +++ b/src/UniversalDiveDataFormat/Models/Guide.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("guide")] -public class Guide: ILinkable +public class Guide: UddfModel, ILinkable { [XmlAttribute("id")] public string Id { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Image.cs b/src/UniversalDiveDataFormat/Models/Image.cs index 390ea1f..7d3ec72 100644 --- a/src/UniversalDiveDataFormat/Models/Image.cs +++ b/src/UniversalDiveDataFormat/Models/Image.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("image")] -public class Image : ILinkable +public class Image: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } // These should ideally be int? but the serializer doesn't like that [XmlAttribute("height")] diff --git a/src/UniversalDiveDataFormat/Models/ImageData.cs b/src/UniversalDiveDataFormat/Models/ImageData.cs index 3a883a9..579d2df 100644 --- a/src/UniversalDiveDataFormat/Models/ImageData.cs +++ b/src/UniversalDiveDataFormat/Models/ImageData.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("imagedata")] -public class ImageData +public class ImageData: UddfModel { [XmlElement("aperture")] public float? Aperture { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Infinity.cs b/src/UniversalDiveDataFormat/Models/Infinity.cs index a8db056..a243292 100644 --- a/src/UniversalDiveDataFormat/Models/Infinity.cs +++ b/src/UniversalDiveDataFormat/Models/Infinity.cs @@ -3,4 +3,4 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("infinity")] -public class Infinity; \ No newline at end of file +public class Infinity: UddfModel; \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/InformationAfterDive.cs b/src/UniversalDiveDataFormat/Models/InformationAfterDive.cs index 1319b8e..0fa0d4f 100644 --- a/src/UniversalDiveDataFormat/Models/InformationAfterDive.cs +++ b/src/UniversalDiveDataFormat/Models/InformationAfterDive.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("informationafterdive")] -public class InformationAfterDive +public class InformationAfterDive: UddfModel { [XmlElement("anysymptoms")] diff --git a/src/UniversalDiveDataFormat/Models/InformationBeforeDive.cs b/src/UniversalDiveDataFormat/Models/InformationBeforeDive.cs index 591d95f..9af94a9 100644 --- a/src/UniversalDiveDataFormat/Models/InformationBeforeDive.cs +++ b/src/UniversalDiveDataFormat/Models/InformationBeforeDive.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("informationbeforedive")] -public class InformationBeforeDive +public class InformationBeforeDive: UddfModel { [XmlElement("airtemperature")] public float? AirTemperatureInKelvin { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/InputProfile.cs b/src/UniversalDiveDataFormat/Models/InputProfile.cs index b036919..7ba7eba 100644 --- a/src/UniversalDiveDataFormat/Models/InputProfile.cs +++ b/src/UniversalDiveDataFormat/Models/InputProfile.cs @@ -1,9 +1,10 @@ using System.Xml.Serialization; +using UniversalDiveDataFormat.Models.Linking; namespace UniversalDiveDataFormat.Models; [XmlRoot("inputprofile")] -public class InputProfile +public class InputProfile: UddfModel { [XmlElement("link")] public List Links { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Instructor.cs b/src/UniversalDiveDataFormat/Models/Instructor.cs index b480ed6..49e34cc 100644 --- a/src/UniversalDiveDataFormat/Models/Instructor.cs +++ b/src/UniversalDiveDataFormat/Models/Instructor.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("instructor")] -public class Instructor: ILinkable +public class Instructor: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("personal")] public required Personal Personal { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Insurance.cs b/src/UniversalDiveDataFormat/Models/Insurance.cs index c6974ab..95769e1 100644 --- a/src/UniversalDiveDataFormat/Models/Insurance.cs +++ b/src/UniversalDiveDataFormat/Models/Insurance.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("insurance")] -public class Insurance +public class Insurance: UddfModel { [XmlElement("name")] public string? Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/Invertebrata.cs b/src/UniversalDiveDataFormat/Models/Invertebrata.cs index 6222b78..6f06bc2 100644 --- a/src/UniversalDiveDataFormat/Models/Invertebrata.cs +++ b/src/UniversalDiveDataFormat/Models/Invertebrata.cs @@ -4,7 +4,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("invertebrata")] -public class Invertebrata +public class Invertebrata: UddfModel { [XmlElement("amphibia")] public Amphibia? Amphibia { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/IssueDate.cs b/src/UniversalDiveDataFormat/Models/IssueDate.cs index 6eef5e0..30dca8a 100644 --- a/src/UniversalDiveDataFormat/Models/IssueDate.cs +++ b/src/UniversalDiveDataFormat/Models/IssueDate.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("issuedate")] -public class IssueDate +public class IssueDate: UddfModel { [XmlElement("datetime")] public required DateTime DateTime { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/LaunchingDate.cs b/src/UniversalDiveDataFormat/Models/LaunchingDate.cs index 5e04631..93f52f5 100644 --- a/src/UniversalDiveDataFormat/Models/LaunchingDate.cs +++ b/src/UniversalDiveDataFormat/Models/LaunchingDate.cs @@ -2,9 +2,9 @@ namespace UniversalDiveDataFormat.Models; -[XmlRoot("LaunchingDate")] +[XmlRoot("launchingdate")] public class LaunchingDate { [XmlElement("datetime")] - public DateTime? DateTime { get; init; } + public DateTime DateTime { get; init; } } \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Link.cs b/src/UniversalDiveDataFormat/Models/Link.cs deleted file mode 100644 index a600c58..0000000 --- a/src/UniversalDiveDataFormat/Models/Link.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Xml.Serialization; - -namespace UniversalDiveDataFormat.Models; - -[XmlRoot("link")] -public class Link -{ - [XmlAttribute("ref")] - public required string Ref { get; init; } - - // public ILinkable? LinkedObject { get; init; } -} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/ILinkable.cs b/src/UniversalDiveDataFormat/Models/Linking/ILinkable.cs similarity index 79% rename from src/UniversalDiveDataFormat/Models/ILinkable.cs rename to src/UniversalDiveDataFormat/Models/Linking/ILinkable.cs index b1c4d6b..7fdfa52 100644 --- a/src/UniversalDiveDataFormat/Models/ILinkable.cs +++ b/src/UniversalDiveDataFormat/Models/Linking/ILinkable.cs @@ -5,5 +5,5 @@ namespace UniversalDiveDataFormat.Models; public interface ILinkable { [XmlAttribute("id")] - public string Id { get; init; } + public string? Id { get; init; } } \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Linking/Link.cs b/src/UniversalDiveDataFormat/Models/Linking/Link.cs new file mode 100644 index 0000000..62d7f51 --- /dev/null +++ b/src/UniversalDiveDataFormat/Models/Linking/Link.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; + +namespace UniversalDiveDataFormat.Models.Linking; + +[XmlRoot("link")] +public class Link: UddfModel +{ + [XmlAttribute("ref")] + public required string Ref { get; init; } + + [XmlIgnore] + public ILinkable? LinkedObject { get; private set; } + + [XmlIgnore] + public bool IsResolved => LinkedObject is not null; + + public void SetLinkedObject(ILinkable? linkedObject) + { + LinkedObject = linkedObject; + } +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/Maker.cs b/src/UniversalDiveDataFormat/Models/Maker.cs index d7588e9..acac3a4 100644 --- a/src/UniversalDiveDataFormat/Models/Maker.cs +++ b/src/UniversalDiveDataFormat/Models/Maker.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("maker")] -public class Maker +public class Maker: UddfModel { [XmlElement("manufacturer")] public List Manufacturers { get; init; } = []; diff --git a/src/UniversalDiveDataFormat/Models/Manufacturer.cs b/src/UniversalDiveDataFormat/Models/Manufacturer.cs index 92d24d5..b28e522 100644 --- a/src/UniversalDiveDataFormat/Models/Manufacturer.cs +++ b/src/UniversalDiveDataFormat/Models/Manufacturer.cs @@ -3,10 +3,10 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("manufacturer")] -public class Manufacturer: ILinkable +public class Manufacturer: UddfModel, ILinkable { [XmlAttribute("id")] - public required string Id { get; init; } + public string? Id { get; init; } [XmlElement("name")] public required string Name { get; init; } diff --git a/src/UniversalDiveDataFormat/Models/MediaData.cs b/src/UniversalDiveDataFormat/Models/MediaData.cs index 085ef72..e15b7a6 100644 --- a/src/UniversalDiveDataFormat/Models/MediaData.cs +++ b/src/UniversalDiveDataFormat/Models/MediaData.cs @@ -3,7 +3,7 @@ namespace UniversalDiveDataFormat.Models; [XmlRoot("mediadata")] -public class MediaData +public class MediaData: UddfModel { [XmlElement("audio")] public List