diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5c2f2c..69e05ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build (Windows) on: push: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] pull_request: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] workflow_dispatch: jobs: @@ -35,6 +35,36 @@ jobs: - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 + - name: Compute SAMVersion + id: ver + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + # Prefer head_ref when its a sow branch (release-promotion PRs from sow/* to main), + # else use base_ref on PR events / ref_name on push events. + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + if ($headRef -match '^sow/\d{4}-Q\d$') { + $ref = $headRef + } elseif ('${{ github.event_name }}' -eq 'pull_request') { + $ref = $baseRef + } else { + $ref = $refName + } + # .NET AssemblyVersion components are UInt16 (max 65535). Cap to 60000 for headroom. + $run = ${{ github.run_number }} % 60000 + if ($ref -match 'sow/(\d{4})-Q(\d)') { + $v = "$($Matches[1]).$($Matches[2]).$run.0" + $src = "branch '$ref'" + } else { + $now = (Get-Date).ToUniversalTime() + $quarter = [int][Math]::Ceiling($now.Month / 3.0) + $v = "$($now.Year).$quarter.$run.0" + $src = "date $($now.ToString('yyyy-MM-dd')) (ref '$ref' not sow/yyyy-Qx)" + } + Write-Host "SAMVersion = $v (from $src)" + "samversion=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Clone dependency repos (siblings) shell: pwsh @@ -55,10 +85,32 @@ jobs: $deps = $buildOrder[0..($buildOrder.Count-2)] foreach ($r in $deps) { if (Test-Path $r) { continue } - Write-Host "Cloning https://github.com/$org/$r.git" - git clone --depth 1 "https://github.com/$org/$r.git" $r + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + $candidates = @() + if ($headRef) { $candidates += $headRef } + # Current sow branch: base_ref on PR events, ref_name on push events. + $sowRef = if ($baseRef -match '^sow/') { $baseRef } elseif ($refName -match '^sow/') { $refName } else { '' } + if ($sowRef -and $sowRef -ne $headRef) { $candidates += $sowRef } + $candidates += 'sow/2026-Q2' + $cloned = $false + foreach ($cand in $candidates) { + $has = (git ls-remote --heads "https://github.com/$org/$r.git" $cand 2>$null | Out-String).Trim() + if ($has) { + Write-Host "Cloning $org/$r @ $cand" + git clone --depth 1 --branch $cand "https://github.com/$org/$r.git" $r + $cloned = $true + break + } + } + if (-not $cloned) { + Write-Host "Cloning $org/$r @ default branch" + git clone --depth 1 "https://github.com/$org/$r.git" $r + } } + # Ensure ReferencePath exists even before SAM_Windows builds New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null @@ -77,6 +129,7 @@ jobs: '/v:m' '/p:Configuration=Release' '/p:UseSharedCompilation=false' + '/p:SAMVersion=${{ steps.ver.outputs.samversion }}' '/p:RunPostBuildEvent=OnOutputUpdated' "/p:ReferencePath=$windowsRef" ) diff --git a/.github/workflows/spdx-check.yml b/.github/workflows/spdx-check.yml index 269d562..e386bd3 100644 --- a/.github/workflows/spdx-check.yml +++ b/.github/workflows/spdx-check.yml @@ -2,44 +2,89 @@ name: SPDX + Copyright header check on: pull_request: + workflow_dispatch: jobs: spdx: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Check header in changed .cs files + shell: bash run: | - set -e - BASE="${{ github.event.pull_request.base.sha }}" - HEAD="${{ github.event.pull_request.head.sha }}" + set -euo pipefail + + if [ "${{ github.event_name }}" = "pull_request" ]; then + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + else + HEAD="${{ github.sha }}" + BASE="$(git rev-parse "${HEAD}^" 2>/dev/null || true)" + fi - FILES=$(git diff --name-only "$BASE" "$HEAD" -- '*.cs' || true) + echo "Base SHA: ${BASE:-}" + echo "Head SHA: $HEAD" + echo - if [ -z "$FILES" ]; then + if [ -z "${BASE:-}" ]; then + mapfile -t files < <(git ls-files '*.cs') + else + mapfile -t files < <(git diff --diff-filter=ACMR --name-only "$BASE" "$HEAD" -- '*.cs' || true) + fi + + if [ "${#files[@]}" -eq 0 ]; then echo "No C# files changed." exit 0 fi - MISSING="" - for f in $FILES; do - HEADBLOCK=$(head -n 6 "$f") + echo "Changed C# files:" + printf ' - %s\n' "${files[@]}" + echo + + missing=() + + for f in "${files[@]}"; do + if [ ! -f "$f" ]; then + echo "Skipping missing file: $f" + continue + fi + + headblock="$(head -n 20 "$f" | sed '1s/^\xEF\xBB\xBF//' | tr -d '\r')" + + echo "Checking: $f" + + if ! grep -q "SPDX-License-Identifier: LGPL-3.0-or-later" <<< "$headblock"; then + echo " Missing SPDX line" + missing+=("$f") + continue + fi + + if ! grep -qE "Copyright \(c\) 2020[-–]2026 Michal Dengusiak & Jakub Ziolkowski and contributors" <<< "$headblock"; then + echo " Missing copyright line" + missing+=("$f") + continue + fi - echo "$HEADBLOCK" | grep -q "// SPDX-License-Identifier: LGPL-3.0-or-later" || MISSING="$MISSING $f" - echo "$HEADBLOCK" | grep -q "// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors" || MISSING="$MISSING $f" + echo " OK" done - if [ -n "$MISSING" ]; then - echo "❌ Missing required header in:" - for f in $MISSING; do echo " - $f"; done - echo "" - echo "Each changed .cs file must start with:" + echo + if [ "${#missing[@]}" -gt 0 ]; then + echo "Missing required header in:" + printf ' - %s\n' "${missing[@]}" + echo + echo "Each checked .cs file must contain within the first 20 lines:" echo "// SPDX-License-Identifier: LGPL-3.0-or-later" - echo "// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors" + echo "// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors" exit 1 fi - echo "✅ SPDX + copyright headers OK." + echo "SPDX + copyright headers OK." \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..509f4c6 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,57 @@ + + + + + 1.0.0.0 + $(SAMVersion) + $(SAMVersion) + + $(SAMVersion)+$(SAMSourceRevision) + + false + true + + + + + + <_SAMVersionLine Include="// <auto-generated />" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute("$(SAMVersion)")]" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyFileVersionAttribute("$(SAMVersion)")]" /> + + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyInformationalVersionAttribute("$(InformationalVersion)")]" Condition="'$(InformationalVersion)' != ''" /> + + + + + + + + + + diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Kernel/AssemblyInfo.cs b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Kernel/AssemblyInfo.cs index 3ca0dde..f24ae9b 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Kernel/AssemblyInfo.cs +++ b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Kernel/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using Grasshopper.Kernel; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using Grasshopper.Kernel; using System; using System.Drawing; diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Properties/AssemblyInfo.cs index e375edf..9eade6c 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/SAM.Analytical.Grasshopper.Mollier.csproj b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/SAM.Analytical.Grasshopper.Mollier.csproj index e821333..e7cc95d 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Mollier/SAM.Analytical.Grasshopper.Mollier.csproj +++ b/Grasshopper/SAM.Analytical.Grasshopper.Mollier/SAM.Analytical.Grasshopper.Mollier.csproj @@ -10,7 +10,6 @@ false true true - false false false @@ -60,9 +59,7 @@ runtime - - 13.0.3 - + diff --git a/Grasshopper/SAM.Core.Grasshopper.Mollier/Classes/MollierChartObject.cs b/Grasshopper/SAM.Core.Grasshopper.Mollier/Classes/MollierChartObject.cs index b829ac5..a712b62 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Mollier/Classes/MollierChartObject.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Mollier/Classes/MollierChartObject.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Mollier; namespace SAM.Core.Grasshopper.Mollier @@ -18,9 +20,9 @@ public MollierChartObject(IUIMollierObject uIMollierObject, ChartType chartType, this.z = z; } - public MollierChartObject(JObject jObject) + public MollierChartObject(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public MollierChartObject(MollierChartObject mollierChartObject) @@ -65,7 +67,7 @@ public IUIMollierAppearance UIMollierAppearance } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -74,30 +76,30 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("UIMollierObject")) { - uIMollierObject = Core.Query.IJSAMObject< IUIMollierObject >(jObject.Value("UIMollierObject")); + uIMollierObject = Core.Query.IJSAMObject< IUIMollierObject >(jObject["UIMollierObject"] as JsonObject); } if (jObject.ContainsKey("ChartType")) { - chartType = Core.Query.Enum(jObject.Value("ChartType")); + chartType = Core.Query.Enum(jObject["ChartType"]?.GetValue() ?? null); } if (jObject.ContainsKey("Z")) { - z = jObject.Value("Z"); + z = jObject["Z"]?.GetValue() ?? default(double); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(uIMollierObject != null) { - jObject.Add("UIMollierObject", uIMollierObject.ToJObject()); + jObject.Add("UIMollierObject", uIMollierObject.ToJsonObject()); } jObject.Add("ChartType", chartType.ToString()); diff --git a/Grasshopper/SAM.Core.Grasshopper.Mollier/Kernel/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Mollier/Kernel/AssemblyInfo.cs index 241983d..17af13f 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Mollier/Kernel/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Mollier/Kernel/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using Grasshopper.Kernel; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using Grasshopper.Kernel; using System; using System.Drawing; diff --git a/Grasshopper/SAM.Core.Grasshopper.Mollier/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Mollier/Properties/AssemblyInfo.cs index 7b18ef1..b2fc33a 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Mollier/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Core.Grasshopper.Mollier/SAM.Core.Grasshopper.Mollier.csproj b/Grasshopper/SAM.Core.Grasshopper.Mollier/SAM.Core.Grasshopper.Mollier.csproj index 68b6c5d..09bc382 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Mollier/SAM.Core.Grasshopper.Mollier.csproj +++ b/Grasshopper/SAM.Core.Grasshopper.Mollier/SAM.Core.Grasshopper.Mollier.csproj @@ -10,7 +10,6 @@ false true true - false false false @@ -48,9 +47,7 @@ runtime - - 13.0.3 - + diff --git a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Component/SAMMollierMollierPointsByPercentage.cs b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Component/SAMMollierMollierPointsByPercentage.cs index 27f83a4..409b70c 100644 --- a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Component/SAMMollierMollierPointsByPercentage.cs +++ b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Component/SAMMollierMollierPointsByPercentage.cs @@ -1,9 +1,11 @@ -using Grasshopper.Kernel; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Grasshopper.Kernel; using SAM.Geometry.Grasshopper.Mollier.Properties; using System; using System.Collections.Generic; using SAM.Core.Mollier; -using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using System.Linq; using SAM.Core.Grasshopper; using SAM.Core; diff --git a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Properties/AssemblyInfo.cs index 924029c..6d7db6d 100644 --- a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,6 +34,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/SAM.Geometry.Grasshopper.Mollier.csproj b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/SAM.Geometry.Grasshopper.Mollier.csproj index 8fd0d7b..313114a 100644 --- a/Grasshopper/SAM.Geometry.Grasshopper.Mollier/SAM.Geometry.Grasshopper.Mollier.csproj +++ b/Grasshopper/SAM.Geometry.Grasshopper.Mollier/SAM.Geometry.Grasshopper.Mollier.csproj @@ -11,7 +11,6 @@ false true true - false false false @@ -43,9 +42,7 @@ runtime - - 13.0.3 - + diff --git a/Grasshopper/SAM.Weather.Grasshopper.Mollier/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Weather.Grasshopper.Mollier/Properties/AssemblyInfo.cs index ddc830f..aea9229 100644 --- a/Grasshopper/SAM.Weather.Grasshopper.Mollier/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Weather.Grasshopper.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -30,6 +33,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Grasshopper/SAM.Weather.Grasshopper.Mollier/SAM.Weather.Grasshopper.Mollier.csproj b/Grasshopper/SAM.Weather.Grasshopper.Mollier/SAM.Weather.Grasshopper.Mollier.csproj index 44cf5c0..4820b10 100644 --- a/Grasshopper/SAM.Weather.Grasshopper.Mollier/SAM.Weather.Grasshopper.Mollier.csproj +++ b/Grasshopper/SAM.Weather.Grasshopper.Mollier/SAM.Weather.Grasshopper.Mollier.csproj @@ -9,7 +9,6 @@ $([MSBuild]::ValueOrDefault('$(RhinoDebugPluginsDir)', '$(RhinoDefaultPluginsDir)')) Library false - false false false diff --git a/SAM_Mollier/SAM.Analytical.Mollier/Classes/AirHandlingUnitResult.cs b/SAM_Mollier/SAM.Analytical.Mollier/Classes/AirHandlingUnitResult.cs index 383c310..3ff1b2f 100644 --- a/SAM_Mollier/SAM.Analytical.Mollier/Classes/AirHandlingUnitResult.cs +++ b/SAM_Mollier/SAM.Analytical.Mollier/Classes/AirHandlingUnitResult.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using System; @@ -24,22 +26,22 @@ public AirHandlingUnitResult(AirHandlingUnitResult airHandlingUnitResult) } - public AirHandlingUnitResult(JObject jObject) + public AirHandlingUnitResult(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return null; diff --git a/SAM_Mollier/SAM.Analytical.Mollier/Properties/AssemblyInfo.cs b/SAM_Mollier/SAM.Analytical.Mollier/Properties/AssemblyInfo.cs index 0980704..f8aa9e3 100644 --- a/SAM_Mollier/SAM.Analytical.Mollier/Properties/AssemblyInfo.cs +++ b/SAM_Mollier/SAM.Analytical.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/SAM_Mollier/SAM.Analytical.Mollier/SAM.Analytical.Mollier.csproj b/SAM_Mollier/SAM.Analytical.Mollier/SAM.Analytical.Mollier.csproj index 7132af0..7483b3a 100644 --- a/SAM_Mollier/SAM.Analytical.Mollier/SAM.Analytical.Mollier.csproj +++ b/SAM_Mollier/SAM.Analytical.Mollier/SAM.Analytical.Mollier.csproj @@ -6,8 +6,6 @@ SAM.Analytical.Mollier SAM.Analytical.Mollier Copyright © 2022 - 1.0.0.0 - 1.0.0.0 false false @@ -44,6 +42,6 @@ - + \ No newline at end of file diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/AdiabaticHumidificationProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/AdiabaticHumidificationProcess.cs index c938338..9f5dc77 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/AdiabaticHumidificationProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/AdiabaticHumidificationProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class AdiabaticHumidificationProcess : HumidificationProcess @@ -12,7 +13,7 @@ internal AdiabaticHumidificationProcess(MollierPoint start, MollierPoint end) } - public AdiabaticHumidificationProcess(JObject jObject) + public AdiabaticHumidificationProcess(JsonObject jObject) :base(jObject) { diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantEnthalpyCurve.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantEnthalpyCurve.cs index 4b0a7d9..95e59c7 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantEnthalpyCurve.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantEnthalpyCurve.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Mollier @@ -28,7 +30,7 @@ public ConstantEnthalpyCurve(ConstantEnthalpyCurve constantEnthalpyCurve) } } - public ConstantEnthalpyCurve(JObject jObject) + public ConstantEnthalpyCurve(JsonObject jObject) : base(jObject) { @@ -42,9 +44,9 @@ public Phase Phase } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = FromJObject(jObject); + bool result = FromJsonObject(jObject); if(!result) { return result; @@ -52,15 +54,15 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("Phase")) { - phase = Core.Query.Enum(jObject.Value("Phase")); + phase = Core.Query.Enum(jObject["Phase"]?.GetValue() ?? null); } return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantTemperatureCurve.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantTemperatureCurve.cs index 9d75f25..d374e96 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantTemperatureCurve.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantTemperatureCurve.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Mollier @@ -28,7 +30,7 @@ public ConstantTemperatureCurve(ConstantTemperatureCurve constantTemperatureCurv } } - public ConstantTemperatureCurve(JObject jObject) + public ConstantTemperatureCurve(JsonObject jObject) : base(jObject) { @@ -42,9 +44,9 @@ public Phase Phase } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = FromJObject(jObject); + bool result = FromJsonObject(jObject); if(!result) { return result; @@ -52,15 +54,15 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("Phase")) { - phase = Core.Query.Enum(jObject.Value("Phase")); + phase = Core.Query.Enum(jObject["Phase"]?.GetValue() ?? null); } return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantValueCurve.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantValueCurve.cs index 112ed84..273bfd3 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantValueCurve.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/ConstantValueCurve.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Mollier @@ -32,7 +34,7 @@ public ConstantValueCurve(ConstantValueCurve constantValueCurve) } } - public ConstantValueCurve(JObject jObject) + public ConstantValueCurve(JsonObject jObject) : base(jObject) { @@ -54,9 +56,9 @@ public double Value } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = FromJObject(jObject); + bool result = FromJsonObject(jObject); if(!result) { return result; @@ -64,20 +66,20 @@ public virtual bool FromJObject(JObject jObject) if(jObject.ContainsKey("Value")) { - value = jObject.Value("Value"); + value = jObject["Value"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("ChartDataType")) { - chartDataType = Core.Query.Enum(jObject.Value("ChartDataType")); + chartDataType = Core.Query.Enum(jObject["ChartDataType"]?.GetValue() ?? null); } return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/CoolingProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/CoolingProcess.cs index 675cf42..4574362 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/CoolingProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/CoolingProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class CoolingProcess : MollierProcess @@ -13,7 +14,7 @@ internal CoolingProcess(MollierPoint start, MollierPoint end, double efficiency this.efficiency = efficiency; } - public CoolingProcess(JObject jObject) + public CoolingProcess(JsonObject jObject) :base(jObject) { @@ -91,24 +92,24 @@ public MollierPoint ApparatusDewPoint() // //return downPoint; //} - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if(!base.FromJObject(jObject)) + if(!base.FromJsonObject(jObject)) { return false; } if(jObject.ContainsKey("Efficiency")) { - efficiency = jObject.Value("Efficiency"); + efficiency = jObject["Efficiency"]?.GetValue() ?? default(double); } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/FanProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/FanProcess.cs index 87d3cfd..ed72c8f 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/FanProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/FanProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class FanProcess : HeatingProcess @@ -10,7 +11,7 @@ internal FanProcess(MollierPoint start, MollierPoint end) } - public FanProcess(JObject jObject) + public FanProcess(JsonObject jObject) :base(jObject) { diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/HeatRecoveryProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/HeatRecoveryProcess.cs index 48dc28e..788bece 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/HeatRecoveryProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/HeatRecoveryProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class HeatRecoveryProcess : MollierProcess @@ -11,7 +12,7 @@ internal HeatRecoveryProcess(MollierPoint start, MollierPoint end) } - public HeatRecoveryProcess(JObject jObject) + public HeatRecoveryProcess(JsonObject jObject) :base(jObject) { @@ -22,9 +23,9 @@ public HeatRecoveryProcess(HeatRecoveryProcess heatRecoveryProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -32,9 +33,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/HeatingProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/HeatingProcess.cs index c5c0cb0..aa0dfa1 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/HeatingProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/HeatingProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class HeatingProcess : MollierProcess @@ -10,7 +11,7 @@ internal HeatingProcess(MollierPoint start, MollierPoint end) { } - public HeatingProcess(JObject jObject) + public HeatingProcess(JsonObject jObject) :base(jObject) { @@ -21,9 +22,9 @@ public HeatingProcess(HeatingProcess heatingProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -31,9 +32,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/HumidificationProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/HumidificationProcess.cs index 86a0220..7095d25 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/HumidificationProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/HumidificationProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public abstract class HumidificationProcess : MollierProcess @@ -10,7 +11,7 @@ internal HumidificationProcess(MollierPoint start, MollierPoint end) } - public HumidificationProcess(JObject jObject) + public HumidificationProcess(JsonObject jObject) :base(jObject) { @@ -21,9 +22,9 @@ public HumidificationProcess(HumidificationProcess humidificationProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -31,9 +32,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/IsotermicHumidificationProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/IsotermicHumidificationProcess.cs index f40b6f0..06dc20f 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/IsotermicHumidificationProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/IsotermicHumidificationProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class IsothermalHumidificationProcess : HumidificationProcess @@ -12,7 +13,7 @@ internal IsothermalHumidificationProcess(MollierPoint start, MollierPoint end) } - public IsothermalHumidificationProcess(JObject jObject) + public IsothermalHumidificationProcess(JsonObject jObject) :base(jObject) { diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MixingProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MixingProcess.cs index 0fb1674..d4f9c20 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MixingProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MixingProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class MixingProcess : MollierProcess @@ -11,7 +12,7 @@ internal MixingProcess(MollierPoint start, MollierPoint end) } - public MixingProcess(JObject jObject) + public MixingProcess(JsonObject jObject) :base(jObject) { @@ -22,9 +23,9 @@ public MixingProcess(MixingProcess mixingProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -32,9 +33,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierCurve.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierCurve.cs index ccb3173..9e922cf 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierCurve.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierCurve.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Mollier @@ -52,9 +54,9 @@ public MollierCurve(MollierCurve mollierCurve) } } - public MollierCurve(JObject jObject) + public MollierCurve(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public MollierPoint Start @@ -91,7 +93,7 @@ public List MollierPoints } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -100,12 +102,17 @@ public virtual bool FromJObject(JObject jObject) if(jObject.ContainsKey("MollierPoints")) { - JArray jArray = jObject.Value("MollierPoints"); + JsonArray jArray = jObject["MollierPoints"] as JsonArray; if(jArray != null) { mollierPoints = new List(); - foreach(JObject jObject_MollierPoint in jArray) + foreach(JsonNode jsonNode_MollierPoint in jArray) { + if (!(jsonNode_MollierPoint is JsonObject jObject_MollierPoint)) + { + continue; + } + mollierPoints.Add(new MollierPoint(jObject_MollierPoint)); } } @@ -114,14 +121,14 @@ public virtual bool FromJObject(JObject jObject) return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(mollierPoints != null) { - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach(MollierPoint mollierPoint in mollierPoints) { if(mollierPoint == null) @@ -129,7 +136,7 @@ public virtual JObject ToJObject() continue; } - jArray.Add(mollierPoint.ToJObject()); + jArray.Add(mollierPoint.ToJsonObject()); } jObject.Add("MollierPoints", jArray); diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierGroup.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierGroup.cs index 1da7516..089203c 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierGroup.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierGroup.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System; using System.Collections; using System.Collections.Generic; @@ -28,9 +30,9 @@ public MollierGroup(MollierGroup mollierGroup) } } - public MollierGroup(JObject jObject) + public MollierGroup(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } @@ -203,7 +205,7 @@ List Objects } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if(jObject == null) { @@ -212,21 +214,21 @@ public virtual bool FromJObject(JObject jObject) if(jObject.ContainsKey("Name")) { - Name = jObject.Value("Name"); + Name = jObject["Name"]?.GetValue() ?? null; } if(jObject.ContainsKey("Objects")) { - List mollierGroupables = Core.Create.IJSAMObjects(jObject.Value("Objects")); + List mollierGroupables = Core.Create.IJSAMObjects(jObject["Objects"] as JsonArray); mollierGroupables?.ForEach(x => Add(x)); } return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(Name != null) @@ -234,10 +236,10 @@ public virtual JObject ToJObject() jObject.Add("Name", Name); } - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach (IMollierGroupable mollierGroupable in this) { - jArray.Add(mollierGroupable.ToJObject()); + jArray.Add(mollierGroupable.ToJsonObject()); } jObject.Add("Objects", jArray); diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierLine.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierLine.cs index 987cc9a..c8b5787 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierLine.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierLine.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public abstract class MollierLine : MollierCurve @@ -16,9 +17,9 @@ public MollierLine(MollierLine mollierLine) } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = base.FromJObject(jObject); + bool result = base.FromJsonObject(jObject); if (!result) { return false; @@ -27,9 +28,9 @@ public virtual bool FromJObject(JObject jObject) return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierPoint.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierPoint.cs index 8e4bb2d..45b7484 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierPoint.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierPoint.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class MollierPoint : IMollierPoint @@ -28,9 +29,9 @@ public MollierPoint(double dryBulbTemperature, double humidityRatio, double pres this.pressure = pressure; } - public MollierPoint(JObject jObject) + public MollierPoint(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } ///// @@ -142,16 +143,16 @@ public double RelativeHumidity } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if(jObject == null) { return false; } - dryBulbTemperature = jObject.ContainsKey("DryBulbTemperature") ? jObject.Value("DryBulbTemperature") : double.NaN; - humidityRatio = jObject.ContainsKey("HumidityRatio") ? jObject.Value("HumidityRatio") : double.NaN; - pressure = jObject.ContainsKey("Pressure") ? jObject.Value("Pressure") : double.NaN; + dryBulbTemperature = jObject.ContainsKey("DryBulbTemperature") ? jObject["DryBulbTemperature"]?.GetValue() ?? default(double) : double.NaN; + humidityRatio = jObject.ContainsKey("HumidityRatio") ? jObject["HumidityRatio"]?.GetValue() ?? default(double) : double.NaN; + pressure = jObject.ContainsKey("Pressure") ? jObject["Pressure"]?.GetValue() ?? default(double) : double.NaN; return true; } @@ -161,9 +162,9 @@ public virtual bool IsValid() return !double.IsNaN(dryBulbTemperature) && !double.IsNaN(humidityRatio) && !double.IsNaN(pressure) && !double.IsInfinity(dryBulbTemperature) && !double.IsInfinity(humidityRatio) && !double.IsInfinity(pressure); } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(!double.IsNaN(dryBulbTemperature)) diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierProcess.cs index bdbd898..8ae98d8 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public abstract class MollierProcess : MollierCurve, IMollierProcess @@ -16,7 +17,7 @@ public MollierProcess(MollierProcess mollierProcess) } - public MollierProcess(JObject jObject) + public MollierProcess(JsonObject jObject) :base(jObject) { @@ -35,9 +36,9 @@ public virtual void Scale(double factor) mollierPoints[1] = new MollierPoint(Start.DryBulbTemperature - (dryBulbTemperatureDifference * factor), Start.HumidityRatio - (humidityRatioDifference * factor), Start.Pressure); } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = base.FromJObject(jObject); + bool result = base.FromJsonObject(jObject); if (!result) { return false; @@ -46,9 +47,9 @@ public virtual bool FromJObject(JObject jObject) return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierRange.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierRange.cs index 6523205..048654b 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierRange.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierRange.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class MollierRange : IJSAMObject @@ -19,9 +20,9 @@ public MollierRange(MollierRange mollierRange) humidityRatioRange = mollierRange?.humidityRatioRange == null ? null : new Range(mollierRange.humidityRatioRange); } - public MollierRange(JObject jObject) + public MollierRange(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public double DryBulbTemperature_Max @@ -77,7 +78,7 @@ public bool IsValid() return dryBulbTemperatureRange != null && humidityRatioRange != null && !double.IsNaN(dryBulbTemperatureRange.Max) && !double.IsNaN(dryBulbTemperatureRange.Min) && !double.IsNaN(humidityRatioRange.Max) && !double.IsNaN(humidityRatioRange.Min); } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if(jObject == null) { @@ -86,30 +87,30 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("DryBulbTemperatureRange")) { - dryBulbTemperatureRange = new Range(jObject.Value("DryBulbTemperatureRange")); + dryBulbTemperatureRange = new Range(jObject["DryBulbTemperatureRange"] as JsonObject); } if (jObject.ContainsKey("HumidityRatioRange")) { - humidityRatioRange = new Range(jObject.Value("HumidityRatioRange")); + humidityRatioRange = new Range(jObject["HumidityRatioRange"] as JsonObject); } return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(dryBulbTemperatureRange != null) { - jObject.Add("DryBulbTemperatureRange", dryBulbTemperatureRange.ToJObject()); + jObject.Add("DryBulbTemperatureRange", dryBulbTemperatureRange.ToJsonObject()); } if (humidityRatioRange != null) { - jObject.Add("HumidityRatioRange", humidityRatioRange.ToJObject()); + jObject.Add("HumidityRatioRange", humidityRatioRange.ToJsonObject()); } return jObject; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSensibleHeatRatioLine.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSensibleHeatRatioLine.cs index 07501fa..e8b2fda 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSensibleHeatRatioLine.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSensibleHeatRatioLine.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class MollierSensibleHeatRatioLine : MollierLine @@ -31,9 +32,9 @@ public double SensibleHeatRatio } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - bool result = base.FromJObject(jObject); + bool result = base.FromJsonObject(jObject); if (!result) { return false; @@ -41,15 +42,15 @@ public virtual bool FromJObject(JObject jObject) if(jObject.ContainsKey("SensibleHeatRatio")) { - sensibleHeatRatio = jObject.Value(sensibleHeatRatio); + sensibleHeatRatio = jObject["SensibleHeatRatio"]?.GetValue() ?? default(double); } return result; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSettings.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSettings.cs index 2074995..471bdfd 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSettings.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierSettings.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class MollierSettings : IJSAMObject @@ -61,84 +62,84 @@ public MollierSettings(MollierSettings mollierSettings) } } - public MollierSettings(JObject jObject) + public MollierSettings(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject.ContainsKey("ChartType")) { - ChartType = Core.Query.Enum(jObject.Value("ChartType")); + ChartType = Core.Query.Enum(jObject["ChartType"]?.GetValue() ?? null); } if (jObject.ContainsKey("Pressure")) { - Pressure = jObject.Value("Pressure"); + Pressure = jObject["Pressure"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("MollierRange")) { - MollierRange = new MollierRange(jObject.Value("MollierRange")); + MollierRange = new MollierRange(jObject["MollierRange"] as JsonObject); } if (jObject.ContainsKey("HumidityRatio_Interval")) { - HumidityRatio_Interval = jObject.Value("HumidityRatio_Interval"); + HumidityRatio_Interval = jObject["HumidityRatio_Interval"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("DryBulbTemperature_Interval")) { - DryBulbTemperature_Interval = jObject.Value("DryBulbTemperature_Interval"); + DryBulbTemperature_Interval = jObject["DryBulbTemperature_Interval"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("DensityRange")) { - DensityRange = new Range(jObject.Value("DensityRange")); + DensityRange = new Range(jObject["DensityRange"] as JsonObject); } if (jObject.ContainsKey("Density_Interval")) { - Density_Interval = jObject.Value("Density_Interval"); + Density_Interval = jObject["Density_Interval"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("EnthalpyRange")) { - EnthalpyRange = new Range(jObject.Value("EnthalpyRange")); + EnthalpyRange = new Range(jObject["EnthalpyRange"] as JsonObject); } if (jObject.ContainsKey("Enthalpy_Interval")) { - Enthalpy_Interval = jObject.Value("Enthalpy_Interval"); + Enthalpy_Interval = jObject["Enthalpy_Interval"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("SpecificVolumeRange")) { - SpecificVolumeRange = new Range(jObject.Value("SpecificVolumeRange")); + SpecificVolumeRange = new Range(jObject["SpecificVolumeRange"] as JsonObject); } if (jObject.ContainsKey("SpecificVolume_Interval")) { - SpecificVolume_Interval = jObject.Value("SpecificVolume_Interval"); + SpecificVolume_Interval = jObject["SpecificVolume_Interval"]?.GetValue() ?? default(double); } if (jObject.ContainsKey("WetBulbTemperatureRange")) { - WetBulbTemperatureRange = new Range(jObject.Value("WetBulbTemperatureRange")); + WetBulbTemperatureRange = new Range(jObject["WetBulbTemperatureRange"] as JsonObject); } if (jObject.ContainsKey("WetBulbTemperature_Interval")) { - WetBulbTemperature_Interval = jObject.Value("WetBulbTemperature_Interval"); + WetBulbTemperature_Interval = jObject["WetBulbTemperature_Interval"]?.GetValue() ?? default(double); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = new JObject(); + JsonObject result = new JsonObject(); result.Add("_type", Core.Query.FullTypeName(this)); result.Add("ChartType", ChartType.ToString()); @@ -150,7 +151,7 @@ public JObject ToJObject() if(MollierRange != null) { - result.Add("MollierRange", MollierRange.ToJObject()); + result.Add("MollierRange", MollierRange.ToJsonObject()); } if (!double.IsNaN(HumidityRatio_Interval)) @@ -165,7 +166,7 @@ public JObject ToJObject() if (DensityRange != null) { - result.Add("DensityRange", DensityRange.ToJObject()); + result.Add("DensityRange", DensityRange.ToJsonObject()); } if (!double.IsNaN(Density_Interval)) @@ -175,7 +176,7 @@ public JObject ToJObject() if (EnthalpyRange != null) { - result.Add("EnthalpyRange", EnthalpyRange.ToJObject()); + result.Add("EnthalpyRange", EnthalpyRange.ToJsonObject()); } if (!double.IsNaN(Enthalpy_Interval)) @@ -185,7 +186,7 @@ public JObject ToJObject() if (SpecificVolumeRange != null) { - result.Add("SpecificVolumeRange", SpecificVolumeRange.ToJObject()); + result.Add("SpecificVolumeRange", SpecificVolumeRange.ToJsonObject()); } if (!double.IsNaN(SpecificVolume_Interval)) @@ -195,7 +196,7 @@ public JObject ToJObject() if (WetBulbTemperatureRange != null) { - result.Add("WetBulbTemperatureRange", WetBulbTemperatureRange.ToJObject()); + result.Add("WetBulbTemperatureRange", WetBulbTemperatureRange.ToJsonObject()); } if (!double.IsNaN(WetBulbTemperature_Interval)) diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierZone.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierZone.cs index d18c566..c1993f2 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/MollierZone.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/MollierZone.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Mollier @@ -28,9 +30,9 @@ public MollierZone(MollierZone mollierZone) mollierPoints.Add(new MollierPoint(point)); } } - public MollierZone(JObject jObject) + public MollierZone(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public MollierPoint GetCenter() @@ -60,7 +62,7 @@ public List MollierPoints } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if(jObject == null) { @@ -70,13 +72,18 @@ public virtual bool FromJObject(JObject jObject) { mollierPoints = new List(); - //mollierPoints = Core.Create.IJSAMObjects(jObject.Value("MollierPoints")); + //mollierPoints = Core.Create.IJSAMObjects(jObject["MollierPoints"] as JsonArray); - JArray jArray = jObject.Value("MollierPoints"); + JsonArray jArray = jObject["MollierPoints"] as JsonArray; if(jArray != null) { - foreach (JObject jObject_MollierPoint in jArray) + foreach (JsonNode jsonNode_MollierPoint in jArray) { + if (!(jsonNode_MollierPoint is JsonObject jObject_MollierPoint)) + { + continue; + } + if(jObject_MollierPoint == null) { continue; @@ -90,17 +97,17 @@ public virtual bool FromJObject(JObject jObject) return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if(mollierPoints != null) { - JArray jArray = new JArray(); - //mollierPoints.ForEach(x => jArray.Add(x.ToJObject())); + JsonArray jArray = new JsonArray(); + //mollierPoints.ForEach(x => jArray.Add(x.ToJsonObject())); foreach(MollierPoint point in mollierPoints) { - jArray.Add(point.ToJObject()); + jArray.Add(point.ToJsonObject()); } jObject.Add("MollierPoints", jArray); diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/RoomProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/RoomProcess.cs index 810bb65..fec5e13 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/RoomProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/RoomProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class RoomProcess : SpecificProcess @@ -12,7 +13,7 @@ internal RoomProcess(MollierPoint start, MollierPoint end) } - public RoomProcess(JObject jObject) + public RoomProcess(JsonObject jObject) : base(jObject) { diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/SpecificProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/SpecificProcess.cs index 206bf32..56d0bd2 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/SpecificProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/SpecificProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public abstract class SpecificProcess : MollierProcess @@ -10,7 +11,7 @@ internal SpecificProcess(MollierPoint start, MollierPoint end) } - public SpecificProcess(JObject jObject) + public SpecificProcess(JsonObject jObject) : base(jObject) { @@ -21,9 +22,9 @@ public SpecificProcess(SpecificProcess specificMollierProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -31,9 +32,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/SteamHumidificationProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/SteamHumidificationProcess.cs index c85b1f3..6af5b4f 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/SteamHumidificationProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/SteamHumidificationProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { @@ -14,7 +15,7 @@ internal SteamHumidificationProcess(MollierPoint start, MollierPoint end) } - public SteamHumidificationProcess(JObject jObject) + public SteamHumidificationProcess(JsonObject jObject) :base(jObject) { diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/UndefinedProcess.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/UndefinedProcess.cs index 17c0a5e..7674e7f 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/UndefinedProcess.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/UndefinedProcess.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Mollier { public class UndefinedProcess : MollierProcess @@ -11,7 +12,7 @@ internal UndefinedProcess(MollierPoint start, MollierPoint end) } - public UndefinedProcess(JObject jObject) + public UndefinedProcess(JsonObject jObject) :base(jObject) { @@ -22,9 +23,9 @@ public UndefinedProcess(UndefinedProcess undefinedProcess) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) { return false; } @@ -32,9 +33,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return result; diff --git a/SAM_Mollier/SAM.Core.Mollier/Classes/VisibilitySettings.cs b/SAM_Mollier/SAM.Core.Mollier/Classes/VisibilitySettings.cs index 8b284d2..8982628 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Classes/VisibilitySettings.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Classes/VisibilitySettings.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System.Collections.Generic; using System; using System.Linq; @@ -26,12 +28,12 @@ public VisibilitySettings(VisibilitySettings visibilitySettings) } } - public VisibilitySettings(JObject jObject) + public VisibilitySettings(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -42,19 +44,29 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("Templates")) { dictionary = new Dictionary>(); - JArray jArray = jObject.Value("Templates"); - foreach (JObject jObject_Temp in jArray) + JsonArray jArray = jObject["Templates"] as JsonArray; + foreach (JsonNode jsonNode_Temp in jArray) { + if (!(jsonNode_Temp is JsonObject jObject_Temp)) + { + continue; + } + if (!jObject_Temp.ContainsKey("TemplateName") || !jObject_Temp.ContainsKey("VisibilitySettings")) { continue; } - string templateName = jObject_Temp.Value("TemplateName"); - JArray jArray_VisibilitySettings = jObject_Temp.Value("VisibilitySettings"); + string templateName = jObject_Temp["TemplateName"]?.GetValue() ?? null; + JsonArray jArray_VisibilitySettings = jObject_Temp["VisibilitySettings"] as JsonArray; - foreach (JObject jObject_VisibilitySetting in jArray_VisibilitySettings) + foreach (JsonNode jsonNode_VisibilitySetting in jArray_VisibilitySettings) { + if (!(jsonNode_VisibilitySetting is JsonObject jObject_VisibilitySetting)) + { + continue; + } + if (!dictionary.TryGetValue(templateName, out List visibilitySettings)) { visibilitySettings = new List(); @@ -69,25 +81,25 @@ public bool FromJObject(JObject jObject) return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = new JObject(); + JsonObject result = new JsonObject(); if (dictionary != null) { - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach (KeyValuePair> keyValuePair in dictionary) { - JObject jObject_Template = new JObject(); + JsonObject jObject_Template = new JsonObject(); string templateName = keyValuePair.Key; jObject_Template.Add("TemplateName", templateName); - JArray jArray_VisibilitySettings = new JArray(); + JsonArray jArray_VisibilitySettings = new JsonArray(); foreach (IVisibilitySetting visibilitySetting in keyValuePair.Value) { - jArray_VisibilitySettings.Add(visibilitySetting.ToJObject()); + jArray_VisibilitySettings.Add(visibilitySetting.ToJsonObject()); } jObject_Template.Add("VisibilitySettings", jArray_VisibilitySettings); diff --git a/SAM_Mollier/SAM.Core.Mollier/Properties/AssemblyInfo.cs b/SAM_Mollier/SAM.Core.Mollier/Properties/AssemblyInfo.cs index 98164ff..75bf415 100644 --- a/SAM_Mollier/SAM.Core.Mollier/Properties/AssemblyInfo.cs +++ b/SAM_Mollier/SAM.Core.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Mollier/SAM.Core.Mollier/SAM.Core.Mollier.csproj b/SAM_Mollier/SAM.Core.Mollier/SAM.Core.Mollier.csproj index f7df4dc..8dc7aed 100644 --- a/SAM_Mollier/SAM.Core.Mollier/SAM.Core.Mollier.csproj +++ b/SAM_Mollier/SAM.Core.Mollier/SAM.Core.Mollier.csproj @@ -2,13 +2,10 @@ netstandard2.0 Library - false false SAM SAM - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false @@ -35,7 +32,7 @@ - + diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UICoolingProcess.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UICoolingProcess.cs index 3b9e473..f4455d5 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UICoolingProcess.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UICoolingProcess.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Mollier; using System.Drawing; @@ -29,7 +31,7 @@ public UICoolingProcess(UICoolingProcess uICoolingProcess) } } - public UICoolingProcess(JObject jObject) + public UICoolingProcess(JsonObject jObject) : base(jObject) { } @@ -42,24 +44,24 @@ public bool Realistic } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { - if(!base.FromJObject(jObject)) + if(!base.FromJsonObject(jObject)) { return false; } if(jObject.ContainsKey("Realistic")) { - realistic = jObject.Value("Realistic"); + realistic = jObject["Realistic"]?.GetValue() ?? default(bool); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierAppearance.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierAppearance.cs index c6a7aa9..3fa445c 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierAppearance.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierAppearance.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Drawing; @@ -54,9 +56,9 @@ public UIMollierAppearance(UIMollierAppearance uIMollierAppearance, Color color) Color = color; } - public UIMollierAppearance(JObject jObject) + public UIMollierAppearance(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public string Label @@ -79,7 +81,7 @@ public string Label } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -88,7 +90,7 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("Color")) { - JObject jObject_Color = jObject.Value("Color"); + JsonObject jObject_Color = jObject["Color"] as JsonObject; if (jObject_Color != null) { SAMColor sAMColor = new SAMColor(jObject_Color); @@ -101,35 +103,35 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("UIMollierLabelAppearance")) { - UIMollierLabelAppearance = new UIMollierLabelAppearance(jObject.Value("UIMollierLabelAppearance")); + UIMollierLabelAppearance = new UIMollierLabelAppearance(jObject["UIMollierLabelAppearance"] as JsonObject); } if (jObject.ContainsKey("Visible")) { - Visible = jObject.Value("Visible"); + Visible = jObject["Visible"]?.GetValue() ?? default(bool); } if (jObject.ContainsKey("Size")) { - Size = jObject.Value("Size"); + Size = jObject["Size"]?.GetValue() ?? default(int); } return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if (Color != Color.Empty) { - jObject.Add("Color", (new SAMColor(Color)).ToJObject()); + jObject.Add("Color", (new SAMColor(Color)).ToJsonObject()); } if (UIMollierLabelAppearance != null) { - jObject.Add("UIMollierLabelAppearance", UIMollierLabelAppearance.ToJObject()); + jObject.Add("UIMollierLabelAppearance", UIMollierLabelAppearance.ToJsonObject()); } jObject.Add("Visible", Visible); diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierCurve.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierCurve.cs index 6ba4150..a440e75 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierCurve.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierCurve.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Collections.Generic; @@ -98,9 +100,9 @@ public UIMollierCurve(MollierCurve mollierCurve, UIMollierAppearance uIMollierAp this.uIMollierAppearance = uIMollierAppearance?.Clone(); } - public UIMollierCurve(JObject jObject) + public UIMollierCurve(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public System.Guid Guid @@ -111,7 +113,7 @@ public System.Guid Guid } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -120,12 +122,12 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("MollierCurve")) { - mollierCurve = Core.Query.IJSAMObject(jObject.Value("MollierCurve")) as MollierCurve; + mollierCurve = Core.Query.IJSAMObject(jObject["MollierCurve"] as JsonObject) as MollierCurve; } if (jObject.ContainsKey("UIMollierAppearance")) { - uIMollierAppearance = Core.Query.IJSAMObject(jObject.Value("UIMollierAppearance")) as UIMollierAppearance; + uIMollierAppearance = Core.Query.IJSAMObject(jObject["UIMollierAppearance"] as JsonObject) as UIMollierAppearance; } if (jObject.ContainsKey("Guid")) @@ -136,19 +138,19 @@ public virtual bool FromJObject(JObject jObject) return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = new JObject(); + JsonObject result = new JsonObject(); result.Add("_type", Core.Query.FullTypeName(this)); if (mollierCurve != null) { - result.Add("MollierCurve", mollierCurve.ToJObject()); + result.Add("MollierCurve", mollierCurve.ToJsonObject()); } if (uIMollierAppearance != null) { - result.Add("UIMollierAppearance", uIMollierAppearance.ToJObject()); + result.Add("UIMollierAppearance", uIMollierAppearance.ToJsonObject()); } if (guid != System.Guid.Empty) diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierGroup.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierGroup.cs index eaa31d0..d671b3a 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierGroup.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierGroup.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Mollier; using System.Drawing; @@ -61,16 +63,16 @@ public System.Guid Guid } } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if(jObject == null || !base.FromJObject(jObject)) + if(jObject == null || !base.FromJsonObject(jObject)) { return false; } if (jObject.ContainsKey("UIMollierAppearance")) { - uIMollierAppearance = Core.Query.IJSAMObject(jObject.Value("UIMollierAppearance")) as UIMollierAppearance; + uIMollierAppearance = Core.Query.IJSAMObject(jObject["UIMollierAppearance"] as JsonObject) as UIMollierAppearance; } if (jObject.ContainsKey("Guid")) @@ -81,9 +83,9 @@ public override bool FromJObject(JObject jObject) return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { @@ -92,7 +94,7 @@ public override JObject ToJObject() if (uIMollierAppearance != null) { - result.Add("UIMollierAppearance", uIMollierAppearance.ToJObject()); + result.Add("UIMollierAppearance", uIMollierAppearance.ToJsonObject()); } if (guid != System.Guid.Empty) diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierLabelAppearance.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierLabelAppearance.cs index 17a7e26..b44ac31 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierLabelAppearance.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierLabelAppearance.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Drawing; @@ -76,12 +78,12 @@ public UIMollierLabelAppearance(UIMollierLabelAppearance uIMollierLabelAppearanc Color = color; } - public UIMollierLabelAppearance(JObject jObject) + public UIMollierLabelAppearance(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -90,7 +92,7 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("Color")) { - JObject jObject_Color = jObject.Value("Color"); + JsonObject jObject_Color = jObject["Color"] as JsonObject; if (jObject_Color != null) { SAMColor sAMColor = new SAMColor(jObject_Color); @@ -103,35 +105,35 @@ public virtual bool FromJObject(JObject jObject) if (jObject.ContainsKey("Text")) { - Text = jObject.Value("Text"); + Text = jObject["Text"]?.GetValue() ?? null; } if (jObject.ContainsKey("Visible")) { - Visible = jObject.Value("Visible"); + Visible = jObject["Visible"]?.GetValue() ?? default(bool); } if (jObject.ContainsKey("Size")) { - Size = jObject.Value("Size"); + Size = jObject["Size"]?.GetValue() ?? default(int); } if (jObject.ContainsKey("Vector2D")) { - Vector2D = new Vector2D(jObject.Value("Vector2D")); + Vector2D = new Vector2D(jObject["Vector2D"] as JsonObject); } return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); if (Color != Color.Empty) { - jObject.Add("Color", (new SAMColor(Color)).ToJObject()); + jObject.Add("Color", (new SAMColor(Color)).ToJsonObject()); } if (Text != null) @@ -145,7 +147,7 @@ public virtual JObject ToJObject() if (Vector2D != null) { - jObject.Add("Vector2D", Vector2D.ToJObject()); + jObject.Add("Vector2D", Vector2D.ToJsonObject()); } return jObject; diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPoint.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPoint.cs index daa23d0..d1a889c 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPoint.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPoint.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Drawing; @@ -75,10 +77,10 @@ public UIMollierPoint(UIMollierPoint uIMollierPoint) } } - public UIMollierPoint(JObject jObject) + public UIMollierPoint(JsonObject jObject) : base(jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public UIMollierPoint(UIMollierProcess uIMollierProcess, ProcessReferenceType processReferenceType) @@ -95,16 +97,16 @@ public System.Guid Guid } } - public virtual bool FromJObject(JObject jObject) + public virtual bool FromJsonObject(JsonObject jObject) { - if (jObject == null || !base.FromJObject(jObject)) + if (jObject == null || !base.FromJsonObject(jObject)) { return false; } if (jObject.ContainsKey("UIMollierPointAppearance")) { - uIMollierPointAppearance = new UIMollierPointAppearance(jObject.Value("UIMollierPointAppearance")); + uIMollierPointAppearance = new UIMollierPointAppearance(jObject["UIMollierPointAppearance"] as JsonObject); } if (jObject.ContainsKey("Guid")) @@ -115,9 +117,9 @@ public virtual bool FromJObject(JObject jObject) return true; } - public virtual JObject ToJObject() + public virtual JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { return null; @@ -125,7 +127,7 @@ public virtual JObject ToJObject() if (uIMollierPointAppearance != null) { - result.Add("UIMollierPointAppearance", uIMollierPointAppearance.ToJObject()); + result.Add("UIMollierPointAppearance", uIMollierPointAppearance.ToJsonObject()); } if (guid != System.Guid.Empty) diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPointAppearance.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPointAppearance.cs index 94cf607..575d81c 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPointAppearance.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierPointAppearance.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using System.Drawing; @@ -66,14 +68,14 @@ public UIMollierPointAppearance(UIMollierPointAppearance uIMollierPointAppearanc } } - public UIMollierPointAppearance(JObject jObject) + public UIMollierPointAppearance(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - bool result = base.FromJObject(jObject); + bool result = base.FromJsonObject(jObject); if (!result) { return result; @@ -81,7 +83,7 @@ public override bool FromJObject(JObject jObject) if (jObject.ContainsKey("BorderColor")) { - JObject jObject_Color = jObject.Value("BorderColor"); + JsonObject jObject_Color = jObject["BorderColor"] as JsonObject; if (jObject_Color != null) { SAMColor sAMColor = new SAMColor(jObject_Color); @@ -94,15 +96,15 @@ public override bool FromJObject(JObject jObject) if (jObject.ContainsKey("BorderSize")) { - BorderSize = jObject.Value("BorderSize"); + BorderSize = jObject["BorderSize"]?.GetValue() ?? default(int); } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; @@ -110,7 +112,7 @@ public override JObject ToJObject() if (BorderColor != Color.Empty) { - result.Add("BorderColor", (new SAMColor(BorderColor)).ToJObject()); + result.Add("BorderColor", (new SAMColor(BorderColor)).ToJsonObject()); } result.Add("BorderSize", BorderSize); diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierProcess.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierProcess.cs index b1d34d3..a3249a4 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierProcess.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierProcess.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Drawing; @@ -79,15 +81,15 @@ public UIMollierProcess(UIMollierProcess uIMollierProcess) } } - public UIMollierProcess(JObject jObject) + public UIMollierProcess(JsonObject jObject) :base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - bool result = base.FromJObject(jObject); + bool result = base.FromJsonObject(jObject); if (!result) { return false; @@ -95,20 +97,20 @@ public override bool FromJObject(JObject jObject) if (jObject.ContainsKey("UIMollierPointAppearance_Start")) { - uIMollierPointAppearance_Start = Core.Query.IJSAMObject(jObject.Value("UIMollierPointAppearance_Start")) as UIMollierPointAppearance; + uIMollierPointAppearance_Start = Core.Query.IJSAMObject(jObject["UIMollierPointAppearance_Start"] as JsonObject) as UIMollierPointAppearance; } if (jObject.ContainsKey("UIMollierPointAppearance_End")) { - uIMollierPointAppearance_End = Core.Query.IJSAMObject(jObject.Value("UIMollierPointAppearance_End")) as UIMollierPointAppearance; + uIMollierPointAppearance_End = Core.Query.IJSAMObject(jObject["UIMollierPointAppearance_End"] as JsonObject) as UIMollierPointAppearance; } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return null; @@ -116,12 +118,12 @@ public override JObject ToJObject() if (uIMollierPointAppearance_Start != null) { - result.Add("UIMollierPointAppearance_Start", uIMollierPointAppearance_Start.ToJObject()); + result.Add("UIMollierPointAppearance_Start", uIMollierPointAppearance_Start.ToJsonObject()); } if (uIMollierPointAppearance_End != null) { - result.Add("UIMollierPointAppearance_End", uIMollierPointAppearance_End.ToJObject()); + result.Add("UIMollierPointAppearance_End", uIMollierPointAppearance_End.ToJsonObject()); } return result; diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierZone.cs b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierZone.cs index 555fca3..b7e57f2 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierZone.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Classes/UIMollierZone.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Mollier; using System.Drawing; @@ -45,10 +47,10 @@ public UIMollierZone(MollierZone mollierZone, UIMollierAppearance uIMollierAppea this.uIMollierAppearance = uIMollierAppearance?.Clone(); } - public UIMollierZone(JObject jObject) + public UIMollierZone(JsonObject jObject) : base(jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public IUIMollierAppearance UIMollierAppearance @@ -72,16 +74,16 @@ public System.Guid Guid } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { - if (jObject == null || !base.FromJObject(jObject)) + if (jObject == null || !base.FromJsonObject(jObject)) { return false; } if (jObject.ContainsKey("UIMollierAppearance")) { - uIMollierAppearance = new UIMollierAppearance(jObject.Value("UIMollierAppearance")); + uIMollierAppearance = new UIMollierAppearance(jObject["UIMollierAppearance"] as JsonObject); } if(jObject.ContainsKey("Guid")) @@ -92,9 +94,9 @@ public bool FromJObject(JObject jObject) return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) { @@ -103,7 +105,7 @@ public JObject ToJObject() if (uIMollierAppearance != null) { - result.Add("UIMollierAppearance", uIMollierAppearance.ToJObject()); + result.Add("UIMollierAppearance", uIMollierAppearance.ToJsonObject()); } if(guid != System.Guid.Empty) diff --git a/SAM_Mollier/SAM.Geometry.Mollier/Properties/AssemblyInfo.cs b/SAM_Mollier/SAM.Geometry.Mollier/Properties/AssemblyInfo.cs index 6a49c9e..c067996 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/Properties/AssemblyInfo.cs +++ b/SAM_Mollier/SAM.Geometry.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] diff --git a/SAM_Mollier/SAM.Geometry.Mollier/SAM.Geometry.Mollier.csproj b/SAM_Mollier/SAM.Geometry.Mollier/SAM.Geometry.Mollier.csproj index 586c522..233dda3 100644 --- a/SAM_Mollier/SAM.Geometry.Mollier/SAM.Geometry.Mollier.csproj +++ b/SAM_Mollier/SAM.Geometry.Mollier/SAM.Geometry.Mollier.csproj @@ -8,8 +8,6 @@ SAM.Geometry.Mollier SAM.Geometry.Mollier Copyright © 2024 - 1.0.0.0 - 1.0.0.0 false false @@ -27,7 +25,7 @@ - + diff --git a/SAM_Mollier/SAM.Weather.Mollier/Classes/WeatherMollierPoint.cs b/SAM_Mollier/SAM.Weather.Mollier/Classes/WeatherMollierPoint.cs index 1a6943f..d696c5d 100644 --- a/SAM_Mollier/SAM.Weather.Mollier/Classes/WeatherMollierPoint.cs +++ b/SAM_Mollier/SAM.Weather.Mollier/Classes/WeatherMollierPoint.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Mollier; using System; @@ -23,7 +25,7 @@ public WeatherMollierPoint(WeatherMollierPoint weatherMollierPoint) } } - public WeatherMollierPoint(JObject jObject) + public WeatherMollierPoint(JsonObject jObject) : base(jObject) { @@ -37,9 +39,9 @@ public DateTime DateTime } } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return null; @@ -50,16 +52,16 @@ public override JObject ToJObject() return result; } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if(!base.FromJObject(jObject)) + if(!base.FromJsonObject(jObject)) { return false; } if(jObject.ContainsKey("DateTime")) { - dateTime = jObject.Value("DateTime"); + dateTime = jObject["DateTime"]?.GetValue() ?? default(DateTime); } return true; diff --git a/SAM_Mollier/SAM.Weather.Mollier/Properties/AssemblyInfo.cs b/SAM_Mollier/SAM.Weather.Mollier/Properties/AssemblyInfo.cs index f2579b4..4a99e90 100644 --- a/SAM_Mollier/SAM.Weather.Mollier/Properties/AssemblyInfo.cs +++ b/SAM_Mollier/SAM.Weather.Mollier/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/SAM_Mollier/SAM.Weather.Mollier/SAM.Weather.Mollier.csproj b/SAM_Mollier/SAM.Weather.Mollier/SAM.Weather.Mollier.csproj index 307285a..1d05e45 100644 --- a/SAM_Mollier/SAM.Weather.Mollier/SAM.Weather.Mollier.csproj +++ b/SAM_Mollier/SAM.Weather.Mollier/SAM.Weather.Mollier.csproj @@ -6,8 +6,6 @@ SAM.Weather.Mollier SAM.Weather.Mollier Copyright © 2022 - 1.0.0.0 - 1.0.0.0 false false @@ -29,6 +27,6 @@ - + \ No newline at end of file