From e26b6231abacbb68179ca4daf943403bfadb59b4 Mon Sep 17 00:00:00 2001 From: konstantin Date: Thu, 5 Sep 2024 14:17:30 +0200 Subject: [PATCH] ci/fmt: switch from `dotnet-format` to `csharpier` (#520) * dotnet new tool-manifest * dotnet tool install csharpier * dotnet csharpier . * ci: switch from dotnet-format to csharpier * fmt: prettier dotnet-tools.json --------- Co-authored-by: Konstantin --- .config/dotnet-tools.json | 11 + .github/workflows/formatter.yml | 13 +- .../BenachrichtigungExtension.cs | 30 +- .../BusinessObjects/BusinessObject.cs | 5 +- .../Energiemenge/EnergiemengeExtension.cs | 449 ++++++++++++------ .../EnergiemengeExtensionCompleteness.cs | 124 +++-- .../EnergiemengeExtensionPlausibility.cs | 123 +++-- .../EnergiemengeExtensionSlicingHelper.cs | 136 ++++-- BO4E.Extensions/COM/COM.cs | 5 +- .../COM/PhysikalischerWertExtension.cs | 7 +- BO4E.Extensions/COM/VerbrauchExtension.cs | 153 ++++-- BO4E.Extensions/COM/ZeitraumExtension.cs | 2 +- .../ENUM/MengeneinheitExtension.cs | 38 +- BO4E.Reporting/CompletenessReport.cs | 41 +- BO4E.Reporting/PlausibilityReport.cs | 2 +- BO4E.Reporting/Report.cs | 94 ++-- BO4E/BO/Anfrage.cs | 5 +- BO4E/BO/Angebot.cs | 14 +- BO4E/BO/Ansprechpartner.cs | 8 +- BO4E/BO/Auftrag.cs | 13 +- BO4E/BO/AuftragsStorno.cs | 6 +- BO4E/BO/Avis.cs | 6 +- BO4E/BO/Benachrichtigung.cs | 3 + BO4E/BO/Berechnungsformel.cs | 3 +- BO4E/BO/Bilanzierung.cs | 45 +- BO4E/BO/BusinessObject.cs | 173 ++++--- BO4E/BO/Einspeisung.cs | 13 +- BO4E/BO/Energiemenge.cs | 62 ++- BO4E/BO/Entsperrauftrag.cs | 2 +- BO4E/BO/Geschaeftspartner.cs | 16 +- BO4E/BO/Handelsunstimmigkeit.cs | 7 +- BO4E/BO/Lokationszuordnung.cs | 6 +- BO4E/BO/MabisZaehlpunkt.cs | 11 +- BO4E/BO/Marktlokation.cs | 67 +-- BO4E/BO/Marktteilnehmer.cs | 3 +- BO4E/BO/Messlokation.cs | 21 +- BO4E/BO/Netzlokation.cs | 18 +- BO4E/BO/Preisblatt.cs | 2 +- BO4E/BO/PreisblattMessung.cs | 6 +- BO4E/BO/PreisblattNetznutzung.cs | 1 - BO4E/BO/PreisblattUmlagen.cs | 5 +- BO4E/BO/Rechnung.cs | 255 ++++++---- BO4E/BO/Reklamation.cs | 33 +- BO4E/BO/Sperrauftrag.cs | 3 +- BO4E/BO/SperrauftragsStorno.cs | 4 +- BO4E/BO/Statusbericht.cs | 1 + BO4E/BO/SteuerbareRessource.cs | 24 +- BO4E/BO/Summenzeitreihe.cs | 14 +- BO4E/BO/TechnischeRessource.cs | 12 +- BO4E/BO/Vertrag.cs | 73 +-- BO4E/BO/Wechsel.cs | 11 +- BO4E/BO/Zaehler.cs | 39 +- BO4E/BO/Zaehlzeitdefinition.cs | 6 +- BO4E/BoMapper.cs | 26 +- BO4E/COM/Abweichung.cs | 20 +- BO4E/COM/AbweichungsPosition.cs | 21 +- BO4E/COM/Adresse.cs | 8 +- BO4E/COM/Angebotsposition.cs | 7 +- BO4E/COM/Angebotsteil.cs | 20 +- BO4E/COM/Angebotsvariante.cs | 6 +- BO4E/COM/Aufgabe.cs | 14 +- BO4E/COM/AusgerollteZaehlzeit.cs | 8 +- BO4E/COM/Ausschreibungslos.cs | 2 +- BO4E/COM/Avisposition.cs | 3 +- BO4E/COM/COM.cs | 42 +- BO4E/COM/Erreichbarkeit.cs | 10 +- BO4E/COM/ExterneReferenz.cs | 35 +- BO4E/COM/Fehler.cs | 3 +- BO4E/COM/FehlerDetail.cs | 2 +- BO4E/COM/FehlerUrsache.cs | 4 +- BO4E/COM/Geraet.cs | 5 +- BO4E/COM/Handelsunstimmigkeitsbegruendung.cs | 5 +- BO4E/COM/Katasteradresse.cs | 2 +- BO4E/COM/Konfigurationsprodukt.cs | 13 +- BO4E/COM/Kostenblock.cs | 2 +- BO4E/COM/Kostenposition.cs | 5 +- BO4E/COM/Lastprofil.cs | 9 +- BO4E/COM/MarktpartnerDetails.cs | 20 +- BO4E/COM/Menge.cs | 7 +- BO4E/COM/Messlokationszuordnung.cs | 10 +- BO4E/COM/Messprodukt.cs | 14 +- BO4E/COM/Netznutzungsabrechnungsdaten.cs | 20 +- BO4E/COM/Notiz.cs | 8 +- BO4E/COM/PhysikalischerWert.cs | 12 +- BO4E/COM/PositionsAufAbschlag.cs | 2 +- BO4E/COM/Preis.cs | 2 +- BO4E/COM/Preisgarantie.cs | 2 +- BO4E/COM/Preisposition.cs | 4 +- BO4E/COM/Preisstaffel.cs | 2 +- BO4E/COM/Rechenschritt.cs | 10 +- BO4E/COM/Rechnungsposition.cs | 18 +- BO4E/COM/RechnungspositionFlat.cs | 20 +- BO4E/COM/RegionalePreisgarantie.cs | 2 +- BO4E/COM/RegionalePreisstaffel.cs | 2 +- BO4E/COM/RegionaleTarifpreisposition.cs | 2 +- BO4E/COM/RegionalerAufAbschlag.cs | 2 +- BO4E/COM/Regionskriterium.cs | 2 +- BO4E/COM/Rueckmeldungsposition.cs | 12 +- BO4E/COM/Rufnummer.cs | 2 +- BO4E/COM/Sigmoidparameter.cs | 2 +- BO4E/COM/StatusZusatzInformation.cs | 3 +- BO4E/COM/Steuerbetrag.cs | 7 +- BO4E/COM/Tagesparameter.cs | 8 +- BO4E/COM/Tarifberechnungsparameter.cs | 2 +- BO4E/COM/Tarifeinschraenkung.cs | 2 +- BO4E/COM/Tarifpreisposition.cs | 2 +- BO4E/COM/Unterschrift.cs | 2 +- BO4E/COM/Verbrauch.cs | 57 ++- BO4E/COM/Vertragskonditionen.cs | 47 +- BO4E/COM/Vertragsteil.cs | 12 +- BO4E/COM/Verwendungszweck.cs | 2 +- BO4E/COM/Vorauszahlung.cs | 10 +- BO4E/COM/Zaehlwerk.cs | 32 +- BO4E/COM/Zaehlzeit.cs | 12 +- BO4E/COM/Zaehlzeitregister.cs | 6 +- BO4E/COM/Zeitfenster.cs | 8 +- BO4E/COM/Zeitraum.cs | 7 +- BO4E/COM/Zeitreihenprodukt.cs | 10 +- BO4E/COM/Zustaendigkeit.cs | 2 +- BO4E/ENUM/AbgabeArt.cs | 2 +- BO4E/ENUM/Abweichungsgrund.cs | 7 +- BO4E/ENUM/Abwicklungsmodell.cs | 5 +- BO4E/ENUM/Aggregationsverantwortung.cs | 7 +- BO4E/ENUM/Anfragekategorie.cs | 10 +- BO4E/ENUM/Anfragetyp.cs | 6 +- BO4E/ENUM/Angebotsstatus.cs | 7 +- BO4E/ENUM/Anrede.cs | 5 +- BO4E/ENUM/ArithmetischeOperation.cs | 4 +- BO4E/ENUM/ArtikelIdTyp.cs | 7 +- BO4E/ENUM/AufAbschlagstyp.cs | 4 +- BO4E/ENUM/AufAbschlagsziel.cs | 7 +- BO4E/ENUM/Auftragsstatus.cs | 4 +- BO4E/ENUM/Auftragsstornogrund.cs | 4 +- BO4E/ENUM/Ausschreibungsportal.cs | 4 +- BO4E/ENUM/Ausschreibungsstatus.cs | 4 +- BO4E/ENUM/Ausschreibungstyp.cs | 4 +- BO4E/ENUM/AvisTyp.cs | 4 +- BO4E/ENUM/BDEWArtikelnummer.cs | 31 +- BO4E/ENUM/Bearbeitungsstatus.cs | 4 +- BO4E/ENUM/Befestigungsart.cs | 4 +- BO4E/ENUM/Bemessungsgroesse.cs | 7 +- BO4E/ENUM/BerechnungsformelAblehngrund.cs | 4 +- BO4E/ENUM/BerechnungsformelNotwendigkeit.cs | 5 +- BO4E/ENUM/BerichtStatus.cs | 7 +- BO4E/ENUM/Betriebszustand.cs | 7 +- BO4E/ENUM/BezeichnungSummenzeitreihe.cs | 18 +- BO4E/ENUM/Bilanzierungsmethode.cs | 7 +- BO4E/ENUM/BoTyp.cs | 4 +- BO4E/ENUM/DefinitionenNotwendigkeit.cs | 8 +- BO4E/ENUM/Dienstleistungstyp.cs | 41 +- BO4E/ENUM/EEGVermarktungsform.cs | 5 +- BO4E/ENUM/EMobilitaetsart.cs | 2 +- BO4E/ENUM/Energieflussrichtung.cs | 2 +- BO4E/ENUM/Energierichtung.cs | 4 +- BO4E/ENUM/ErmittlungLeistungsmaximum.cs | 4 +- BO4E/ENUM/Erzeugungsart.cs | 7 +- BO4E/ENUM/Fallgruppenzuordnung.cs | 8 +- BO4E/ENUM/FehlerCode.cs | 41 +- BO4E/ENUM/FehlerTyp.cs | 4 +- BO4E/ENUM/Fernschaltung.cs | 4 +- BO4E/ENUM/FernsteuerbarkeitStatus.cs | 5 +- BO4E/ENUM/Gasqualitaet.cs | 5 +- BO4E/ENUM/Gebiettyp.cs | 4 +- BO4E/ENUM/Geraeteart.cs | 14 +- BO4E/ENUM/Geraetemerkmal.cs | 5 +- BO4E/ENUM/Geraetetyp.cs | 3 +- BO4E/ENUM/Geschaeftspartnerrolle.cs | 3 +- BO4E/ENUM/GrundDerPrivilegierungNachEnFG.cs | 3 +- ...ndlageZurVerringerungDerUmlagenNachEnfg.cs | 4 +- BO4E/ENUM/Gueltigkeitstyp.cs | 4 +- BO4E/ENUM/HaeufigkeitZaehlzeit.cs | 4 +- BO4E/ENUM/Handelsunstimmigkeitsgrund.cs | 5 +- BO4E/ENUM/Handelsunstimmigkeitstyp.cs | 3 +- BO4E/ENUM/Kalkulationsmethode.cs | 1 - BO4E/ENUM/Kontaktart.cs | 2 +- BO4E/ENUM/Kostenklasse.cs | 7 +- BO4E/ENUM/Kundentyp.cs | 5 +- BO4E/ENUM/Landescode.cs | 5 +- .../LeistungsbeschreibungDesSteuerkanals.cs | 2 +- BO4E/ENUM/Leistungsbezeichung.cs | 16 + BO4E/ENUM/Lokationstyp.cs | 2 +- BO4E/ENUM/Marktrolle.cs | 2 +- BO4E/ENUM/Mengeneinheit.cs | 5 +- BO4E/ENUM/MesstechnischeEinordnung.cs | 2 +- BO4E/ENUM/Messwertstatus.cs | 7 +- BO4E/ENUM/NNRechnungstyp.cs | 5 +- BO4E/ENUM/Netznutzungszahler.cs | 3 +- BO4E/ENUM/Preismodell.cs | 2 +- BO4E/ENUM/Preisstatus.cs | 2 +- BO4E/ENUM/Profilart.cs | 7 +- BO4E/ENUM/Profiltyp.cs | 5 +- BO4E/ENUM/Profilverfahren.cs | 5 +- BO4E/ENUM/Prognosegrundlage.cs | 5 +- BO4E/ENUM/RechnungspositionsStatus.cs | 5 +- BO4E/ENUM/Rechnungsstatus.cs | 2 +- BO4E/ENUM/Rechnungstyp.cs | 11 +- BO4E/ENUM/Rollencodetyp.cs | 9 +- BO4E/ENUM/Servicetyp.cs | 2 +- BO4E/ENUM/SonderrechnungsArt.cs | 12 +- BO4E/ENUM/Sparte.cs | 5 +- BO4E/ENUM/Sperrauftragsablehngrund.cs | 14 +- BO4E/ENUM/Sperrauftragsart.cs | 5 +- BO4E/ENUM/Sperrauftragsverhinderungsgrund.cs | 7 +- BO4E/ENUM/Sperrstatus.cs | 6 +- BO4E/ENUM/Status.cs | 29 +- BO4E/ENUM/StatusArt.cs | 5 +- BO4E/ENUM/Steuerkennzeichen.cs | 3 + BO4E/ENUM/Tarifkalkulationsmethode.cs | 3 +- BO4E/ENUM/Tarifmerkmal.cs | 5 +- BO4E/ENUM/Tarifregionskriterium.cs | 3 +- BO4E/ENUM/Tarifstufe.cs | 10 +- BO4E/ENUM/Tariftyp.cs | 2 +- BO4E/ENUM/Tarifzeit.cs | 2 +- BO4E/ENUM/TechnischeRessourceNutzung.cs | 4 +- BO4E/ENUM/Themengebiet.cs | 2 +- BO4E/ENUM/UebermittelbarkeitZaehlzeit.cs | 2 +- BO4E/ENUM/Verbrauchsart.cs | 2 +- BO4E/ENUM/Vertragsart.cs | 2 +- BO4E/ENUM/Vertragsform.cs | 3 +- BO4E/ENUM/Vertragstatus.cs | 5 +- BO4E/ENUM/Verwendungszweck.cs | 2 +- BO4E/ENUM/Waehrungscode.cs | 3 +- BO4E/ENUM/Waehrungseinheit.cs | 3 +- BO4E/ENUM/Waermenutzung.cs | 5 +- BO4E/ENUM/WahlrechtPrognosegrundlage.cs | 1 + BO4E/ENUM/Wertermittlungsverfahren.cs | 2 +- BO4E/ENUM/Zaehlerauspraegung.cs | 2 +- BO4E/ENUM/ZaehlertypSpezifikation.cs | 2 +- BO4E/ENUM/ZaehlzeitdefinitionTyp.cs | 4 + BO4E/ENUM/Zeiteinheit.cs | 3 +- BO4E/ENUM/Zeitreihentyp.cs | 7 +- .../EnergyIdentificationCodeExtensions.cs | 61 ++- BO4E/UserPropertiesDataContractResolver.cs | 2 +- BO4E/UserPropertiesExtensions.cs | 67 ++- BO4E/meta/Bo4eUri.cs | 77 +-- BO4E/meta/BoKey.cs | 2 +- .../meta/BusinessObjectSerializationBinder.cs | 14 +- BO4E/meta/CentralEuropeStandardTime.cs | 6 +- BO4E/meta/DataCategoryAttribute.cs | 3 +- BO4E/meta/Defaults.cs | 4 +- BO4E/meta/FieldName.cs | 10 +- BO4E/meta/IOptionalGuid.cs | 2 +- BO4E/meta/IUserProperties.cs | 2 +- .../AutoNumberToStringConverter.cs | 10 +- .../GasqualitaetStringEnumConverter.cs | 45 +- .../LenientBo4eUriConverter.cs | 8 +- .../LenientDateTimeConverter.cs | 67 ++- .../LenientDictionaryConverter.cs | 27 +- .../LenientEnumListConverter.cs | 10 +- .../LenientGeraetemerkmalGasConverter.cs | 4 +- .../LenientJsonSerializerOptionsGenerator.cs | 52 +- .../LenientJsonSerializerSettingsGenerator.cs | 31 +- BO4E/meta/LenientConverters/LenientParsing.cs | 4 +- .../LenientStringToIntConverter.cs | 10 +- ...entSystemTextGeraetemerkmalGasConverter.cs | 8 +- .../LenientSystemTextJsonDateTimeConverter.cs | 240 +++++++--- .../LenientSystemTextJsonEnumListConverter.cs | 58 ++- ...ientSystemTextJsonStringToBoolConverter.cs | 6 +- ...nientSystemTextJsonStringToIntConverter.cs | 20 +- .../NullableEnumConverter.cs | 31 +- .../VerwendungszweckStringEnumConverter.cs | 49 +- BO4E/meta/MultiLangResolver.cs | 12 +- BO4E/meta/NonOfficialAttribute.cs | 15 +- BO4ETestProject/CreateTimeZoneJson.cs | 2 +- .../TestAbstractDeserialization.cs | 9 +- BO4ETestProject/TestAutoNumberConverter.cs | 8 +- BO4ETestProject/TestBOCOMDesign.cs | 229 ++++++--- BO4ETestProject/TestBOCOMGuids.cs | 33 +- BO4ETestProject/TestBo4eUri.cs | 121 +++-- BO4ETestProject/TestBoExpansion.cs | 18 +- BO4ETestProject/TestBoMapperSystemText.cs | 112 +++-- BO4ETestProject/TestCOMValidity.cs | 4 +- BO4ETestProject/TestEnergiemengeAdding.cs | 30 +- .../TestEnergyIdentificationCodeExtensions.cs | 8 +- BO4ETestProject/TestEnumMembers.cs | 41 +- BO4ETestProject/TestEnums.cs | 6 +- BO4ETestProject/TestExterneReferenzen.cs | 56 ++- .../TestGeraetemerkmalConverter.cs | 90 +++- BO4ETestProject/TestHelper/JsonHelper.cs | 54 +-- BO4ETestProject/TestJsonOrder.cs | 248 +++++----- BO4ETestProject/TestJsonSchemaGeneration.cs | 19 +- BO4ETestProject/TestMaLoMeLoId.cs | 4 +- BO4ETestProject/TestMultiLangJson.cs | 33 +- BO4ETestProject/TestNotizDeserialization.cs | 8 +- BO4ETestProject/TestNullable.cs | 23 +- BO4ETestProject/TestProtoFileGeneration.cs | 10 +- BO4ETestProject/TestProtobufAttributes.cs | 271 +++++++---- BO4ETestProject/TestProtobufSerialization.cs | 12 +- BO4ETestProject/TestSperrauftrag.cs | 33 +- BO4ETestProject/TestStringEnumConverter.cs | 262 +++++++--- BO4ETestProject/TestUserProperties.cs | 72 ++- BO4ETestProject/TestZeitfenster.cs | 2 - .../TestZeitraumDeserialization.cs | 30 +- SchemaGenerator/Program.cs | 48 +- .../EnergiemengeShowCaseTests.cs | 25 +- .../ShowCaseTests/VerbrauchShowCaseTests.cs | 10 +- .../TestBenachrichtigungExtension.cs | 17 +- TestBO4E.Extensions/TestCloningExtension.cs | 20 +- .../TestEnergiemengeExtension.cs | 27 +- .../TestEnergiemengeExtensionCompleteness.cs | 379 ++++++++++----- .../TestEnergiemengeExtensionPlausibility.cs | 14 +- .../TestMengeneinheitExtension.cs | 16 +- TestBO4E.Extensions/TestVerbrauchExtension.cs | 199 +++++--- .../CompletenessReportShowCaseTests.cs | 27 +- .../TestCompletenessReportSorting.cs | 18 +- TestBO4E.Reporting/TestReportToCsv.cs | 236 +++++---- 306 files changed, 4682 insertions(+), 2732 deletions(-) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..02da728d --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,11 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "csharpier": { + "version": "0.29.1", + "commands": ["dotnet-csharpier"], + "rollForward": false + } + } +} diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml index e1d2d7f1..497b5da4 100644 --- a/.github/workflows/formatter.yml +++ b/.github/workflows/formatter.yml @@ -1,4 +1,4 @@ -name: dotnet-format +name: csharpier on: [push, pull_request] @@ -7,12 +7,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup .NET 6 + - name: Setup .NET 8 uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.100 - - name: Install dotnet-format - run: | - dotnet tool install -g dotnet-format - - name: Run dotnet-format - run: dotnet-format BO4E-dotnet.sln --check + - name: Restore .NET tools + run: dotnet tool restore + - name: Run CSharpier + run: dotnet csharpier BO4E-dotnet.sln --check diff --git a/BO4E.Extensions/BusinessObjects/Benachrichtigung/BenachrichtigungExtension.cs b/BO4E.Extensions/BusinessObjects/Benachrichtigung/BenachrichtigungExtension.cs index ac34b539..c7d66b1f 100644 --- a/BO4E.Extensions/BusinessObjects/Benachrichtigung/BenachrichtigungExtension.cs +++ b/BO4E.Extensions/BusinessObjects/Benachrichtigung/BenachrichtigungExtension.cs @@ -18,11 +18,7 @@ public static class BenachrichtigungExtension /// public static bool Has(this BO.Benachrichtigung b, string key, string value) { - return Has(b, new GenericStringStringInfo - { - KeyColumn = key, - Value = value - }); + return Has(b, new GenericStringStringInfo { KeyColumn = key, Value = value }); } /// @@ -73,8 +69,14 @@ public static bool Has(this BO.Benachrichtigung b, string key) /// true if there's an info object with given key of type /// fulfilling or there's no such property but is true /// - public static bool Has(this BO.Benachrichtigung b, string keyName, Predicate predicate, - bool passByDefault = true, TypeConverter typeConverter = null) where T : IComparable + public static bool Has( + this BO.Benachrichtigung b, + string keyName, + Predicate predicate, + bool passByDefault = true, + TypeConverter typeConverter = null + ) + where T : IComparable { if (!b.Has(keyName)) { @@ -94,9 +96,7 @@ public static bool Has(this BO.Benachrichtigung b, string keyName, Predicate< return predicate(value); } } - catch (NotSupportedException) - { - } + catch (NotSupportedException) { } return false; } @@ -108,7 +108,10 @@ public static bool Has(this BO.Benachrichtigung b, string keyName, Predicate< /// Benachrichtigung /// set true to overwrite userProperties with same key // ToDo: make method generic MoveInfosTouserProperties(...) - public static void MoveInfosToUserProperties(this BO.Benachrichtigung b, bool overwriteExistingKeys = false) + public static void MoveInfosToUserProperties( + this BO.Benachrichtigung b, + bool overwriteExistingKeys = false + ) { if (b.Infos != null && b.Infos.Count > 0) { @@ -124,11 +127,10 @@ public static void MoveInfosToUserProperties(this BO.Benachrichtigung b, bool ov b.UserProperties.Remove(info.KeyColumn); } - b.UserProperties.Add(info.KeyColumn, - info.Value); // might throw exception if key exists and !overwriteExistingKeys. That's ok. + b.UserProperties.Add(info.KeyColumn, info.Value); // might throw exception if key exists and !overwriteExistingKeys. That's ok. } b.Infos = null; // set to null after all elements have been moved } } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/BusinessObjects/BusinessObject.cs b/BO4E.Extensions/BusinessObjects/BusinessObject.cs index fa70540c..75515bb6 100644 --- a/BO4E.Extensions/BusinessObjects/BusinessObject.cs +++ b/BO4E.Extensions/BusinessObjects/BusinessObject.cs @@ -14,8 +14,9 @@ public static class BusinessObjectExtensions /// Type of the BusinessObject /// the BO that is copied /// the deep copy - public static T DeepClone(this T source) where T : BusinessObject + public static T DeepClone(this T source) + where T : BusinessObject { return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source)); } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs index fbdf07ef..5e5fdd0f 100644 --- a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs +++ b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs @@ -1,18 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using BO4E.COM; using BO4E.ENUM; using BO4E.Extensions.COM; using BO4E.Extensions.ENUM; using BO4E.Reporting; - using Itenso.TimePeriod; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - using static BO4E.Extensions.COM.VerbrauchExtension; - namespace BO4E.Extensions.BusinessObjects.Energiemenge; /// Do calculations on top of an Energiemenge BO4E. @@ -20,12 +17,16 @@ public static partial class EnergiemengeExtension { private const decimal QUASI_ZERO = 0.00000000001M; - private const string SAP_SANITIZED_USERPROPERTY_KEY = "sapSanitized"; - private static readonly Func> PurityGrouper = - v => new Tuple(v.Wertermittlungsverfahren, v.Einheit, - v.Obiskennzahl); + private static readonly Func< + Verbrauch, + Tuple + > PurityGrouper = v => new Tuple( + v.Wertermittlungsverfahren, + v.Einheit, + v.Obiskennzahl + ); /// /// Get Zeitraum covered by Energiemenge. @@ -40,7 +41,7 @@ public static Zeitraum GetZeitraum(this BO.Energiemenge menge) var zeitraum = new Zeitraum { Startdatum = GetMinDate(menge), - Enddatum = GetMaxDate(menge) + Enddatum = GetMaxDate(menge), }; return zeitraum; } @@ -59,7 +60,6 @@ public static TimeRange GetTimeRange(this BO.Energiemenge menge) return new TimeRange(menge.GetMinDate().UtcDateTime, menge.GetMaxDate().UtcDateTime); } - /* * If GetMinDate() or GetMaxDate() throws an InvalidOperationException you shouldn't catch * it here but allow the programmer to handle it higher up in the stack trace. @@ -90,7 +90,10 @@ private static DateTimeOffset GetMaxDate(this BO.Energiemenge em) /// Tuple of consumption value and unit of measurement public static Tuple GetTotalConsumption(this BO.Energiemenge em) { - return GetConsumption(em, new TimeRange(em.GetMinDate().UtcDateTime, em.GetMaxDate().UtcDateTime)); + return GetConsumption( + em, + new TimeRange(em.GetMinDate().UtcDateTime, em.GetMaxDate().UtcDateTime) + ); } /// @@ -101,8 +104,12 @@ public static Tuple GetTotalConsumption(this BO.Energiem /// OBIS /// unit of measurement /// consumption value - public static decimal GetTotalConsumption(this BO.Energiemenge em, - Wertermittlungsverfahren wev, string obiskennzahl, Mengeneinheit me) + public static decimal GetTotalConsumption( + this BO.Energiemenge em, + Wertermittlungsverfahren wev, + string obiskennzahl, + Mengeneinheit me + ) { return em.GetConsumption(em.GetTimeRange(), wev, obiskennzahl, me); } @@ -113,7 +120,10 @@ public static decimal GetTotalConsumption(this BO.Energiemenge em, /// Energiemenge /// time reference frame /// Tuple of consumption value and automatically determined unit of measurement - public static Tuple GetConsumption(this BO.Energiemenge em, ITimeRange reference) + public static Tuple GetConsumption( + this BO.Energiemenge em, + ITimeRange reference + ) { if (!IsPure(em)) { @@ -125,17 +135,25 @@ public static Tuple GetConsumption(this BO.Energiemenge return Tuple.Create(0.0M, Mengeneinheit.ANZAHL); } - ISet einheiten = new HashSet(em.Energieverbrauch.Select(x => x.Einheit)); + ISet einheiten = new HashSet( + em.Energieverbrauch.Select(x => x.Einheit) + ); if (einheiten.Count > 1) // z.B. kWh und Wh oder Monat und Jahr... Die liefern IsPure==true. { - throw new NotImplementedException("Converting different units of same type is not supported yet."); + throw new NotImplementedException( + "Converting different units of same type is not supported yet." + ); } var v = em.Energieverbrauch.First(); - var consumption = em.GetConsumption(reference, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit); + var consumption = em.GetConsumption( + reference, + v.Wertermittlungsverfahren, + v.Obiskennzahl, + v.Einheit + ); return Tuple.Create(consumption, v.Einheit); - } /// @@ -150,18 +168,37 @@ public static Tuple GetConsumption(this BO.Energiemenge /// the consumption within the give time slice in the unit passed as /// /// - public static decimal GetConsumption(this BO.Energiemenge em, ITimeRange reference, - Wertermittlungsverfahren? wev, string obiskennzahl, Mengeneinheit me) + public static decimal GetConsumption( + this BO.Energiemenge em, + ITimeRange reference, + Wertermittlungsverfahren? wev, + string obiskennzahl, + Mengeneinheit me + ) { if (!me.IsExtensive()) { throw new ArgumentException( - $"The Mengeneinheit {me} isn't extensive. Calculating a consumption doesn't make sense."); + $"The Mengeneinheit {me} isn't extensive. Calculating a consumption doesn't make sense." + ); } - return em.Energieverbrauch - .Where(v => v.Wertermittlungsverfahren == wev && v.Obiskennzahl == obiskennzahl && v.Einheit == me) - .Sum(v => GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, false) * v.Wert); + return em + .Energieverbrauch.Where(v => + v.Wertermittlungsverfahren == wev + && v.Obiskennzahl == obiskennzahl + && v.Einheit == me + ) + .Sum(v => + GetOverlapFactor( + new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ), + reference, + false + ) * v.Wert + ); } /// @@ -172,7 +209,6 @@ public static decimal GetConsumption(this BO.Energiemenge em, ITimeRange referen /// new Energiemenge object with normalised consumption values public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target = 1.0M) { - BO.Energiemenge result; decimal scalingFactor; Tuple totalConsumption; @@ -188,12 +224,15 @@ public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target scalingFactor = 0.0M; } - Parallel.ForEach(result.Energieverbrauch.Where(v => v.Einheit == totalConsumption.Item2), - v => { v.Wert = scalingFactor * v.Wert; }); - + Parallel.ForEach( + result.Energieverbrauch.Where(v => v.Einheit == totalConsumption.Item2), + v => + { + v.Wert = scalingFactor * v.Wert; + } + ); return result; - } /// @@ -208,7 +247,8 @@ public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target if (!me.IsIntensive()) { throw new ArgumentException( - $"The Mengeneinheit {me} isn't intensive. Calculating the value for a specific point in time doesn't make sense."); + $"The Mengeneinheit {me} isn't intensive. Calculating the value for a specific point in time doesn't make sense." + ); } decimal? result = null; @@ -246,7 +286,10 @@ public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target } var v = em.Energieverbrauch.First(); - return Tuple.Create(em.GetAverage(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit), v.Einheit); + return Tuple.Create( + em.GetAverage(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit), + v.Einheit + ); } /// @@ -260,8 +303,12 @@ public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target /// The average for the given Mengeneinheit for the Energiemenge object or null if there was no Verbrauch for the /// given Mengeneinheit. /// - public static decimal? GetAverage(this BO.Energiemenge em, - Wertermittlungsverfahren? wev, string obiskennzahl, Mengeneinheit me) + public static decimal? GetAverage( + this BO.Energiemenge em, + Wertermittlungsverfahren? wev, + string obiskennzahl, + Mengeneinheit me + ) { return em.GetAverage(em.GetTimeRange(), wev, obiskennzahl, me); } @@ -275,14 +322,26 @@ public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target /// OBIS /// an extensive or intensive unit /// the average value or null if no Verbrauch overlapped with the specified time interval - public static decimal? GetAverage(this BO.Energiemenge em, TimeRange reference, - Wertermittlungsverfahren? wev, string obiskennzahl, Mengeneinheit me) + public static decimal? GetAverage( + this BO.Energiemenge em, + TimeRange reference, + Wertermittlungsverfahren? wev, + string obiskennzahl, + Mengeneinheit me + ) { decimal? result = null; var overallDenominator = 0.0M; foreach (var v in em.Energieverbrauch.Where(v => v.Einheit == me)) { - var overlapFactor = GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, true); + var overlapFactor = GetOverlapFactor( + new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ), + reference, + true + ); if (result.HasValue) { result += overlapFactor * v.Wert; @@ -322,40 +381,56 @@ public static IList GetMissingTimeRanges(this BO.Energiemenge em) /// OBIS-Kennzahl /// Mengeneinheit /// - public static List GetMissingTimeRanges(this BO.Energiemenge em, ITimeRange reference, - Wertermittlungsverfahren? wev, string obis, Mengeneinheit me) + public static List GetMissingTimeRanges( + this BO.Energiemenge em, + ITimeRange reference, + Wertermittlungsverfahren? wev, + string obis, + Mengeneinheit me + ) { - IDictionary, Verbrauch> filteredVerbrauch; - filteredVerbrauch = em.Energieverbrauch - .Where(v => v.Wertermittlungsverfahren == wev && v.Obiskennzahl == obis && v.Einheit == me) - .ToDictionary(v => new Tuple(v.Startdatum, v.Enddatum), v => v); - + filteredVerbrauch = em + .Energieverbrauch.Where(v => + v.Wertermittlungsverfahren == wev && v.Obiskennzahl == obis && v.Einheit == me + ) + .ToDictionary( + v => new Tuple(v.Startdatum, v.Enddatum), + v => v + ); if (filteredVerbrauch.Count < 2) { - throw new ArgumentException("Not enough entries in energieverbrauch to determine periodicity."); + throw new ArgumentException( + "Not enough entries in energieverbrauch to determine periodicity." + ); } if (!IsEvenlySpaced(em, reference, wev, obis, me, true)) { throw new ArgumentException( - "The provided Energiemenge is not evenly spaced although gaps are allowed."); + "The provided Energiemenge is not evenly spaced although gaps are allowed." + ); } var periodicity = GetTimeSpans(em, wev, obis, me).Min(); if ( - Math.Abs((reference.Start - em.GetMinDate()).TotalMilliseconds % periodicity.TotalMilliseconds) != - 0) + Math.Abs( + (reference.Start - em.GetMinDate()).TotalMilliseconds + % periodicity.TotalMilliseconds + ) != 0 + ) { throw new ArgumentException( - $"The absolute difference between reference.start ({reference.Start}) and the minimal date time in the Energiemenge ({em.GetMinDate()}) has to be an integer multiple of the periodicity {periodicity.TotalMilliseconds} but was {(reference.Start - em.GetMinDate()).TotalMilliseconds}."); + $"The absolute difference between reference.start ({reference.Start}) and the minimal date time in the Energiemenge ({em.GetMinDate()}) has to be an integer multiple of the periodicity {periodicity.TotalMilliseconds} but was {(reference.Start - em.GetMinDate()).TotalMilliseconds}." + ); } // since it's assured, that the energieverbrauch entries are evenly spaced it doesn't matter which entry we use to determine the duration. - var duration = filteredVerbrauch.Values.Min(v => v.Enddatum) - - filteredVerbrauch.Values.Min(v => v.Startdatum); + var duration = + filteredVerbrauch.Values.Min(v => v.Enddatum) + - filteredVerbrauch.Values.Min(v => v.Startdatum); var result = new List(); for (var dt = reference.Start; dt < reference.End; dt += periodicity) @@ -374,18 +449,18 @@ public static List GetMissingTimeRanges(this BO.Energiemenge em, ITim //using (MiniProfiler.Current.Step("linq where on filtered verbrauch")) //{ - if (!filteredVerbrauch.ContainsKey( - new Tuple(dt, - dt + duration))) // Where(v => v.startdatum == dt && v.enddatum == dt + duration).Any()) + if ( + !filteredVerbrauch.ContainsKey( + new Tuple(dt, dt + duration) + ) + ) // Where(v => v.startdatum == dt && v.enddatum == dt + duration).Any()) { result.Add(new TimeRange(dt, (dt + duration).Value)); } //} } - return result; - } /// @@ -399,11 +474,18 @@ public static List GetMissingTimeRanges(this BO.Energiemenge em, Time if (!em.IsPure()) { throw new ArgumentException( - "The Energiemenge you provided is not pure. Consider using the overloaded method."); + "The Energiemenge you provided is not pure. Consider using the overloaded method." + ); } var v = em.Energieverbrauch.FirstOrDefault(); - return GetMissingTimeRanges(em, reference, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit); + return GetMissingTimeRanges( + em, + reference, + v.Wertermittlungsverfahren, + v.Obiskennzahl, + v.Einheit + ); } /// @@ -419,14 +501,19 @@ public static List GetMissingTimeRanges(this BO.Energiemenge em, Time /// True, if all energieverbrauch entries have the same length and their start and enddatum are evenly spaced. /// Also true, if there less than 2 entries in the energieverbrauch array. /// - public static bool IsEvenlySpaced(this BO.Energiemenge em, ITimeRange reference, Wertermittlungsverfahren? wev, - string obis, Mengeneinheit me, bool allowGaps = false) + public static bool IsEvenlySpaced( + this BO.Energiemenge em, + ITimeRange reference, + Wertermittlungsverfahren? wev, + string obis, + Mengeneinheit me, + bool allowGaps = false + ) { HashSet startEndDatumPeriods; startEndDatumPeriods = GetTimeSpans(em, wev, obis, me); - if (startEndDatumPeriods.Count < 2) { return true; @@ -445,7 +532,6 @@ public static bool IsEvenlySpaced(this BO.Energiemenge em, ITimeRange reference, return false; } - return true; } @@ -468,21 +554,32 @@ public static bool IsEvenlySpaced(this BO.Energiemenge em, bool allowGaps = fals var combinations = GetWevObisMeCombinations(em); foreach (var combo in combinations) - if (!em.IsEvenlySpaced(em.GetTimeRange(), combo.Item1, combo.Item2, combo.Item3, allowGaps)) + if ( + !em.IsEvenlySpaced( + em.GetTimeRange(), + combo.Item1, + combo.Item2, + combo.Item3, + allowGaps + ) + ) { return false; } - return true; } var v = em.Energieverbrauch.FirstOrDefault(); - return em.IsEvenlySpaced(em.GetTimeRange(), v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit, - allowGaps); + return em.IsEvenlySpaced( + em.GetTimeRange(), + v.Wertermittlungsverfahren, + v.Obiskennzahl, + v.Einheit, + allowGaps + ); } - private static HashSet GetTimeSpans(this BO.Energiemenge em) { var result = new HashSet(); @@ -490,25 +587,44 @@ private static HashSet GetTimeSpans(this BO.Energiemenge em) vlist.Sort(new VerbrauchDateTimeComparer()); for (var i = 1; i < vlist.Count; i++) { - result.Add((vlist[i].Startdatum ?? DateTimeOffset.MinValue) - (vlist[i - 1].Startdatum ?? DateTimeOffset.MinValue)); - result.Add((vlist[i].Enddatum ?? DateTimeOffset.MinValue) - (vlist[i - 1].Enddatum ?? DateTimeOffset.MinValue)); + result.Add( + (vlist[i].Startdatum ?? DateTimeOffset.MinValue) + - (vlist[i - 1].Startdatum ?? DateTimeOffset.MinValue) + ); + result.Add( + (vlist[i].Enddatum ?? DateTimeOffset.MinValue) + - (vlist[i - 1].Enddatum ?? DateTimeOffset.MinValue) + ); } return result; } - private static HashSet GetTimeSpans(this BO.Energiemenge em, Wertermittlungsverfahren? wev, - string obis, Mengeneinheit me) + private static HashSet GetTimeSpans( + this BO.Energiemenge em, + Wertermittlungsverfahren? wev, + string obis, + Mengeneinheit me + ) { var result = new HashSet(); var vlist = new List(em.Energieverbrauch); vlist.Sort(new VerbrauchDateTimeComparer()); - vlist = vlist.Where(v => v.Wertermittlungsverfahren == wev && v.Obiskennzahl == obis && v.Einheit == me) + vlist = vlist + .Where(v => + v.Wertermittlungsverfahren == wev && v.Obiskennzahl == obis && v.Einheit == me + ) .ToList(); for (var i = 1; i < vlist.Count; i++) { - result.Add((vlist[i].Startdatum ?? DateTimeOffset.MinValue) - (vlist[i - 1].Startdatum ?? DateTimeOffset.MinValue)); - result.Add((vlist[i].Enddatum ?? DateTimeOffset.MinValue) - (vlist[i - 1].Enddatum ?? DateTimeOffset.MinValue)); + result.Add( + (vlist[i].Startdatum ?? DateTimeOffset.MinValue) + - (vlist[i - 1].Startdatum ?? DateTimeOffset.MinValue) + ); + result.Add( + (vlist[i].Enddatum ?? DateTimeOffset.MinValue) + - (vlist[i - 1].Enddatum ?? DateTimeOffset.MinValue) + ); } return result; @@ -519,12 +635,15 @@ private static HashSet GetTimeSpans(this BO.Energiemenge em, Wertermit /// /// em /// A Set of tuples of all (Wertermittlungsverfahren, OBIS, Mengeneinheit) combinations - public static ISet> GetWevObisMeCombinations( - this BO.Energiemenge em) + public static ISet< + Tuple + > GetWevObisMeCombinations(this BO.Energiemenge em) { return new HashSet>( - em.Energieverbrauch - .Select(v => Tuple.Create(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit))); + em.Energieverbrauch.Select(v => + Tuple.Create(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit) + ) + ); } /// @@ -537,9 +656,22 @@ private static HashSet GetTimeSpans(this BO.Energiemenge em, Wertermit public static decimal GetJointCoverage(this BO.Energiemenge em, TimeRange reference) { var combinations = GetWevObisMeCombinations(em); - var jointCoverage = em.Energieverbrauch - .Where(v => combinations.Contains(Tuple.Create(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit))) - .Sum(v => GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, true)); + var jointCoverage = em + .Energieverbrauch.Where(v => + combinations.Contains( + Tuple.Create(v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit) + ) + ) + .Sum(v => + GetOverlapFactor( + new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ), + reference, + true + ) + ); return jointCoverage - (combinations.Count - 1); } @@ -551,10 +683,11 @@ public static decimal GetJointCoverage(this BO.Energiemenge em, TimeRange refere /// value between 0 (only coverage for 1 point in time) and 1.0 (100% coverage) public static decimal GetCoverage(this BO.Energiemenge em, ITimeRange reference) { - if (!IsPure(em)) { - throw new ArgumentException("The Energiemenge is not pure. Cannot determine parameters."); + throw new ArgumentException( + "The Energiemenge is not pure. Cannot determine parameters." + ); } if (em.Energieverbrauch.Count == 0) @@ -564,7 +697,6 @@ public static decimal GetCoverage(this BO.Energiemenge em, ITimeRange reference) var v = em.Energieverbrauch.First(); return em.GetCoverage(reference, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit); - } /// @@ -588,16 +720,33 @@ public static decimal GetCoverage(this BO.Energiemenge em) /// type of measurement /// post decimals /// value between 0 (no overlap) and 1.0 (100% overlap) - public static decimal GetCoverage(this BO.Energiemenge em, ITimeRange reference, - Wertermittlungsverfahren? wev, string obisKz, Mengeneinheit mengeneinheit, int decimalRounding = 10) + public static decimal GetCoverage( + this BO.Energiemenge em, + ITimeRange reference, + Wertermittlungsverfahren? wev, + string obisKz, + Mengeneinheit mengeneinheit, + int decimalRounding = 10 + ) { decimal exactResult; - exactResult = em.Energieverbrauch - .Where(v => v.Einheit == mengeneinheit && v.Obiskennzahl == obisKz && - v.Wertermittlungsverfahren == wev) - .Sum(v => GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, true)); - + exactResult = em + .Energieverbrauch.Where(v => + v.Einheit == mengeneinheit + && v.Obiskennzahl == obisKz + && v.Wertermittlungsverfahren == wev + ) + .Sum(v => + GetOverlapFactor( + new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ), + reference, + true + ) + ); return Math.Round(exactResult, decimalRounding); } @@ -614,7 +763,10 @@ public static decimal GetCoverage(this BO.Energiemenge em, ITimeRange reference, /// public static bool IsContinuous(this BO.Energiemenge em) { - return IsContinuous(em, new TimeRange(em.GetMinDate().UtcDateTime, em.GetMaxDate().UtcDateTime)); + return IsContinuous( + em, + new TimeRange(em.GetMinDate().UtcDateTime, em.GetMaxDate().UtcDateTime) + ); } /// @@ -625,28 +777,39 @@ public static bool IsContinuous(this BO.Energiemenge em) /// true iff Energiemenge has defined value for every point in time range, false otherwise public static bool IsContinuous(this BO.Energiemenge em, TimeRange reference) { - return Math.Abs(em.Energieverbrauch.Sum(v => - GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, true)) - 1.0M) < QUASI_ZERO; - } - - private static decimal GetOverlapFactor(TimeRange period, ITimeRange reference, bool toReference) - { - var periods = new TimePeriodCollection - { - reference, - period - }; + return Math.Abs( + em.Energieverbrauch.Sum(v => + GetOverlapFactor( + new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ), + reference, + true + ) + ) - 1.0M + ) < QUASI_ZERO; + } + + private static decimal GetOverlapFactor( + TimeRange period, + ITimeRange reference, + bool toReference + ) + { + var periods = new TimePeriodCollection { reference, period }; var periodIntersector = new TimePeriodIntersector(); var intersectedPeriods = periodIntersector.IntersectPeriods(periods); try { if (toReference) { - return (decimal)intersectedPeriods.TotalDuration.TotalSeconds / - (decimal)reference.Duration.TotalSeconds; + return (decimal)intersectedPeriods.TotalDuration.TotalSeconds + / (decimal)reference.Duration.TotalSeconds; } - return (decimal)intersectedPeriods.TotalDuration.TotalSeconds / (decimal)period.Duration.TotalSeconds; + return (decimal)intersectedPeriods.TotalDuration.TotalSeconds + / (decimal)period.Duration.TotalSeconds; } catch (DivideByZeroException) { @@ -668,9 +831,10 @@ public static bool IsPure(this BO.Energiemenge em, bool checkUserProperties = fa { bool basicPurity; - basicPurity = em.IsPureMengeneinheit() && em.IsPureObisKennzahl() && - em.IsPureWertermittlungsverfahren(); - + basicPurity = + em.IsPureMengeneinheit() + && em.IsPureObisKennzahl() + && em.IsPureWertermittlungsverfahren(); if (basicPurity && checkUserProperties) { @@ -688,9 +852,7 @@ public static bool IsPure(this BO.Energiemenge em, bool checkUserProperties = fa /// true iff the Energiemenge->energieverbrauch list has at most one distinct Wertermittlungsverfahren public static bool IsPureWertermittlungsverfahren(this BO.Energiemenge em) { - return em.Energieverbrauch.Select(v => v.Wertermittlungsverfahren).Distinct().Count() <= 1; - } /// @@ -700,9 +862,7 @@ public static bool IsPureWertermittlungsverfahren(this BO.Energiemenge em) /// true iff the Energiemenge->energieverbrauch list has at most one distinct Obiskennzahl public static bool IsPureObisKennzahl(this BO.Energiemenge em) { - return em.Energieverbrauch.Select(v => v.Obiskennzahl).Distinct().Count() <= 1; - } /// @@ -713,35 +873,35 @@ public static bool IsPureObisKennzahl(this BO.Energiemenge em) /// public static bool IsPureUserProperties(this BO.Energiemenge em) { - - ISet upKeys = new HashSet(em.Energieverbrauch.Where(v => v.UserProperties != null) - .SelectMany(v => v.UserProperties.Keys)); + ISet upKeys = new HashSet( + em.Energieverbrauch.Where(v => v.UserProperties != null) + .SelectMany(v => v.UserProperties.Keys) + ); var values = new Dictionary(); // ToDo: make it nice. foreach (var v in em.Energieverbrauch.Where(v => v.UserProperties != null)) - foreach (var key in upKeys) - if (v.UserProperties.TryGetValue(key, out var rawValue)) + foreach (var key in upKeys) + if (v.UserProperties.TryGetValue(key, out var rawValue)) + { + if (values.TryGetValue(key, out var onlyValue)) { - if (values.TryGetValue(key, out var onlyValue)) + if (rawValue == null && onlyValue != null) { - if (rawValue == null && onlyValue != null) - { - return false; - } - - if (rawValue != null && !rawValue.Equals(onlyValue)) - { - return false; - } + return false; } - else + + if (rawValue != null && !rawValue.Equals(onlyValue)) { - values.Add(key, rawValue); + return false; } } + else + { + values.Add(key, rawValue); + } + } return true; - } /// @@ -751,7 +911,6 @@ public static bool IsPureUserProperties(this BO.Energiemenge em) /// true iff the Energiemenge->energieverbrauch list does only contain entries with mutually convertible units public static bool IsPureMengeneinheit(this BO.Energiemenge em) { - if (em.Energieverbrauch.Select(v => v.Einheit).Distinct().Count() <= 1) { return true; @@ -759,7 +918,6 @@ public static bool IsPureMengeneinheit(this BO.Energiemenge em) var me1 = em.Energieverbrauch.Select(v => v.Einheit).First(); return em.Energieverbrauch.Select(v => v.Einheit).All(me2 => me1.IsConvertibleTo(me2)); - } /// @@ -809,7 +967,6 @@ public static bool IsExtensive(this BO.Energiemenge em) return result; } - /// /// Apply to the . /// @@ -824,21 +981,15 @@ public static void Detangle(this BO.Energiemenge em) private class BasicVerbrauchDateTimeComparer : IComparer { - int IComparer.Compare(CompletenessReport.BasicVerbrauch x, - CompletenessReport.BasicVerbrauch y) + int IComparer.Compare( + CompletenessReport.BasicVerbrauch x, + CompletenessReport.BasicVerbrauch y + ) { - var vx = new Verbrauch - { - Startdatum = x.Startdatum, - Enddatum = x.Enddatum - }; - var vy = new Verbrauch - { - Startdatum = y.Startdatum, - Enddatum = y.Enddatum - }; + var vx = new Verbrauch { Startdatum = x.Startdatum, Enddatum = x.Enddatum }; + var vy = new Verbrauch { Startdatum = y.Startdatum, Enddatum = y.Enddatum }; IComparer cv = new VerbrauchDateTimeComparer(); return cv.Compare(vx, vy); } } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionCompleteness.cs b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionCompleteness.cs index ac83b47c..408b5474 100644 --- a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionCompleteness.cs +++ b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionCompleteness.cs @@ -1,16 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; using BO4E.COM; using BO4E.ENUM; using BO4E.Reporting; - using Itenso.TimePeriod; - using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; -using System.Linq; - namespace BO4E.Extensions.BusinessObjects.Energiemenge; public static partial class EnergiemengeExtension @@ -23,13 +20,20 @@ public static partial class EnergiemengeExtension /// Energiemenge /// configuration container /// - public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, - CompletenessReport.CompletenessReportConfiguration config) + public static CompletenessReport GetCompletenessReport( + this BO.Energiemenge em, + CompletenessReport.CompletenessReportConfiguration config + ) { return em.GetCompletenessReport( - new TimeRange(config.ReferenceTimeFrame.Startdatum.Value.UtcDateTime, - config.ReferenceTimeFrame.Enddatum.Value.UtcDateTime), config.Wertermittlungsverfahren, config.Obis, - config.Einheit); + new TimeRange( + config.ReferenceTimeFrame.Startdatum.Value.UtcDateTime, + config.ReferenceTimeFrame.Enddatum.Value.UtcDateTime + ), + config.Wertermittlungsverfahren, + config.Obis, + config.Einheit + ); } /// @@ -38,7 +42,10 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, /// Energiemenge /// reference time frame /// - public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, ITimeRange reference) + public static CompletenessReport GetCompletenessReport( + this BO.Energiemenge em, + ITimeRange reference + ) { var combis = em.GetWevObisMeCombinations(); if (combis.Count != 1) @@ -63,10 +70,10 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, ReferenceTimeFrame = new Zeitraum { Startdatum = new DateTimeOffset(reference.Start, TimeSpan.Zero), - Enddatum = new DateTimeOffset(reference.End, TimeSpan.Zero) + Enddatum = new DateTimeOffset(reference.End, TimeSpan.Zero), }, Coverage = coverage, - ErrorMessage = errorMessage + ErrorMessage = errorMessage, }; } @@ -83,8 +90,13 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, /// OBIS Kennzahl /// Mengeneinheit /// the completeness report - public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, ITimeRange reference, - Wertermittlungsverfahren? wev, string obiskennzahl, Mengeneinheit einheit) + public static CompletenessReport GetCompletenessReport( + this BO.Energiemenge em, + ITimeRange reference, + Wertermittlungsverfahren? wev, + string obiskennzahl, + Mengeneinheit einheit + ) { CompletenessReport result; @@ -97,12 +109,15 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, Obiskennzahl = obiskennzahl, ReferenceTimeFrame = new Zeitraum { - Startdatum = new DateTimeOffset(DateTime.SpecifyKind(reference.Start, DateTimeKind.Utc)), - Enddatum = new DateTimeOffset(DateTime.SpecifyKind(reference.End, DateTimeKind.Utc)) - } + Startdatum = new DateTimeOffset( + DateTime.SpecifyKind(reference.Start, DateTimeKind.Utc) + ), + Enddatum = new DateTimeOffset( + DateTime.SpecifyKind(reference.End, DateTimeKind.Utc) + ), + }, }; - if (em.Energieverbrauch != null && em.Energieverbrauch.Any()) { /*using (MiniProfiler.Current.Step("populating time slices of/with missing/null values")) @@ -130,14 +145,19 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, .ToList()); }*/ - var nonNullValues = - new TimePeriodCollection( - em.Energieverbrauch.Select(v => new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime))); + var nonNullValues = new TimePeriodCollection( + em.Energieverbrauch.Select(v => new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + )) + ); ITimeRange limits; if (result.ReferenceTimeFrame != null && result.ReferenceTimeFrame.Startdatum.HasValue) { - limits = new TimeRange(result.ReferenceTimeFrame.Startdatum.Value.UtcDateTime, - result.ReferenceTimeFrame.Enddatum.Value.UtcDateTime); + limits = new TimeRange( + result.ReferenceTimeFrame.Startdatum.Value.UtcDateTime, + result.ReferenceTimeFrame.Enddatum.Value.UtcDateTime + ); } else { @@ -146,12 +166,12 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, var gaps = new TimeGapCalculator().GetGaps(nonNullValues, limits); result.Gaps = gaps.Select(gap => new CompletenessReport.BasicVerbrauch - { - Startdatum = DateTime.SpecifyKind(gap.Start, DateTimeKind.Utc), - Enddatum = DateTime.SpecifyKind(gap.End, DateTimeKind.Utc), - Wert = null - }).ToList(); - + { + Startdatum = DateTime.SpecifyKind(gap.Start, DateTimeKind.Utc), + Enddatum = DateTime.SpecifyKind(gap.End, DateTimeKind.Utc), + Wert = null, + }) + .ToList(); /*using (MiniProfiler.Current.Step("sorting result")) { @@ -161,8 +181,11 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, { try { - foreach (var kvp in em.Energieverbrauch.Where(v => v.UserProperties != null) - .SelectMany(v => v.UserProperties)) + foreach ( + var kvp in em + .Energieverbrauch.Where(v => v.UserProperties != null) + .SelectMany(v => v.UserProperties) + ) { if (result.UserProperties == null) { @@ -205,7 +228,8 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em) if (!em.IsPure()) { throw new ArgumentException( - "The provided Energiemenge is not pure. Please use overloaded method GetCompletenessReport(... , wertermittlungsverfahren, obiskennzahl, mengeneinheit)."); + "The provided Energiemenge is not pure. Please use overloaded method GetCompletenessReport(... , wertermittlungsverfahren, obiskennzahl, mengeneinheit)." + ); } Verbrauch v; @@ -219,11 +243,16 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em) { Coverage = null, LokationsId = em.LokationsId, - ErrorMessage = "energieverbrauch is empty" + ErrorMessage = "energieverbrauch is empty", }; } - return em.GetCompletenessReport(em.GetTimeRange(), v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit); + return em.GetCompletenessReport( + em.GetTimeRange(), + v.Wertermittlungsverfahren, + v.Obiskennzahl, + v.Einheit + ); } /// @@ -233,8 +262,11 @@ public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em) /// list of ranges for which the completeness reports are generated /// set true to internally use parallel linq /// - public static IDictionary GetSlicedCompletenessReports(this BO.Energiemenge em, - IEnumerable ranges, bool useParallelExecution = false) + public static IDictionary GetSlicedCompletenessReports( + this BO.Energiemenge em, + IEnumerable ranges, + bool useParallelExecution = false + ) { if (ranges == null) { @@ -262,8 +294,11 @@ public static IDictionary GetSlicedCompletenessR /// overall time frame. Beginning and end must have same hour/minute/second /// set true to internally use parallel linq /// - public static IDictionary GetDailyCompletenessReports(this BO.Energiemenge em, - ITimeRange overallTimeRange, bool useParallelExecution = false) + public static IDictionary GetDailyCompletenessReports( + this BO.Energiemenge em, + ITimeRange overallTimeRange, + bool useParallelExecution = false + ) { var slices = GetLocalDailySlices(overallTimeRange); return em.GetSlicedCompletenessReports(slices, useParallelExecution); @@ -276,10 +311,13 @@ public static IDictionary GetDailyCompletenessRe /// /// set true to internally use parallel linq /// - public static IDictionary GetMonthlyCompletenessReports(this BO.Energiemenge em, - ITimeRange overallTimeRange, bool useParallelExecution = false) + public static IDictionary GetMonthlyCompletenessReports( + this BO.Energiemenge em, + ITimeRange overallTimeRange, + bool useParallelExecution = false + ) { var slices = GetLocalMonthlySlices(overallTimeRange); return em.GetSlicedCompletenessReports(slices, useParallelExecution); } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionPlausibility.cs b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionPlausibility.cs index 9279c0cd..c89fbfd3 100644 --- a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionPlausibility.cs +++ b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionPlausibility.cs @@ -1,15 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; using BO4E.COM; using BO4E.ENUM; using BO4E.Reporting; - using Itenso.TimePeriod; - using Newtonsoft.Json; - -using System; -using System.Collections.Generic; -using System.Linq; - using static BO4E.Extensions.ENUM.MengeneinheitExtenion; using static BO4E.Reporting.PlausibilityReport; @@ -33,8 +29,12 @@ public static partial class EnergiemengeExtension /// do not match. Setting this flag suppresses the error. /// /// a - public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emReference, - BO.Energiemenge emOther, ITimeRange timeframe = null, bool ignoreLocation = false) + public static PlausibilityReport GetPlausibilityReport( + this BO.Energiemenge emReference, + BO.Energiemenge emOther, + ITimeRange timeframe = null, + bool ignoreLocation = false + ) { var trReference = emReference.GetTimeRange(); var trOther = emOther.GetTimeRange(); @@ -43,11 +43,16 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe var overlap = trReference.GetIntersection(trOther); if (!ignoreLocation) { - if (!(emReference.LokationsId == emOther.LokationsId && - emReference.LokationsTyp == emOther.LokationsTyp)) + if ( + !( + emReference.LokationsId == emOther.LokationsId + && emReference.LokationsTyp == emOther.LokationsTyp + ) + ) { throw new ArgumentException( - $"locations do not match! '{emReference.LokationsId}' ({emReference.LokationsTyp}) != '{emOther.LokationsId}' ({emOther.LokationsTyp})"); + $"locations do not match! '{emReference.LokationsId}' ({emReference.LokationsTyp}) != '{emOther.LokationsId}' ({emOther.LokationsTyp})" + ); } } @@ -66,14 +71,16 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe if (consumptionReference.Item2.IsConvertibleTo(consumptionOtherRaw.Item2)) { consumptionOther = new Tuple( - consumptionOtherRaw.Item1 * - consumptionOtherRaw.Item2.GetConversionFactor(consumptionReference.Item2), - consumptionReference.Item2); + consumptionOtherRaw.Item1 + * consumptionOtherRaw.Item2.GetConversionFactor(consumptionReference.Item2), + consumptionReference.Item2 + ); } else { throw new ArgumentException( - $"The unit {consumptionOtherRaw.Item2} is not comparable to {consumptionReference.Item2}!"); + $"The unit {consumptionOtherRaw.Item2} is not comparable to {consumptionReference.Item2}!" + ); } } else @@ -92,15 +99,13 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe relativeDeviation = null; } - var vReference = - emReference.Energieverbrauch.FirstOrDefault(); // copies obiskennzahl, wertermittlungsverfahren... + var vReference = emReference.Energieverbrauch.FirstOrDefault(); // copies obiskennzahl, wertermittlungsverfahren... vReference.Wert = consumptionReference.Item1; vReference.Einheit = consumptionReference.Item2; vReference.Startdatum = timeframe.Start; vReference.Enddatum = timeframe.End; - var vOther = - emOther.Energieverbrauch.FirstOrDefault(); // copies obiskennzahl, wertermittlungsverfahren... + var vOther = emOther.Energieverbrauch.FirstOrDefault(); // copies obiskennzahl, wertermittlungsverfahren... vOther.Wert = consumptionOther.Item1; vOther.Einheit = consumptionOther.Item2; vOther.Startdatum = timeframe.Start; @@ -112,12 +117,12 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe ReferenceTimeFrame = new Zeitraum { Startdatum = new DateTimeOffset(timeframe.Start), - Enddatum = new DateTimeOffset(timeframe.End) + Enddatum = new DateTimeOffset(timeframe.End), }, VerbrauchReference = vReference, VerbrauchOther = vOther, AbsoluteDeviation = Math.Abs(absoluteDeviation), - AbsoluteDeviationEinheit = consumptionReference.Item2 + AbsoluteDeviationEinheit = consumptionReference.Item2, }; if (relativeDeviation.HasValue) { @@ -129,7 +134,6 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe } return pr; - } /// @@ -140,12 +144,19 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge emRe /// container containing the relevant data /// /// - public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge energiemenge, - PlausibilityReportConfiguration config) + public static PlausibilityReport GetPlausibilityReport( + this BO.Energiemenge energiemenge, + PlausibilityReportConfiguration config + ) { - return energiemenge.GetPlausibilityReport(config.Other, - new TimeRange(config.Timeframe.Startdatum.Value.UtcDateTime, - config.Timeframe.Enddatum.Value.UtcDateTime), config.IgnoreLocation); + return energiemenge.GetPlausibilityReport( + config.Other, + new TimeRange( + config.Timeframe.Startdatum.Value.UtcDateTime, + config.Timeframe.Enddatum.Value.UtcDateTime + ), + config.IgnoreLocation + ); } /// @@ -155,8 +166,11 @@ public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge ener /// container containing the relevant data /// list of ranges for which the completeness reports are generated /// - public static IDictionary GetSlicedPlausibilityReports(this BO.Energiemenge em, - PlausibilityReportConfiguration config, IEnumerable ranges) + public static IDictionary GetSlicedPlausibilityReports( + this BO.Energiemenge em, + PlausibilityReportConfiguration config, + IEnumerable ranges + ) { if (ranges == null) { @@ -166,13 +180,10 @@ public static IDictionary GetSlicedPlausibilityR var result = new Dictionary(); foreach (var range in ranges) { - var localConfig = - JsonConvert.DeserializeObject(JsonConvert.SerializeObject(config)); - localConfig.Timeframe = new Zeitraum - { - Startdatum = range.Start, - Enddatum = range.End - }; + var localConfig = JsonConvert.DeserializeObject( + JsonConvert.SerializeObject(config) + ); + localConfig.Timeframe = new Zeitraum { Startdatum = range.Start, Enddatum = range.End }; var subResult = GetPlausibilityReport(em, localConfig); result.Add(range, subResult); } @@ -190,8 +201,10 @@ public static IDictionary GetSlicedPlausibilityR /// /// /// - public static IDictionary GetDailyPlausibilityReports(this BO.Energiemenge em, - PlausibilityReportConfiguration config) + public static IDictionary GetDailyPlausibilityReports( + this BO.Energiemenge em, + PlausibilityReportConfiguration config + ) { if (config == null) { @@ -203,11 +216,13 @@ public static IDictionary GetDailyPlausibilityRe throw new ArgumentNullException(nameof(config.Timeframe)); } - var slices = GetLocalDailySlices(new TimeRange - { - Start = config.Timeframe.Startdatum.Value.UtcDateTime, - End = config.Timeframe.Enddatum.Value.UtcDateTime - }); + var slices = GetLocalDailySlices( + new TimeRange + { + Start = config.Timeframe.Startdatum.Value.UtcDateTime, + End = config.Timeframe.Enddatum.Value.UtcDateTime, + } + ); return em.GetSlicedPlausibilityReports(config, slices); } @@ -220,8 +235,10 @@ public static IDictionary GetDailyPlausibilityRe /// /// /// - public static IDictionary GetMonthlyPlausibilityReports(this BO.Energiemenge em, - PlausibilityReportConfiguration config) + public static IDictionary GetMonthlyPlausibilityReports( + this BO.Energiemenge em, + PlausibilityReportConfiguration config + ) { if (config == null) { @@ -233,11 +250,13 @@ public static IDictionary GetMonthlyPlausibility throw new ArgumentNullException(nameof(config.Timeframe)); } - var slices = GetLocalMonthlySlices(new TimeRange - { - Start = config.Timeframe.Startdatum.Value.UtcDateTime, - End = config.Timeframe.Enddatum.Value.UtcDateTime - }); + var slices = GetLocalMonthlySlices( + new TimeRange + { + Start = config.Timeframe.Startdatum.Value.UtcDateTime, + End = config.Timeframe.Enddatum.Value.UtcDateTime, + } + ); return em.GetSlicedPlausibilityReports(config, slices); } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionSlicingHelper.cs b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionSlicingHelper.cs index 60b936d9..1a0d732b 100644 --- a/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionSlicingHelper.cs +++ b/BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtensionSlicingHelper.cs @@ -9,11 +9,17 @@ namespace BO4E.Extensions.BusinessObjects.Energiemenge; /// Do calculations on top of an Energiemenge BO4E. public static partial class EnergiemengeExtension { - internal static IList GetLocalDailySlices(ITimeRange overallTimeRange, TimeZoneInfo tz = null) + internal static IList GetLocalDailySlices( + ITimeRange overallTimeRange, + TimeZoneInfo tz = null + ) { if (overallTimeRange == null) { - throw new ArgumentNullException(nameof(overallTimeRange), "overall time range must not be null"); + throw new ArgumentNullException( + nameof(overallTimeRange), + "overall time range must not be null" + ); } if (tz == null) @@ -23,40 +29,54 @@ internal static IList GetLocalDailySlices(ITimeRange overallTimeRang if (overallTimeRange.Start.Kind == DateTimeKind.Unspecified) { - throw new ArgumentException("TimeRange start must not have DateTimeKind.Unspecified", - nameof(overallTimeRange)); + throw new ArgumentException( + "TimeRange start must not have DateTimeKind.Unspecified", + nameof(overallTimeRange) + ); } if (overallTimeRange.End.Kind == DateTimeKind.Unspecified) { - throw new ArgumentException("TimeRange end must not have DateTimeKind.Unspecified", - nameof(overallTimeRange)); + throw new ArgumentException( + "TimeRange end must not have DateTimeKind.Unspecified", + nameof(overallTimeRange) + ); } IList result = new List(); if (!overallTimeRange.IsMoment) { - result.Add(new TimeRange - { - Start = overallTimeRange.Start, - End = overallTimeRange.Start.AddDaysDST(1) - }); - while (result.Last().End < overallTimeRange.End) - result.Add(new TimeRange + result.Add( + new TimeRange { - Start = result.Last().Start.AddDaysDST(1), - End = result.Last().End.AddDaysDST(1) - }); + Start = overallTimeRange.Start, + End = overallTimeRange.Start.AddDaysDST(1), + } + ); + while (result.Last().End < overallTimeRange.End) + result.Add( + new TimeRange + { + Start = result.Last().Start.AddDaysDST(1), + End = result.Last().End.AddDaysDST(1), + } + ); } return result; } - internal static IList GetLocalMonthlySlices(ITimeRange overallTimeRange, TimeZoneInfo tz = null) + internal static IList GetLocalMonthlySlices( + ITimeRange overallTimeRange, + TimeZoneInfo tz = null + ) { if (overallTimeRange == null) { - throw new ArgumentNullException(nameof(overallTimeRange), "overall time range must not be null"); + throw new ArgumentNullException( + nameof(overallTimeRange), + "overall time range must not be null" + ); } DateTime localStart; @@ -69,14 +89,16 @@ internal static IList GetLocalMonthlySlices(ITimeRange overallTimeRa { throw new ArgumentException( $"TimeRange start must have DateTimeKind.Utc if no timezone is given in parameter {nameof(tz)}", - nameof(overallTimeRange)); + nameof(overallTimeRange) + ); } if (overallTimeRange.End.Kind != DateTimeKind.Utc) { throw new ArgumentException( $"TimeRange end must have DateTimeKind.Utc if no timezone is given in parameter {nameof(tz)}", - nameof(overallTimeRange)); + nameof(overallTimeRange) + ); } localStart = TimeZoneInfo.ConvertTimeFromUtc(overallTimeRange.Start, tz); @@ -87,8 +109,10 @@ internal static IList GetLocalMonthlySlices(ITimeRange overallTimeRa switch (overallTimeRange.Start.Kind) { case DateTimeKind.Local: - throw new ArgumentException($"{nameof(DateTimeKind.Local)} not allowed for Start", - nameof(overallTimeRange)); + throw new ArgumentException( + $"{nameof(DateTimeKind.Local)} not allowed for Start", + nameof(overallTimeRange) + ); case DateTimeKind.Unspecified: localStart = overallTimeRange.Start; break; @@ -102,8 +126,10 @@ internal static IList GetLocalMonthlySlices(ITimeRange overallTimeRa switch (overallTimeRange.End.Kind) { case DateTimeKind.Local: - throw new ArgumentException($"{nameof(DateTimeKind.Local)} not allowed for End", - nameof(overallTimeRange)); + throw new ArgumentException( + $"{nameof(DateTimeKind.Local)} not allowed for End", + nameof(overallTimeRange) + ); case DateTimeKind.Unspecified: localEnd = overallTimeRange.End; break; @@ -121,31 +147,33 @@ internal static IList GetLocalMonthlySlices(ITimeRange overallTimeRa IList result = new List(); if (!overallTimeRange.IsMoment) { - var initialStart = - new DateTime(localStart.Year, localStart.Month, 1, 0, 0, 0, DateTimeKind.Unspecified); + var initialStart = new DateTime( + localStart.Year, + localStart.Month, + 1, + 0, + 0, + 0, + DateTimeKind.Unspecified + ); var initialEnd = initialStart.AddMonths(1); - result.Add(new TimeRange - { - Start = initialStart, - End = initialEnd - }); + result.Add(new TimeRange { Start = initialStart, End = initialEnd }); while (result.Last().End < overallTimeRange.End) { var sliceStart = result.Last().Start.AddMonths(1); - result.Add(new TimeRange - { - Start = sliceStart, - End = sliceStart.AddMonths(1) - }); + result.Add(new TimeRange { Start = sliceStart, End = sliceStart.AddMonths(1) }); } } return result - .Select(tr => (ITimeRange)new TimeRange - { - Start = TimeZoneInfo.ConvertTimeToUtc(tr.Start, tz), - End = TimeZoneInfo.ConvertTimeToUtc(tr.End, tz) - }) + .Select(tr => + (ITimeRange) + new TimeRange + { + Start = TimeZoneInfo.ConvertTimeToUtc(tr.Start, tz), + End = TimeZoneInfo.ConvertTimeToUtc(tr.End, tz), + } + ) .Where(tr => tr.Start >= overallTimeRange.Start && tr.End <= overallTimeRange.End) .ToList(); } @@ -173,19 +201,23 @@ public static DateTime AddDaysDST(this DateTime dt, double value, TimeZoneInfo t case DateTimeKind.Local: throw new ArgumentException("DateTime Kind must not be local", nameof(dt)); case DateTimeKind.Unspecified: - return - dt.AddDays(value); // doesn't take dst into account. that's just what we want! A day can have 23,24 or 25 hours + return dt.AddDays(value); // doesn't take dst into account. that's just what we want! A day can have 23,24 or 25 hours case DateTimeKind.Utc: - { - // an utc day does always have 24 hours. not what humans expect! - var dtLocal = DateTime.SpecifyKind(TimeZoneInfo.ConvertTimeFromUtc(dt, tz), - DateTimeKind.Unspecified); - var preResult = DateTime.SpecifyKind(dtLocal.AddDays(value), DateTimeKind.Unspecified); - var result = TimeZoneInfo.ConvertTimeToUtc(preResult, tz); - return result; - } + { + // an utc day does always have 24 hours. not what humans expect! + var dtLocal = DateTime.SpecifyKind( + TimeZoneInfo.ConvertTimeFromUtc(dt, tz), + DateTimeKind.Unspecified + ); + var preResult = DateTime.SpecifyKind( + dtLocal.AddDays(value), + DateTimeKind.Unspecified + ); + var result = TimeZoneInfo.ConvertTimeToUtc(preResult, tz); + return result; + } default: throw new NotImplementedException($"DateTimeKind {dt.Kind} is not implemented."); } } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/COM/COM.cs b/BO4E.Extensions/COM/COM.cs index e30da90f..aca30802 100644 --- a/BO4E.Extensions/COM/COM.cs +++ b/BO4E.Extensions/COM/COM.cs @@ -13,8 +13,9 @@ public static class COMExtensions /// Type of the COM /// the BO that is copied /// the deep copy - public static T DeepClone(this T source) where T : BO4E.COM.COM + public static T DeepClone(this T source) + where T : BO4E.COM.COM { return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source)); } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/COM/PhysikalischerWertExtension.cs b/BO4E.Extensions/COM/PhysikalischerWertExtension.cs index bd9d3e9b..c321f3e9 100644 --- a/BO4E.Extensions/COM/PhysikalischerWertExtension.cs +++ b/BO4E.Extensions/COM/PhysikalischerWertExtension.cs @@ -16,9 +16,12 @@ public static class PhysikalischerWertExtension /// physikalischer Wert /// new unit of measurement /// a new instance of PhysikalischerWert having the unit - public static PhysikalischerWert ConvertToUnit(this PhysikalischerWert pw, Mengeneinheit newEinheit) + public static PhysikalischerWert ConvertToUnit( + this PhysikalischerWert pw, + Mengeneinheit newEinheit + ) { var factor = pw.Einheit.GetConversionFactor(newEinheit); // throws all the exceptions. return new PhysikalischerWert(factor * pw.Wert, newEinheit); } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/COM/VerbrauchExtension.cs b/BO4E.Extensions/COM/VerbrauchExtension.cs index 4f341563..4ba3dfa5 100644 --- a/BO4E.Extensions/COM/VerbrauchExtension.cs +++ b/BO4E.Extensions/COM/VerbrauchExtension.cs @@ -26,7 +26,7 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2) => /// /// Apply to the provided Verbräuche. - /// But remove identical entries that occur in both and + /// But remove identical entries that occur in both and /// /// /// @@ -47,19 +47,33 @@ public static HashSet MergeRedundant(this Verbrauch v1, Verbrauch v2, /// /// /// - public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool redundant, bool biased) + public static HashSet Merge( + this Verbrauch v1, + Verbrauch v2, + bool redundant, + bool biased + ) { var result = new HashSet(); - if (v1.Obiskennzahl == v2.Obiskennzahl && v1.Wertermittlungsverfahren == v2.Wertermittlungsverfahren && - v1.Einheit == v2.Einheit) + if ( + v1.Obiskennzahl == v2.Obiskennzahl + && v1.Wertermittlungsverfahren == v2.Wertermittlungsverfahren + && v1.Einheit == v2.Einheit + ) { if (v1.OverlapsWith(v2)) { // don't wanna deal with time running backwards. //Debug.Assert(v1.enddatum >= v1.startdatum); //Debug.Assert(v2.enddatum >= v2.startdatum); - var tr1 = new TimeRange((v1.Startdatum ?? DateTimeOffset.MinValue).UtcDateTime, (v1.Enddatum ?? DateTimeOffset.MinValue).UtcDateTime); - var tr2 = new TimeRange((v2.Startdatum ?? DateTimeOffset.MinValue).UtcDateTime, (v2.Enddatum ?? DateTimeOffset.MinValue).UtcDateTime); + var tr1 = new TimeRange( + (v1.Startdatum ?? DateTimeOffset.MinValue).UtcDateTime, + (v1.Enddatum ?? DateTimeOffset.MinValue).UtcDateTime + ); + var tr2 = new TimeRange( + (v2.Startdatum ?? DateTimeOffset.MinValue).UtcDateTime, + (v2.Enddatum ?? DateTimeOffset.MinValue).UtcDateTime + ); var overlap = v1.GetIntersection(v2); if (v1.Einheit.IsExtensive()) { @@ -67,27 +81,36 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red { Obiskennzahl = v1.Obiskennzahl, Einheit = v1.Einheit, - Wertermittlungsverfahren = v1.Wertermittlungsverfahren + Wertermittlungsverfahren = v1.Wertermittlungsverfahren, }; if (redundant) { var exclusiveV1Wert = - (decimal)(tr1.Duration.TotalSeconds - overlap.Duration.TotalSeconds) * v1.Wert / - (decimal)tr1.Duration.TotalSeconds; + (decimal)(tr1.Duration.TotalSeconds - overlap.Duration.TotalSeconds) + * v1.Wert + / (decimal)tr1.Duration.TotalSeconds; var exclusiveV2Wert = - (decimal)(tr2.Duration.TotalSeconds - overlap.Duration.TotalSeconds) * v2.Wert / - (decimal)tr2.Duration.TotalSeconds; - var overlapV1Wert = (decimal)overlap.Duration.TotalSeconds * v1.Wert / - (decimal)tr1.Duration.TotalSeconds; - var overlapV2Wert = (decimal)overlap.Duration.TotalSeconds * v2.Wert / - (decimal)tr2.Duration.TotalSeconds; + (decimal)(tr2.Duration.TotalSeconds - overlap.Duration.TotalSeconds) + * v2.Wert + / (decimal)tr2.Duration.TotalSeconds; + var overlapV1Wert = + (decimal)overlap.Duration.TotalSeconds + * v1.Wert + / (decimal)tr1.Duration.TotalSeconds; + var overlapV2Wert = + (decimal)overlap.Duration.TotalSeconds + * v2.Wert + / (decimal)tr2.Duration.TotalSeconds; if (biased) { // biased ==> assume that v2 is contained in v1 vmerge.Startdatum = v1.Startdatum; vmerge.Enddatum = v1.Enddatum; - if (exclusiveV1Wert == 0.0M && exclusiveV2Wert == 0.0M && - overlapV1Wert == overlapV2Wert) + if ( + exclusiveV1Wert == 0.0M + && exclusiveV2Wert == 0.0M + && overlapV1Wert == overlapV2Wert + ) { vmerge.Wert = overlapV1Wert; } @@ -105,7 +128,8 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red } else { - vmerge.Startdatum = v1.Startdatum < v2.Startdatum ? v1.Startdatum : v2.Startdatum; + vmerge.Startdatum = + v1.Startdatum < v2.Startdatum ? v1.Startdatum : v2.Startdatum; vmerge.Enddatum = v1.Enddatum > v2.Enddatum ? v1.Enddatum : v2.Enddatum; vmerge.Wert = v1.Wert + v2.Wert; } @@ -121,7 +145,7 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red Wertermittlungsverfahren = v1.Wertermittlungsverfahren, Startdatum = v1.Startdatum < v2.Startdatum ? v1.Startdatum : v2.Startdatum, Enddatum = new DateTimeOffset(overlap.Start, TimeSpan.Zero), - Wert = v1.Startdatum < v2.Startdatum ? v1.Wert : v2.Wert + Wert = v1.Startdatum < v2.Startdatum ? v1.Wert : v2.Wert, }; var vmerge2 = new Verbrauch { @@ -136,7 +160,8 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red if (v1.Wert != v2.Wert) { throw new ArgumentException( - $"Data cannot be redundant if values ({v1.Wert}{v1.Einheit} vs. {v2.Wert}{v2.Einheit}) don't match for interval [{vmerge2.Startdatum}, {vmerge2.Enddatum})."); + $"Data cannot be redundant if values ({v1.Wert}{v1.Einheit} vs. {v2.Wert}{v2.Einheit}) don't match for interval [{vmerge2.Startdatum}, {vmerge2.Enddatum})." + ); } vmerge2.Wert = v1.Wert; @@ -153,7 +178,7 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red Wertermittlungsverfahren = v1.Wertermittlungsverfahren, Startdatum = overlap.End, Enddatum = v1.Enddatum > v2.Enddatum ? v1.Enddatum : v2.Enddatum, - Wert = v1.Enddatum > v2.Enddatum ? v1.Wert : v2.Wert + Wert = v1.Enddatum > v2.Enddatum ? v1.Wert : v2.Wert, }; result.Add(vmerge1); result.Add(vmerge2); @@ -170,7 +195,7 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red Einheit = v1.Einheit, Wertermittlungsverfahren = v1.Wertermittlungsverfahren, Startdatum = start, - Enddatum = stop + Enddatum = stop, }; if (v1.Einheit.IsExtensive()) { @@ -204,7 +229,14 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red } result.RemoveWhere(v => - v.Einheit.IsIntensive() && new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime).Duration.TotalMilliseconds == 0); + v.Einheit.IsIntensive() + && new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ) + .Duration + .TotalMilliseconds == 0 + ); return result; } @@ -215,7 +247,10 @@ public static HashSet Merge(this Verbrauch v1, Verbrauch v2, bool red /// public static TimeRange GetTimeRange(this Verbrauch v) { - return new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime); + return new TimeRange( + (v.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v.Enddatum ?? DateTimeOffset.MinValue).DateTime + ); } /// @@ -225,7 +260,6 @@ public static TimeRange GetTimeRange(this Verbrauch v) /// public static TimeSpan GetDuration(this Verbrauch v) => v.GetTimeRange().Duration; - /// /// De-tangles a list of overlapping Verbrauch entries where entries can be subsets of other entries. /// @@ -244,9 +278,9 @@ public static List Detangle(IEnumerable input) { //var filteredInput = KeepShortestSlices(input); var resultSet = new HashSet(); - var groups = input.OrderBy(v => (v.Startdatum, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit)) - .GroupBy(v => new Tuple - ( + var groups = input + .OrderBy(v => (v.Startdatum, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit)) + .GroupBy(v => new Tuple( v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit @@ -259,7 +293,9 @@ public static List Detangle(IEnumerable input) // |----x----|--------y--------| //var adjacentVerbrauchs = from x in vGroup join y in vGroup on x.enddatum equals y.startdatum select new { x, y }; var adjacentVerbrauchs = - from x in vGroup join y in vGroup on x.Enddatum equals y.Startdatum select new { x, y }; + from x in vGroup + join y in vGroup on x.Enddatum equals y.Startdatum + select new { x, y }; foreach (var av in adjacentVerbrauchs) { subResult.Add(av.x); @@ -270,15 +306,22 @@ public static List Detangle(IEnumerable input) // |-------------z-------------| // ==> delete z from result where z.start == x.start and z.end == y.end //var fullyRedundantVerbrauchs = from av in adjacentVerbrauchs join z in vGroup on new { av.x.startdatum, av.y.enddatum } equals new { z.startdatum, z.enddatum } select new { av, z }; - var fullyRedundantVerbrauchs = from av in adjacentVerbrauchs - join z in vGroup on new { av.x.Startdatum, av.y.Enddatum } equals new { z.Startdatum, z.Enddatum } - select new { av, z }; + var fullyRedundantVerbrauchs = + from av in adjacentVerbrauchs + join z in vGroup + on new { av.x.Startdatum, av.y.Enddatum } equals new + { + z.Startdatum, + z.Enddatum, + } + select new { av, z }; foreach (var frv in fullyRedundantVerbrauchs) { if (frv.av.x.Wert + frv.av.y.Wert != frv.z.Wert) { throw new ArgumentException( - $"Inconsistent data detected: {JsonConvert.SerializeObject(frv.av.x)} + {JsonConvert.SerializeObject(frv.av.y)} ≠ {JsonConvert.SerializeObject(frv.z)}"); + $"Inconsistent data detected: {JsonConvert.SerializeObject(frv.av.x)} + {JsonConvert.SerializeObject(frv.av.y)} ≠ {JsonConvert.SerializeObject(frv.z)}" + ); } subResult.Remove(frv.z); @@ -314,7 +357,7 @@ public static List Detangle(IEnumerable input) Wertermittlungsverfahren = z.Wertermittlungsverfahren, Obiskennzahl = z.Obiskennzahl, Startdatum = new DateTimeOffset(tr.Start, TimeSpan.Zero), - Enddatum = new DateTimeOffset(tr.End, TimeSpan.Zero) + Enddatum = new DateTimeOffset(tr.End, TimeSpan.Zero), }; xs.Add(v); } @@ -322,7 +365,10 @@ public static List Detangle(IEnumerable input) var totalXWert = z.Wert - ys.Select(y => y.Wert).Sum(); var totalXDuration = xs.Select(x => x.GetDuration().TotalSeconds).Sum(); foreach (var x in xs) - x.Wert = totalXWert * (decimal)x.GetDuration().TotalSeconds / (decimal)totalXDuration; + x.Wert = + totalXWert + * (decimal)x.GetDuration().TotalSeconds + / (decimal)totalXDuration; subResult.Remove(z); subResult.UnionWith(xs); } @@ -361,7 +407,13 @@ public static void ConvertToUnit(this Verbrauch v, Mengeneinheit mengeneinheit) /// public static bool OverlapsWith(this Verbrauch v1, Verbrauch v2) { - return v1.OverlapsWith(new TimeRange((v2.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v2.Enddatum ?? DateTimeOffset.MinValue).DateTime, true)); + return v1.OverlapsWith( + new TimeRange( + (v2.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v2.Enddatum ?? DateTimeOffset.MinValue).DateTime, + true + ) + ); } /// @@ -372,7 +424,10 @@ public static bool OverlapsWith(this Verbrauch v1, Verbrauch v2) /// public static bool OverlapsWith(this Verbrauch v1, ITimeRange tr2) { - return new TimeRange((v1.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v1.Enddatum ?? DateTimeOffset.MinValue).DateTime).OverlapsWith(tr2); + return new TimeRange( + (v1.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v1.Enddatum ?? DateTimeOffset.MinValue).DateTime + ).OverlapsWith(tr2); } /// @@ -383,7 +438,10 @@ public static bool OverlapsWith(this Verbrauch v1, ITimeRange tr2) /// public static ITimeRange GetIntersection(this Verbrauch v1, ITimeRange tr2) { - return new TimeRange((v1.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v1.Enddatum ?? DateTimeOffset.MinValue).DateTime).GetIntersection(tr2); + return new TimeRange( + (v1.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v1.Enddatum ?? DateTimeOffset.MinValue).DateTime + ).GetIntersection(tr2); } /// @@ -394,7 +452,12 @@ public static ITimeRange GetIntersection(this Verbrauch v1, ITimeRange tr2) /// public static ITimeRange GetIntersection(this Verbrauch v1, Verbrauch v2) { - return v1.GetIntersection(new TimeRange((v2.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v2.Enddatum ?? DateTimeOffset.MinValue).DateTime)); + return v1.GetIntersection( + new TimeRange( + (v2.Startdatum ?? DateTimeOffset.MinValue).DateTime, + (v2.Enddatum ?? DateTimeOffset.MinValue).DateTime + ) + ); } /// @@ -418,15 +481,21 @@ int IComparer.Compare(Verbrauch x, Verbrauch y) { if (x.Startdatum != y.Startdatum) { - return DateTimeOffset.Compare(x.Startdatum ?? DateTimeOffset.MinValue, y.Startdatum ?? DateTimeOffset.MinValue); + return DateTimeOffset.Compare( + x.Startdatum ?? DateTimeOffset.MinValue, + y.Startdatum ?? DateTimeOffset.MinValue + ); } if (x.Enddatum != y.Enddatum) { - return DateTimeOffset.Compare(x.Enddatum ?? DateTimeOffset.MinValue, y.Enddatum ?? DateTimeOffset.MinValue); + return DateTimeOffset.Compare( + x.Enddatum ?? DateTimeOffset.MinValue, + y.Enddatum ?? DateTimeOffset.MinValue + ); } return 0; } } -} \ No newline at end of file +} diff --git a/BO4E.Extensions/COM/ZeitraumExtension.cs b/BO4E.Extensions/COM/ZeitraumExtension.cs index c9562d1f..8f18e800 100644 --- a/BO4E.Extensions/COM/ZeitraumExtension.cs +++ b/BO4E.Extensions/COM/ZeitraumExtension.cs @@ -15,4 +15,4 @@ public static implicit operator Zeitraum(TimeRange tr) }; } */ -} \ No newline at end of file +} diff --git a/BO4E.Extensions/ENUM/MengeneinheitExtension.cs b/BO4E.Extensions/ENUM/MengeneinheitExtension.cs index 4f5a034a..67e09316 100644 --- a/BO4E.Extensions/ENUM/MengeneinheitExtension.cs +++ b/BO4E.Extensions/ENUM/MengeneinheitExtension.cs @@ -14,17 +14,24 @@ public static class MengeneinheitExtenion /// This set contains sets of Mengeneinheiten that share the same dimension (e.g. time, power, work, volume) /// Einheiten in the same subset are considered convertible amongst each other. /// - public static readonly ISet> DimensionSets = new HashSet> + public static readonly ISet> DimensionSets = new HashSet< + ISet + > { - new HashSet {Mengeneinheit.WH, Mengeneinheit.KWH, Mengeneinheit.MWH}, - new HashSet {Mengeneinheit.KW, Mengeneinheit.MW}, + new HashSet { Mengeneinheit.WH, Mengeneinheit.KWH, Mengeneinheit.MWH }, + new HashSet { Mengeneinheit.KW, Mengeneinheit.MW }, new HashSet - {Mengeneinheit.JAHR, Mengeneinheit.MONAT, Mengeneinheit.TAG, Mengeneinheit.STUNDE}, - new HashSet {Mengeneinheit.ANZAHL}, - new HashSet {Mengeneinheit.KUBIKMETER}, - new HashSet {Mengeneinheit.VAR, Mengeneinheit.KVAR}, - new HashSet {Mengeneinheit.VARH, Mengeneinheit.KVARH}, - new HashSet {Mengeneinheit.KWHK} + { + Mengeneinheit.JAHR, + Mengeneinheit.MONAT, + Mengeneinheit.TAG, + Mengeneinheit.STUNDE, + }, + new HashSet { Mengeneinheit.ANZAHL }, + new HashSet { Mengeneinheit.KUBIKMETER }, + new HashSet { Mengeneinheit.VAR, Mengeneinheit.KVAR }, + new HashSet { Mengeneinheit.VARH, Mengeneinheit.KVARH }, + new HashSet { Mengeneinheit.KWHK }, }; /// @@ -41,7 +48,9 @@ public static bool AreConvertible(Mengeneinheit me1, Mengeneinheit me2) return false; } #pragma warning restore 618 - return DimensionSets.Any(einheitengroup => einheitengroup.Contains(me1) && einheitengroup.Contains(me2)); + return DimensionSets.Any(einheitengroup => + einheitengroup.Contains(me1) && einheitengroup.Contains(me2) + ); } /// @@ -124,7 +133,8 @@ public static decimal GetConversionFactor(this Mengeneinheit me1, Mengeneinheit if (!me1.IsConvertibleTo(me2)) { throw new InvalidOperationException( - $"{me1} and {me2} are not convertible into each other because they don't share the same dimension."); + $"{me1} and {me2} are not convertible into each other because they don't share the same dimension." + ); } if ((int)me1 % (int)me2 == 0 || (int)me2 % (int)me2 == 0) @@ -132,6 +142,8 @@ public static decimal GetConversionFactor(this Mengeneinheit me1, Mengeneinheit return (decimal)me1 / (decimal)me2; } - throw new InvalidOperationException($"{me1} and {me2} are not (trivially) convertible into each other."); + throw new InvalidOperationException( + $"{me1} and {me2} are not (trivially) convertible into each other." + ); } -} \ No newline at end of file +} diff --git a/BO4E.Reporting/CompletenessReport.cs b/BO4E.Reporting/CompletenessReport.cs index c6eed5cb..e46f74dc 100644 --- a/BO4E.Reporting/CompletenessReport.cs +++ b/BO4E.Reporting/CompletenessReport.cs @@ -23,8 +23,10 @@ public class CompletenessReport : Report, IComparable /// /// matches a OBIS-Kennzahl that stands for an intelligentes messsystem for power. /// - private static readonly Regex imsysRegex = new Regex(@"(1)-(65):((?:[1-8]|99))\.((?:6|8|9|29))\.([0-9]{1,2})", - RegexOptions.Compiled); + private static readonly Regex imsysRegex = new Regex( + @"(1)-(65):((?:[1-8]|99))\.((?:6|8|9|29))\.([0-9]{1,2})", + RegexOptions.Compiled + ); /// /// all information like e.g. is normalised to this reference time frame. @@ -55,7 +57,11 @@ public class CompletenessReport : Report, IComparable /// /// /// - [JsonProperty(PropertyName = "wertermittlungsverfahren", Required = Required.Default, Order = 7)] + [JsonProperty( + PropertyName = "wertermittlungsverfahren", + Required = Required.Default, + Order = 7 + )] public Wertermittlungsverfahren? Wertermittlungsverfahren { get; set; } /// @@ -109,10 +115,15 @@ public int CompareTo(CompletenessReport other) if (ReferenceTimeFrame != null && other.ReferenceTimeFrame != null) { - if (ReferenceTimeFrame.Startdatum.HasValue && other.ReferenceTimeFrame.Startdatum.HasValue) + if ( + ReferenceTimeFrame.Startdatum.HasValue + && other.ReferenceTimeFrame.Startdatum.HasValue + ) { - return Comparer.Default.Compare(ReferenceTimeFrame.Startdatum.Value, - other.ReferenceTimeFrame.Startdatum.Value); + return Comparer.Default.Compare( + ReferenceTimeFrame.Startdatum.Value, + other.ReferenceTimeFrame.Startdatum.Value + ); } if (ReferenceTimeFrame.Startdatum.HasValue) @@ -133,7 +144,11 @@ public int CompareTo(CompletenessReport other) /// Shows header of columns in return string? /// This value goes to end of every line. By default is "\\n" /// - public string ToCSV(string separator = ";", bool headerLine = true, string lineTerminator = "\\n") + public string ToCSV( + string separator = ";", + bool headerLine = true, + string lineTerminator = "\\n" + ) { var builder = new StringBuilder(); if (headerLine) @@ -152,7 +167,7 @@ public int CompareTo(CompletenessReport other) "Zeitbereich in dem kein wahrer Wert vorhanden ist bis", "Anzahl fehlende Werte", "Prozentuale Vollständigkeit", - "Status" + "Status", }; builder.Append(string.Join(separator, headerColumns) + lineTerminator); } @@ -160,7 +175,7 @@ public int CompareTo(CompletenessReport other) var columns = new List { ReferenceTimeFrame.Startdatum.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"), - ReferenceTimeFrame.Enddatum.Value.ToString("yyyy-MM-ddTHH:mm:ssZ") + ReferenceTimeFrame.Enddatum.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"), }; if (Messlokation.ValidateId(LokationsId)) @@ -287,7 +302,11 @@ public class CompletenessReportConfiguration /// /// Wertermittlungsverfahren () to be taken into account. /// - [JsonProperty(PropertyName = "wertermittlungsverfahren", Required = Required.Default, Order = 8)] + [JsonProperty( + PropertyName = "wertermittlungsverfahren", + Required = Required.Default, + Order = 8 + )] public Wertermittlungsverfahren? Wertermittlungsverfahren { get; set; } /// @@ -325,4 +344,4 @@ public int Compare(CompletenessReport x, CompletenessReport y) } } }*/ -} \ No newline at end of file +} diff --git a/BO4E.Reporting/PlausibilityReport.cs b/BO4E.Reporting/PlausibilityReport.cs index f873a6fb..ae788db6 100644 --- a/BO4E.Reporting/PlausibilityReport.cs +++ b/BO4E.Reporting/PlausibilityReport.cs @@ -92,4 +92,4 @@ public class PlausibilityReportConfiguration [JsonProperty(PropertyName = "ignoreLocation", Required = Required.Always)] public bool IgnoreLocation { get; set; } } -} \ No newline at end of file +} diff --git a/BO4E.Reporting/Report.cs b/BO4E.Reporting/Report.cs index 311cb156..32a25160 100644 --- a/BO4E.Reporting/Report.cs +++ b/BO4E.Reporting/Report.cs @@ -22,8 +22,12 @@ public abstract class Report : BusinessObject /// /// /// return report as CSV string - public string ToCsv(char separator = ';', bool headerLine = true, string lineTerminator = "\\n", - List> reihenfolge = null) + public string ToCsv( + char separator = ';', + bool headerLine = true, + string lineTerminator = "\\n", + List> reihenfolge = null + ) { var type = GetType(); var resultBuilder = new StringBuilder(); @@ -38,7 +42,8 @@ public abstract class Report : BusinessObject var sortedResults = new List(); var sortedHeaderNamesList = new List(); - var parallelItems = headerNames.GroupBy(x => x) + var parallelItems = headerNames + .GroupBy(x => x) .Where(g => g.Count() > 1) .Select(y => new { Element = y.Key, Counter = y.Count() }) .ToList(); @@ -52,8 +57,10 @@ public abstract class Report : BusinessObject { reihenfolge = reihenfolge.Where(x => x != null).ToList(); foreach (var reihenItem in reihenfolge) - if (!string.IsNullOrEmpty(reihenItem.Values.First()) && - !string.IsNullOrEmpty(reihenItem.Keys.First())) + if ( + !string.IsNullOrEmpty(reihenItem.Values.First()) + && !string.IsNullOrEmpty(reihenItem.Keys.First()) + ) { var index = headerNames.IndexOf(reihenItem.Keys.First()); if (index != -1) @@ -111,11 +118,14 @@ public abstract class Report : BusinessObject if (i == 0 && headerLine) { - resultBuilder = new StringBuilder(string.Join(separator.ToString(), sortedHeaderNamesList) + - lineTerminator); + resultBuilder = new StringBuilder( + string.Join(separator.ToString(), sortedHeaderNamesList) + lineTerminator + ); } - resultBuilder.Append(string.Join(separator.ToString(), sortedResults) + lineTerminator); + resultBuilder.Append( + string.Join(separator.ToString(), sortedResults) + lineTerminator + ); } } else @@ -124,8 +134,10 @@ public abstract class Report : BusinessObject { reihenfolge = reihenfolge.Where(x => x != null).ToList(); foreach (var reihenItem in reihenfolge) - if (!string.IsNullOrEmpty(reihenItem.Values.First()) && - !string.IsNullOrEmpty(reihenItem.Keys.First())) + if ( + !string.IsNullOrEmpty(reihenItem.Values.First()) + && !string.IsNullOrEmpty(reihenItem.Keys.First()) + ) { var index = headerNames.IndexOf(reihenItem.Keys.First()); if (index != -1) @@ -137,7 +149,8 @@ public abstract class Report : BusinessObject { throw new ArgumentException( $"'{reihenItem.Keys.First()}' was not part of {nameof(headerNames)}=[{string.Join(", ", headerNames)}]", - nameof(reihenfolge)); + nameof(reihenfolge) + ); } } else @@ -160,21 +173,22 @@ public abstract class Report : BusinessObject if (headerLine) { - resultBuilder = - new StringBuilder(string.Join(separator.ToString(), sortedHeaderNamesList) + lineTerminator); + resultBuilder = new StringBuilder( + string.Join(separator.ToString(), sortedHeaderNamesList) + lineTerminator + ); } resultBuilder.Append(string.Join(separator.ToString(), sortedResults)); } - var gapdata = new List(); var gapHeaderNames = new List(); var gapReterned = new Dictionary, List> { [gapHeaderNames] = gapdata }; _ = DetectGaps(type, separator, this, gapReterned); var gapSortedResults = new List(); - var gapParallelItems = gapHeaderNames.GroupBy(x => x) + var gapParallelItems = gapHeaderNames + .GroupBy(x => x) .Where(g => g.Count() > 1) .Select(y => new { Element = y.Key, Counter = y.Count() }) .ToList(); @@ -203,8 +217,12 @@ public abstract class Report : BusinessObject return resultBuilder.ToString(); } - private Dictionary, List> Detect(Type type, char separator, object value, - Dictionary, List> returnData) + private Dictionary, List> Detect( + Type type, + char separator, + object value, + Dictionary, List> returnData + ) { var props = type.GetProperties(); var nonHiddenProps = props.Where(s => !s.Name.StartsWith("_")).ToList(); @@ -213,17 +231,25 @@ private Dictionary, List> Detect(Type type, char separator, foreach (var field in nonHiddenProps) if (field.PropertyType.IsSubclassOf(typeof(COM.COM))) { - returnData = Detect(field.PropertyType, separator, field.GetValue(value), returnData); + returnData = Detect( + field.PropertyType, + separator, + field.GetValue(value), + returnData + ); } - else if (field.PropertyType.IsGenericType && - field.PropertyType.GetGenericTypeDefinition() == typeof(List<>)) + else if ( + field.PropertyType.IsGenericType + && field.PropertyType.GetGenericTypeDefinition() == typeof(List<>) + ) { if (field.GetValue(value) != null && field.Name != "gaps") { //var ItemType = field.GetValue(value).GetType().GetGenericArguments()[0]; var list = field.GetValue(value); var a = (IList)list; - foreach (var s in a) returnData = Detect(s.GetType(), separator, s, returnData); + foreach (var s in a) + returnData = Detect(s.GetType(), separator, s, returnData); } } else @@ -249,7 +275,9 @@ private Dictionary, List> Detect(Type type, char separator, { if (((DateTimeOffset?)nestedValue).HasValue) { - val = ((DateTimeOffset?)nestedValue).Value.ToString("yyyy-MM-ddTHH:mm:ssZ"); + val = ((DateTimeOffset?)nestedValue).Value.ToString( + "yyyy-MM-ddTHH:mm:ssZ" + ); } } else if (field.PropertyType == typeof(DateTime)) @@ -269,8 +297,12 @@ private Dictionary, List> Detect(Type type, char separator, return returnData; } - private Dictionary, List> DetectGaps(Type type, char separator, object value, - Dictionary, List> returnData) + private Dictionary, List> DetectGaps( + Type type, + char separator, + object value, + Dictionary, List> returnData + ) { var fields = type.GetFields(); var d = returnData.Values.First(); @@ -282,14 +314,18 @@ private Dictionary, List> DetectGaps(Type type, char separa continue; } - if (field.FieldType.IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof(List<>)) + if ( + field.FieldType.IsGenericType + && field.FieldType.GetGenericTypeDefinition() == typeof(List<>) + ) { if (field.GetValue(value) != null && field.Name == "gaps") { var itemType = field.GetValue(value).GetType().GetGenericArguments()[0]; var list = field.GetValue(value); var a = (IList)list; - foreach (var s in a) returnData = DetectGaps(s.GetType(), separator, s, returnData); + foreach (var s in a) + returnData = DetectGaps(s.GetType(), separator, s, returnData); } } else @@ -310,7 +346,9 @@ private Dictionary, List> DetectGaps(Type type, char separa { if (((DateTime?)nestedValue).HasValue) { - val = ((DateTime?)nestedValue).Value.ToString("yyyy-MM-ddTHH:mm:ssZ"); + val = ((DateTime?)nestedValue).Value.ToString( + "yyyy-MM-ddTHH:mm:ssZ" + ); } h.Add(muterType + field.Name); @@ -329,4 +367,4 @@ private Dictionary, List> DetectGaps(Type type, char separa return returnData; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Anfrage.cs b/BO4E/BO/Anfrage.cs index efa1ad9a..8cc08877 100644 --- a/BO4E/BO/Anfrage.cs +++ b/BO4E/BO/Anfrage.cs @@ -1,13 +1,10 @@ +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// diff --git a/BO4E/BO/Angebot.cs b/BO4E/BO/Angebot.cs index 490f8a94..cceec17a 100644 --- a/BO4E/BO/Angebot.cs +++ b/BO4E/BO/Angebot.cs @@ -50,6 +50,7 @@ private DateTime _Angebotsdatum get => Angebotsdatum.UtcDateTime; set => Angebotsdatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Erstellungsdatum des Angebots, /// @@ -82,6 +83,7 @@ private DateTime _Bindefrist get => Bindefrist?.UtcDateTime ?? default; set => Bindefrist = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Bis zu diesem Zeitpunkt(Tag/Uhrzeit) inklusive gilt das Angebot /// @@ -121,7 +123,11 @@ private DateTime _Bindefrist /// Link auf die Person, die als Angebotsnehmer das Angebot angenommen hat. /// /// - [JsonProperty(Required = Required.Default, Order = 18, PropertyName = "unterzeichnerAngebotsnehmer")] + [JsonProperty( + Required = Required.Default, + Order = 18, + PropertyName = "unterzeichnerAngebotsnehmer" + )] [JsonPropertyName("unterzeichnerAngebotsnehmer")] [ProtoMember(11)] [JsonPropertyOrder(18)] @@ -132,7 +138,11 @@ private DateTime _Bindefrist /// Link auf die Person, die als Angebotsgeber das Angebots ausgestellt hat. /// /// - [JsonProperty(Required = Required.Default, Order = 19, PropertyName = "unterzeichnerAngebotsgeber")] + [JsonProperty( + Required = Required.Default, + Order = 19, + PropertyName = "unterzeichnerAngebotsgeber" + )] [JsonPropertyName("unterzeichnerAngebotsgeber")] [ProtoMember(12)] [JsonPropertyOrder(19)] diff --git a/BO4E/BO/Ansprechpartner.cs b/BO4E/BO/Ansprechpartner.cs index 3f4fbf23..03ac9ecf 100644 --- a/BO4E/BO/Ansprechpartner.cs +++ b/BO4E/BO/Ansprechpartner.cs @@ -82,8 +82,7 @@ public class Ansprechpartner : BusinessObject [JsonProperty(Required = Required.Default, Order = 17, PropertyName = "geschaeftspartner")] [JsonPropertyName("geschaeftspartner")] [JsonPropertyOrder(17)] - [NonOfficial(NonOfficialCategory - .UNSPECIFIED)] // it's always required in BO4E, changed it to default 2020-08-31 KK + [NonOfficial(NonOfficialCategory.UNSPECIFIED)] // it's always required in BO4E, changed it to default 2020-08-31 KK [ProtoMember(11)] [BoKey] public Geschaeftspartner? Geschaeftspartner { get; set; } @@ -97,8 +96,7 @@ public class Ansprechpartner : BusinessObject public Adresse? Adresse { get; set; } /// Liste der Telefonnummern, unter denen der Ansprechpartner erreichbar ist. - [NonOfficial(NonOfficialCategory - .UNSPECIFIED)] // We suggest to name it "rufnummern" instead of "rufnummer" because it's a list")] + [NonOfficial(NonOfficialCategory.UNSPECIFIED)] // We suggest to name it "rufnummern" instead of "rufnummer" because it's a list")] [JsonProperty(Required = Required.Default, Order = 19, PropertyName = "rufnummern")] [JsonPropertyName("rufnummern")] [JsonPropertyOrder(19)] @@ -112,4 +110,4 @@ public class Ansprechpartner : BusinessObject [JsonPropertyOrder(20)] [ProtoMember(14)] public List? Zustaendigkeit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Auftrag.cs b/BO4E/BO/Auftrag.cs index 85fd7ab7..7211beb2 100644 --- a/BO4E/BO/Auftrag.cs +++ b/BO4E/BO/Auftrag.cs @@ -1,18 +1,15 @@ using System; using System.Collections.Generic; using System.Text.Json.Serialization; - using BO4E.COM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; namespace BO4E.BO; /// -/// Ein Auftrag beschreibt einen Vorgang, der von einem anderen Marktpartner auszuführen ist. +/// Ein Auftrag beschreibt einen Vorgang, der von einem anderen Marktpartner auszuführen ist. /// [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] [ProtoContract] @@ -28,7 +25,9 @@ public abstract class Auftrag : BusinessObject protected DateTime? _Ausfuehrungsdatum { get => Ausfuehrungsdatum?.UtcDateTime; - set => Ausfuehrungsdatum = value != null ? DateTime.SpecifyKind(value.Value, DateTimeKind.Utc) : null; + set => + Ausfuehrungsdatum = + value != null ? DateTime.SpecifyKind(value.Value, DateTimeKind.Utc) : null; } /// @@ -50,7 +49,9 @@ protected DateTime? _Ausfuehrungsdatum protected DateTime _Fertigstellungsdatum { get => Fertigstellungsdatum?.UtcDateTime ?? DateTime.MinValue; - set => Fertigstellungsdatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + Fertigstellungsdatum = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } /// diff --git a/BO4E/BO/AuftragsStorno.cs b/BO4E/BO/AuftragsStorno.cs index afc786d0..5a2c08b4 100644 --- a/BO4E/BO/AuftragsStorno.cs +++ b/BO4E/BO/AuftragsStorno.cs @@ -7,11 +7,13 @@ namespace BO4E.BO; /// -/// DEPRECATED Ein AuftragsStorno beschreibt die Stornierung eines s. +/// DEPRECATED Ein AuftragsStorno beschreibt die Stornierung eines s. /// [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] [ProtoContract] -[Obsolete("This is not used in the implementation of the blocking process - we use the enum Auftragsstornogrund instead")] +[Obsolete( + "This is not used in the implementation of the blocking process - we use the enum Auftragsstornogrund instead" +)] public abstract class AuftragsStorno : BusinessObject { /// diff --git a/BO4E/BO/Avis.cs b/BO4E/BO/Avis.cs index da866e8e..09248320 100644 --- a/BO4E/BO/Avis.cs +++ b/BO4E/BO/Avis.cs @@ -1,13 +1,11 @@ #nullable enable +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Collections.Generic; -using System.Text.Json.Serialization; namespace BO4E.BO; diff --git a/BO4E/BO/Benachrichtigung.cs b/BO4E/BO/Benachrichtigung.cs index 05b33ff3..2ec66d30 100644 --- a/BO4E/BO/Benachrichtigung.cs +++ b/BO4E/BO/Benachrichtigung.cs @@ -67,6 +67,7 @@ private DateTime _ErstellungsZeitpunkt get => ErstellungsZeitpunkt.UtcDateTime; set => ErstellungsZeitpunkt = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zeitpunkt zu dem die Benachrichtigung erstellt wurde (UTC). /// @@ -76,6 +77,7 @@ private DateTime _ErstellungsZeitpunkt [ProtoIgnore] [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset ErstellungsZeitpunkt { get; set; } + /*{ get { return _erstellungsZeitpunkt; } set @@ -136,6 +138,7 @@ private DateTime _Deadline get => Deadline?.UtcDateTime ?? default; set => Deadline = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zeitpunkt bis zu dem die Benachrichtigung bearbeitet worden sein muss. /// diff --git a/BO4E/BO/Berechnungsformel.cs b/BO4E/BO/Berechnungsformel.cs index 09a61d34..a79e019f 100644 --- a/BO4E/BO/Berechnungsformel.cs +++ b/BO4E/BO/Berechnungsformel.cs @@ -28,6 +28,7 @@ private DateTime _Beginndatum get => Beginndatum.UtcDateTime; set => Beginndatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Der inklusive Zeitpunkt ab dem die Berechnungsformel gültig ist /// @@ -71,4 +72,4 @@ private DateTime _Beginndatum [JsonProperty(Required = Required.Default, Order = 9, PropertyName = "rechenschritt")] [JsonPropertyName("rechenschritt")] public Rechenschritt? Rechenschritt { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Bilanzierung.cs b/BO4E/BO/Bilanzierung.cs index f3977c91..e2498d50 100644 --- a/BO4E/BO/Bilanzierung.cs +++ b/BO4E/BO/Bilanzierung.cs @@ -1,16 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.EnergyIdentificationCodes; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -30,6 +27,7 @@ public class Bilanzierung : BusinessObject [ProtoMember(1000)] [BoKey] public string? MarktlokationsId { get; set; } + /// /// Eine Liste der verwendeten Lastprofile (SLP, SLP/TLP, ALP etc.) /// @@ -52,6 +50,7 @@ private DateTime _Bilanzierungsbeginn get => Bilanzierungsbeginn?.UtcDateTime ?? DateTime.MinValue; set => Bilanzierungsbeginn = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Inklusiver Start der Bilanzierung /// @@ -62,7 +61,6 @@ private DateTime _Bilanzierungsbeginn [ProtoIgnore] public DateTimeOffset? Bilanzierungsbeginn { get; set; } - /// /// Exklusives Ende der Bilanzierung /// @@ -75,6 +73,7 @@ private DateTime _Bilanzierungsende get => Bilanzierungsende?.UtcDateTime ?? DateTime.MinValue; set => Bilanzierungsende = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Exklusives Ende der Bilanzierung /// @@ -99,7 +98,11 @@ private DateTime _Bilanzierungsende /// /// Jahresverbrauchsprognose /// - [JsonProperty(PropertyName = "jahresverbrauchsprognose", Required = Required.Default, Order = 15)] + [JsonProperty( + PropertyName = "jahresverbrauchsprognose", + Required = Required.Default, + Order = 15 + )] [JsonPropertyName("jahresverbrauchsprognose")] [JsonPropertyOrder(15)] [NonOfficial(NonOfficialCategory.MISSING)] @@ -154,7 +157,11 @@ private DateTime _Bilanzierungsende /// /// Aggregationsverantwortung /// - [JsonProperty(PropertyName = "aggregationsverantwortung", Required = Required.Default, Order = 20)] + [JsonProperty( + PropertyName = "aggregationsverantwortung", + Required = Required.Default, + Order = 20 + )] [JsonPropertyName("aggregationsverantwortung")] [JsonPropertyOrder(20)] [NonOfficial(NonOfficialCategory.MISSING)] @@ -176,7 +183,11 @@ private DateTime _Bilanzierungsende /// Besteht der Bedarf ein tagesparameteräbhängiges Lastprofil mit gemeinsamer Messung anzugeben, so ist dies über die 2 -malige /// Wiederholung des CAV Segments mit der Angabe der Codes E02 und E14 möglich. /// - [JsonProperty(PropertyName = "detailsPrognosegrundlage", Required = Required.Default, Order = 22)] + [JsonProperty( + PropertyName = "detailsPrognosegrundlage", + Required = Required.Default, + Order = 22 + )] [JsonPropertyName("detailsPrognosegrundlage")] [JsonPropertyOrder(22)] [NonOfficial(NonOfficialCategory.MISSING)] @@ -186,7 +197,11 @@ private DateTime _Bilanzierungsende /// /// Wahlrecht der Prognosegrundlage (true = Wahlrecht beim Lieferanten vorhanden) /// - [JsonProperty(PropertyName = "wahlrechtPrognosegrundlage", Required = Required.Default, Order = 23)] + [JsonProperty( + PropertyName = "wahlrechtPrognosegrundlage", + Required = Required.Default, + Order = 23 + )] [JsonPropertyName("wahlrechtPrognosegrundlage")] [JsonPropertyOrder(23)] [NonOfficial(NonOfficialCategory.MISSING)] @@ -216,7 +231,11 @@ private DateTime _Bilanzierungsende /// /// Grund Wahlrecht der Prognosegrundlage (true = Wahlrecht beim Lieferanten vorhanden) /// - [JsonProperty(PropertyName = "grundWahlrechtPrognosegrundlage", Required = Required.Default, Order = 26)] + [JsonProperty( + PropertyName = "grundWahlrechtPrognosegrundlage", + Required = Required.Default, + Order = 26 + )] [JsonPropertyName("grundWahlrechtPrognosegrundlage")] [JsonPropertyOrder(26)] [NonOfficial(NonOfficialCategory.MISSING)] @@ -232,4 +251,4 @@ private DateTime _Bilanzierungsende [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(1019)] public Abwicklungsmodell? Abwicklungsmodell { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/BusinessObject.cs b/BO4E/BO/BusinessObject.cs index e837dc06..583e6ea5 100644 --- a/BO4E/BO/BusinessObject.cs +++ b/BO4E/BO/BusinessObject.cs @@ -1,21 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.Json; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.meta; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema.Generation; using Newtonsoft.Json.Serialization; - using ProtoBuf; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text.Json; -using System.Text.Json.Serialization; - using JsonConverter = Newtonsoft.Json.JsonConverter; using JsonSerializer = Newtonsoft.Json.JsonSerializer; @@ -103,7 +99,6 @@ public abstract class BusinessObject : IUserProperties, IOptionalGuid [ProtoIgnore] public const string USER_PROPERTIES_NAME = "userProperties"; - /// /// generates the BO4E boTyp attribute value (class name as upper case) /// @@ -173,14 +168,17 @@ protected DateTime _TimeStamp /// Store the latest database update, is Datetime, because postgres doesn't handle datetimeoffset in a generated column /// gracefully /// - [JsonProperty(PropertyName = "timestamp", NullValueHandling = NullValueHandling.Ignore, - Required = Required.Default, Order = 3)] + [JsonProperty( + PropertyName = "timestamp", + NullValueHandling = NullValueHandling.Ignore, + Required = Required.Default, + Order = 3 + )] [JsonPropertyName("timestamp")] [JsonPropertyOrder(3)] [ProtoIgnore] public DateTime? Timestamp { get; set; } - /// /// Hier können IDs anderer Systeme hinterlegt werden (z.B. eine SAP-GP-Nummer) (Details siehe /// ) @@ -194,7 +192,12 @@ protected DateTime _TimeStamp /// /// allows adding a GUID to Business Objects for tracking across systems /// - [JsonProperty(PropertyName = "guid", NullValueHandling = NullValueHandling.Ignore, Required = Required.Default, Order = 5)] + [JsonProperty( + PropertyName = "guid", + NullValueHandling = NullValueHandling.Ignore, + Required = Required.Default, + Order = 5 + )] [JsonPropertyName("guid")] [JsonPropertyOrder(5)] public virtual Guid? Guid { get; set; } @@ -202,8 +205,12 @@ protected DateTime _TimeStamp /// /// User properties (non bo4e standard) /// - [JsonProperty(PropertyName = USER_PROPERTIES_NAME, Required = Required.Default, - DefaultValueHandling = DefaultValueHandling.Ignore, Order = 200)] + [JsonProperty( + PropertyName = USER_PROPERTIES_NAME, + Required = Required.Default, + DefaultValueHandling = DefaultValueHandling.Ignore, + Order = 200 + )] [Newtonsoft.Json.JsonExtensionData] [ProtoMember(200)] [JsonPropertyOrder(200)] @@ -236,14 +243,14 @@ public List GetAmbiguousUserPropertiesKeys() { return new List(); } - var regularPropertyNames = GetType().GetProperties() + var regularPropertyNames = GetType() + .GetProperties() .Where(p => p.GetCustomAttribute() != null) .Select(p => p.GetCustomAttribute().Name) .Select(x => x.ToLower()) .ToHashSet(); var result = UserProperties - .Keys - .Where(k => regularPropertyNames.Contains(k.ToLower())) + .Keys.Where(k => regularPropertyNames.Contains(k.ToLower())) .ToList(); return result; } @@ -303,7 +310,8 @@ public static JSchema GetJsonSchema(Type boType) if (!boType.IsSubclassOf(typeof(BusinessObject))) { throw new ArgumentException( - $"You must only request JSON schemes for Business Objects. {boType} is not a valid Business Object type."); + $"You must only request JSON schemes for Business Objects. {boType} is not a valid Business Object type." + ); } var generator = new JSchemaGenerator(); @@ -395,13 +403,16 @@ public static Dictionary GetExpandablePropertyNames(Type boType) public static Dictionary GetExpandableFieldNames(string boTypeName) { #pragma warning disable CS0618 // Type or member is obsolete - var clazz = Assembly.GetExecutingAssembly().GetType(BoMapper.PackagePrefix + "." + boTypeName); + var clazz = Assembly + .GetExecutingAssembly() + .GetType(BoMapper.PackagePrefix + "." + boTypeName); #pragma warning restore CS0618 // Type or member is obsolete if (clazz == null) { #pragma warning disable CS0618 // Type or member is obsolete throw new ArgumentException( - $"{boTypeName} is not a valid Business Object name. Use one of the following: {string.Join("\n -", BoMapper.GetValidBoNames())}"); + $"{boTypeName} is not a valid Business Object name. Use one of the following: {string.Join("\n -", BoMapper.GetValidBoNames())}" + ); #pragma warning restore CS0618 // Type or member is obsolete } @@ -415,7 +426,10 @@ public static Dictionary GetExpandableFieldNames(string boTypeName /// Type inherited from Business Object /// true iff calling from outside the function itself / default /// HashSet of strings - protected static Dictionary GetExpandablePropertyNames(Type type, bool rootLevel = true) + protected static Dictionary GetExpandablePropertyNames( + Type type, + bool rootLevel = true + ) { if (rootLevel && !type.IsSubclassOf(typeof(BusinessObject))) { @@ -447,8 +461,10 @@ protected static Dictionary GetExpandablePropertyNames(Type type, result.Add(fieldName, prop.PropertyType); // coms do not contain any exandable subfield since they're flat } - else if (prop.PropertyType.IsGenericType && - prop.PropertyType.GetGenericTypeDefinition() == typeof(List<>)) + else if ( + prop.PropertyType.IsGenericType + && prop.PropertyType.GetGenericTypeDefinition() == typeof(List<>) + ) { var listElementType = prop.PropertyType.GetGenericArguments()[0]; foreach (var subResult in GetExpandablePropertyNames(listElementType, false)) @@ -490,10 +506,12 @@ public static List GetBoKeyProps(Type boType) if (!boType.IsSubclassOf(typeof(BusinessObject))) { throw new ArgumentException( - $"Business Object keys are only defined on Business Object types but {boType} is not a Business Object."); + $"Business Object keys are only defined on Business Object types but {boType} is not a Business Object." + ); } - return boType.GetProperties() + return boType + .GetProperties() .Where(p => p.GetCustomAttributes(typeof(BoKey), false).Length > 0) .OrderBy(ap => ap.GetCustomAttribute()?.Order) .ToList(); @@ -536,6 +554,7 @@ protected override JsonConverter ResolveContractConverter(Type objectType) internal class BusinessObjectBaseConverter : JsonConverter { public override bool CanWrite => false; + //private static readonly JsonSerializerSettings SpecifiedSubclassConversion = new JsonSerializerSettings() { ContractResolver = new BaseSpecifiedConcreteClassConverter() }; public override bool CanConvert(Type objectType) @@ -543,8 +562,12 @@ public override bool CanConvert(Type objectType) return objectType == typeof(BusinessObject); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) { if (reader.TokenType == JsonToken.Null) { @@ -555,22 +578,27 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { var jo = JObject.Load(reader); Type boType; - if (serializer.TypeNameHandling.HasFlag(TypeNameHandling.Objects) && - jo.TryGetValue("$type", out var typeToken)) + if ( + serializer.TypeNameHandling.HasFlag(TypeNameHandling.Objects) + && jo.TryGetValue("$type", out var typeToken) + ) { - boType = BusinessObjectSerializationBinder.BusinessObjectAndCOMTypes.SingleOrDefault(t => - typeToken.Value().ToUpper().StartsWith(t.FullName.ToUpper())); + boType = + BusinessObjectSerializationBinder.BusinessObjectAndCOMTypes.SingleOrDefault( + t => + typeToken.Value().ToUpper().StartsWith(t.FullName.ToUpper()) + ); } else if (!jo.ContainsKey("boTyp")) { throw new ArgumentException( - "If deserializing into an abstract BusinessObject the key \"boTyp\" has to be set. But it wasn't."); + "If deserializing into an abstract BusinessObject the key \"boTyp\" has to be set. But it wasn't." + ); } else { #pragma warning disable CS0618 // Type or member is obsolete - boType = BoMapper.GetTypeForBoName(jo["boTyp"] - .Value()); // ToDo: catch exception if boTyp is not set and throw exception with descriptive error message + boType = BoMapper.GetTypeForBoName(jo["boTyp"].Value()); // ToDo: catch exception if boTyp is not set and throw exception with descriptive error message #pragma warning restore CS0618 // Type or member is obsolete } @@ -580,8 +608,15 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { try { - boType = assembley.GetTypes().FirstOrDefault(x => string.Equals(x.Name, - jo["boTyp"].Value(), StringComparison.CurrentCultureIgnoreCase)); + boType = assembley + .GetTypes() + .FirstOrDefault(x => + string.Equals( + x.Name, + jo["boTyp"].Value(), + StringComparison.CurrentCultureIgnoreCase + ) + ); } catch (ReflectionTypeLoadException) { @@ -597,28 +632,32 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (boType == null) { throw new NotImplementedException( - $"The type '{jo["boTyp"].Value()}' does not exist in the BO4E standard."); + $"The type '{jo["boTyp"].Value()}' does not exist in the BO4E standard." + ); } } - var deserializationMethod = serializer.GetType() // https://stackoverflow.com/a/5218492/10009545 + var deserializationMethod = serializer + .GetType() // https://stackoverflow.com/a/5218492/10009545 .GetMethods() .Where(m => m.Name == nameof(serializer.Deserialize)) .Select(m => new { Method = m, Params = m.GetParameters(), - Args = m.GetGenericArguments() + Args = m.GetGenericArguments(), }) - .Where(x => x.Params.Length == 1 - && x.Args.Length == 1) + .Where(x => x.Params.Length == 1 && x.Args.Length == 1) .Select(x => x.Method) .First() .GetGenericMethodDefinition() .MakeGenericMethod(boType); try { - return deserializationMethod.Invoke(serializer, new object[] { jo.CreateReader() }); + return deserializationMethod.Invoke( + serializer, + new object[] { jo.CreateReader() } + ); } catch (TargetInvocationException tie) when (tie.InnerException != null) { @@ -633,12 +672,13 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { throw new NotImplementedException( - "Serializing an abstract BusinessObject is not supported."); // won't be called because CanWrite returns false + "Serializing an abstract BusinessObject is not supported." + ); // won't be called because CanWrite returns false } } - internal class - BusinessObjectSystemTextJsonBaseConverter : System.Text.Json.Serialization.JsonConverter + internal class BusinessObjectSystemTextJsonBaseConverter + : System.Text.Json.Serialization.JsonConverter { //private static readonly JsonSerializerSettings SpecifiedSubclassConversion = new JsonSerializerSettings() { ContractResolver = new BaseSpecifiedConcreteClassConverter() }; @@ -647,8 +687,11 @@ public override bool CanConvert(Type objectType) return objectType == typeof(BusinessObject); } - public override BusinessObject Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) + public override BusinessObject Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TokenType == JsonTokenType.Null) { @@ -673,8 +716,15 @@ public override BusinessObject Read(ref Utf8JsonReader reader, Type typeToConver { try { - boType = assembley.GetTypes().FirstOrDefault(x => - string.Equals(x.Name, boTypeString, StringComparison.CurrentCultureIgnoreCase)); + boType = assembley + .GetTypes() + .FirstOrDefault(x => + string.Equals( + x.Name, + boTypeString, + StringComparison.CurrentCultureIgnoreCase + ) + ); } catch (ReflectionTypeLoadException) { @@ -690,19 +740,26 @@ public override BusinessObject Read(ref Utf8JsonReader reader, Type typeToConver if (boType == null) { throw new NotImplementedException( - $"The type '{boTypeString}' does not exist in the BO4E standard."); + $"The type '{boTypeString}' does not exist in the BO4E standard." + ); } } - return System.Text.Json.JsonSerializer.Deserialize(jdoc.RootElement.GetRawText(), boType, options) - as BusinessObject; + return System.Text.Json.JsonSerializer.Deserialize( + jdoc.RootElement.GetRawText(), + boType, + options + ) as BusinessObject; } return null; } - - public override void Write(Utf8JsonWriter writer, BusinessObject value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + BusinessObject value, + JsonSerializerOptions options + ) { var boTypeString = value.GetBoTyp(); #pragma warning disable CS0618 // Type or member is obsolete @@ -711,4 +768,4 @@ public override void Write(Utf8JsonWriter writer, BusinessObject value, JsonSeri System.Text.Json.JsonSerializer.Serialize(writer, value, boType, options); } } -} \ No newline at end of file +} diff --git a/BO4E/BO/Einspeisung.cs b/BO4E/BO/Einspeisung.cs index 1c641aa9..3eaa1490 100644 --- a/BO4E/BO/Einspeisung.cs +++ b/BO4E/BO/Einspeisung.cs @@ -1,10 +1,7 @@ using System.Text.Json.Serialization; - using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; namespace BO4E.BO; @@ -39,7 +36,7 @@ public class Einspeisung : BusinessObject public string? TrancheId { get; set; } /// - /// Empfänger der Vergütung zur Einspeisung + /// Empfänger der Vergütung zur Einspeisung /// [JsonProperty(PropertyName = "verguetungsempfaenger", Required = Required.Default, Order = 11)] [JsonPropertyName("verguetungsempfaenger")] @@ -69,10 +66,14 @@ public class Einspeisung : BusinessObject /// /// Status der Fernsteuerbarkeit einer Marktlokation /// - [JsonProperty(PropertyName = "fernsteuerbarkeitStatus", Required = Required.Default, Order = 14)] + [JsonProperty( + PropertyName = "fernsteuerbarkeitStatus", + Required = Required.Default, + Order = 14 + )] [JsonPropertyName("fernsteuerbarkeitStatus")] [JsonPropertyOrder(14)] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(12)] public FernsteuerbarkeitStatus? FernsteuerbarkeitStatus { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Energiemenge.cs b/BO4E/BO/Energiemenge.cs index 3e97c048..1e8f6d96 100644 --- a/BO4E/BO/Energiemenge.cs +++ b/BO4E/BO/Energiemenge.cs @@ -5,14 +5,11 @@ using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; - using BO4E.COM; using BO4E.ENUM; using BO4E.meta; using Newtonsoft.Json; - using ProtoBuf; - using JsonSerializer = System.Text.Json.JsonSerializer; namespace BO4E.BO; @@ -27,14 +24,13 @@ public class Energiemenge : BusinessObject /// static serializer options for Energiemengenconverter /// public static JsonSerializerOptions? EnergiemengeSerializerOptions; + /// /// Semaphore to protect access to the serializer /// public static readonly System.Threading.SemaphoreSlim SerializerSemaphore = new(1); - static Energiemenge() - { - } + static Energiemenge() { } /// /// Eindeutige Nummer der Marktlokation bzw. der Messlokation, zu der die Energiemenge gehört @@ -80,18 +76,22 @@ static Energiemenge() /// new Energiemenge object public static Energiemenge operator +(Energiemenge em1, Energiemenge em2) { - if (em1.LokationsId != em2.LokationsId || em1.LokationsTyp != em2.LokationsTyp || - em1.VersionStruktur != em2.VersionStruktur) + if ( + em1.LokationsId != em2.LokationsId + || em1.LokationsTyp != em2.LokationsTyp + || em1.VersionStruktur != em2.VersionStruktur + ) { throw new InvalidOperationException( - $"You must not add the Energiemengen with different locations {em1.LokationsId} ({em1.LokationsTyp}) (v{em1.VersionStruktur}) vs. {em2.LokationsId} ({em2.LokationsTyp}) (v{em2.VersionStruktur})"); + $"You must not add the Energiemengen with different locations {em1.LokationsId} ({em1.LokationsTyp}) (v{em1.VersionStruktur}) vs. {em2.LokationsId} ({em2.LokationsTyp}) (v{em2.VersionStruktur})" + ); } var result = new Energiemenge { LokationsId = em1.LokationsId, LokationsTyp = em1.LokationsTyp, - VersionStruktur = em1.VersionStruktur + VersionStruktur = em1.VersionStruktur, }; if (em1.UserProperties == null) { @@ -105,7 +105,8 @@ static Energiemenge() { // there's no consistency check on user properties! result.UserProperties = new Dictionary(); - foreach (var kvp1 in em1.UserProperties) result.UserProperties.Add(kvp1.Key, kvp1.Value); + foreach (var kvp1 in em1.UserProperties) + result.UserProperties.Add(kvp1.Key, kvp1.Value); foreach (var kvp2 in em2.UserProperties) if (!result.UserProperties.ContainsKey(kvp2.Key)) { @@ -143,20 +144,34 @@ public class EnergiemengeConverter : System.Text.Json.Serialization.JsonConverte /// /// /// - public override Energiemenge Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Energiemenge Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { Energiemenge.SerializerSemaphore.Wait(); if (Energiemenge.EnergiemengeSerializerOptions == null) { Energiemenge.EnergiemengeSerializerOptions = new JsonSerializerOptions(options); - while (Energiemenge.EnergiemengeSerializerOptions.Converters.Any(s => s.GetType() == typeof(EnergiemengeConverter))) + while ( + Energiemenge.EnergiemengeSerializerOptions.Converters.Any(s => + s.GetType() == typeof(EnergiemengeConverter) + ) + ) { Energiemenge.EnergiemengeSerializerOptions.Converters.Remove( - Energiemenge.EnergiemengeSerializerOptions.Converters.First(s => s.GetType() == typeof(EnergiemengeConverter))); + Energiemenge.EnergiemengeSerializerOptions.Converters.First(s => + s.GetType() == typeof(EnergiemengeConverter) + ) + ); } } Energiemenge.SerializerSemaphore.Release(); - var e = JsonSerializer.Deserialize(ref reader, Energiemenge.EnergiemengeSerializerOptions); + var e = JsonSerializer.Deserialize( + ref reader, + Energiemenge.EnergiemengeSerializerOptions + ); if (e.Energieverbrauch == null) { e.Energieverbrauch = new List(); @@ -170,16 +185,27 @@ public override Energiemenge Read(ref Utf8JsonReader reader, Type typeToConvert, /// /// /// - public override void Write(Utf8JsonWriter writer, Energiemenge value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + Energiemenge value, + JsonSerializerOptions options + ) { Energiemenge.SerializerSemaphore.Wait(); if (Energiemenge.EnergiemengeSerializerOptions == null) { Energiemenge.EnergiemengeSerializerOptions = new JsonSerializerOptions(options); - while (Energiemenge.EnergiemengeSerializerOptions.Converters.Any(s => s.GetType() == typeof(EnergiemengeConverter))) + while ( + Energiemenge.EnergiemengeSerializerOptions.Converters.Any(s => + s.GetType() == typeof(EnergiemengeConverter) + ) + ) { Energiemenge.EnergiemengeSerializerOptions.Converters.Remove( - Energiemenge.EnergiemengeSerializerOptions.Converters.First(s => s.GetType() == typeof(EnergiemengeConverter))); + Energiemenge.EnergiemengeSerializerOptions.Converters.First(s => + s.GetType() == typeof(EnergiemengeConverter) + ) + ); } } Energiemenge.SerializerSemaphore.Release(); diff --git a/BO4E/BO/Entsperrauftrag.cs b/BO4E/BO/Entsperrauftrag.cs index 7d09afc4..057c8192 100644 --- a/BO4E/BO/Entsperrauftrag.cs +++ b/BO4E/BO/Entsperrauftrag.cs @@ -38,4 +38,4 @@ public class Entsperrauftrag : Auftrag [JsonProperty("istNurInnerhalbDerArbeitszeitZuEntsperren", Required = Required.Always)] [JsonPropertyName("istNurInnerhalbDerArbeitszeitZuEntsperren")] public bool IstNurInnerhalbDerArbeitszeitZuEntsperren { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Geschaeftspartner.cs b/BO4E/BO/Geschaeftspartner.cs index 6633c88a..15718417 100644 --- a/BO4E/BO/Geschaeftspartner.cs +++ b/BO4E/BO/Geschaeftspartner.cs @@ -97,7 +97,6 @@ public class Geschaeftspartner : BusinessObject [DataCategory(DataCategory.LEGAL)] public string? Hrnummer { get; set; } - /// Amtsgericht bzw Handelsregistergericht, das die Handelsregisternummer herausgegeben hat [JsonProperty(Required = Required.Default, Order = 13, PropertyName = "amtsgericht")] [JsonPropertyOrder(13)] @@ -147,8 +146,7 @@ public class Geschaeftspartner : BusinessObject public string? Website { get; set; } /// Rolle, die der Geschäftspartner hat (z.B. Interessent, Kunde). - [JsonProperty(Required = Required.Default, Order = 19, - PropertyName = "geschaeftspartnerrolle")] // ToDo: it's actually required but I need it to work quickly + [JsonProperty(Required = Required.Default, Order = 19, PropertyName = "geschaeftspartnerrolle")] // ToDo: it's actually required but I need it to work quickly [JsonPropertyName("geschaeftspartnerrolle")] [JsonPropertyOrder(19)] [FieldName("role", Language.EN)] @@ -168,7 +166,11 @@ public class Geschaeftspartner : BusinessObject /// /// Grundlage zur Verringerung der Umlagen nach EnFG /// - [JsonProperty(PropertyName = "grundlageZurVerringerungDerUmlagenNachEnfg", Required = Required.Default, Order = 21)] + [JsonProperty( + PropertyName = "grundlageZurVerringerungDerUmlagenNachEnfg", + Required = Required.Default, + Order = 21 + )] [JsonPropertyName("grundlageZurVerringerungDerUmlagenNachEnfg")] [JsonPropertyOrder(21)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -178,7 +180,11 @@ public class Geschaeftspartner : BusinessObject /// /// Grund der Privilegierung nach EnFG /// - [JsonProperty(PropertyName = "grundDerPrivilegierungNachEnFG", Required = Required.Default, Order = 22)] + [JsonProperty( + PropertyName = "grundDerPrivilegierungNachEnFG", + Required = Required.Default, + Order = 22 + )] [JsonPropertyName("grundDerPrivilegierungNachEnFG")] [JsonPropertyOrder(22)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] diff --git a/BO4E/BO/Handelsunstimmigkeit.cs b/BO4E/BO/Handelsunstimmigkeit.cs index cef26f7a..2b135d25 100644 --- a/BO4E/BO/Handelsunstimmigkeit.cs +++ b/BO4E/BO/Handelsunstimmigkeit.cs @@ -1,13 +1,10 @@ +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -17,7 +14,6 @@ namespace BO4E.BO; [NonOfficial(NonOfficialCategory.MISSING)] public class Handelsunstimmigkeit : BusinessObject { - /// /// Handelsunstimmigkeitsnummer /// @@ -59,5 +55,4 @@ public class Handelsunstimmigkeit : BusinessObject [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(1003)] public Betrag? ZuZahlen { get; set; } - } diff --git a/BO4E/BO/Lokationszuordnung.cs b/BO4E/BO/Lokationszuordnung.cs index bb4edcf9..74c0f9a0 100644 --- a/BO4E/BO/Lokationszuordnung.cs +++ b/BO4E/BO/Lokationszuordnung.cs @@ -12,10 +12,8 @@ namespace BO4E.BO; /// Messlokationen, Netzlokationen, technische/steuerbaren Ressourcen an einer Lokation vorhanden sind; /// [ProtoContract] - public class Lokationszuordnung : BusinessObject { - /// /// Liste mit IDs der referenzierten Marktlokationen /// @@ -71,7 +69,6 @@ public class Lokationszuordnung : BusinessObject // Instead of COM.Zeitspanne (bo4e-python) public List? Gueltigkeit { get; set; } - /// /// Verknüpfungsrichtung z.B. Malo-Melo /// @@ -90,5 +87,4 @@ public class Lokationszuordnung : BusinessObject [ProtoMember(18)] [BoKey] public string? LokationsbuendelCode { get; set; } - -} \ No newline at end of file +} diff --git a/BO4E/BO/MabisZaehlpunkt.cs b/BO4E/BO/MabisZaehlpunkt.cs index b07efa41..a95b59db 100644 --- a/BO4E/BO/MabisZaehlpunkt.cs +++ b/BO4E/BO/MabisZaehlpunkt.cs @@ -1,15 +1,13 @@ -using BO4E.meta; - -using Newtonsoft.Json; - -using ProtoBuf; using System.ComponentModel; using System.Text.Json.Serialization; using System.Text.RegularExpressions; +using BO4E.meta; +using Newtonsoft.Json; +using ProtoBuf; namespace BO4E.BO; -/// Objekt zur Aufnahme der Informationen zu einem MabisZaehlpunkt. +/// Objekt zur Aufnahme der Informationen zu einem MabisZaehlpunkt. [ProtoContract] public class MabisZaehlpunkt : BusinessObject { @@ -30,7 +28,6 @@ public class MabisZaehlpunkt : BusinessObject [ProtoMember(4)] public string Id { get; set; } - /// /// Test if a is a valid messlokations ID. /// diff --git a/BO4E/BO/Marktlokation.cs b/BO4E/BO/Marktlokation.cs index c74193cf..7b0b50f4 100644 --- a/BO4E/BO/Marktlokation.cs +++ b/BO4E/BO/Marktlokation.cs @@ -29,8 +29,7 @@ public class Marktlokation : BusinessObject /// //[Newtonsoft.Json.JsonIgnore] [System.Text.Json.Serialization.JsonIgnore] - protected static readonly Regex RegexValidate = - new(@"^[1-9][\d]{10}$", RegexOptions.Compiled); + protected static readonly Regex RegexValidate = new(@"^[1-9][\d]{10}$", RegexOptions.Compiled); /// /// Regular Expression to check if a string consists only of numbers (is numeric) @@ -67,11 +66,7 @@ public class Marktlokation : BusinessObject public Energierichtung? Energierichtung { get; set; } /// Kennzeichnung, ob Energie eingespeist oder entnommen (ausgespeist) wird. - [JsonProperty( - Required = Required.Default, - Order = 13, - PropertyName = "bilanzierungsmethode" - )] + [JsonProperty(Required = Required.Default, Order = 13, PropertyName = "bilanzierungsmethode")] [JsonPropertyName("bilanzierungsmethode")] [JsonPropertyOrder(13)] [ProtoMember(7)] @@ -107,11 +102,7 @@ public class Marktlokation : BusinessObject /// Codenummer des Netzbetreibers, an dessen Netz diese Marktlokation /// angeschlossen ist. /// - [JsonProperty( - PropertyName = "netzbetreiberCodeNr", - Required = Required.Default, - Order = 17 - )] + [JsonProperty(PropertyName = "netzbetreiberCodeNr", Required = Required.Default, Order = 17)] [JsonPropertyOrder(17)] [JsonPropertyName("netzbetreiberCodeNr")] [ProtoMember(11)] @@ -133,22 +124,14 @@ public class Marktlokation : BusinessObject public string? NetzgebietNr { get; set; } /// Bilanzierungsgebiet, dem das Netzgebiet zugeordnet ist - im Falle eines Strom Netzes. - [JsonProperty( - Required = Required.Default, - Order = 20, - PropertyName = "bilanzierungsgebiet" - )] + [JsonProperty(Required = Required.Default, Order = 20, PropertyName = "bilanzierungsgebiet")] [JsonPropertyOrder(20)] [JsonPropertyName("bilanzierungsgebiet")] [ProtoMember(14)] public string? Bilanzierungsgebiet { get; set; } /// CodeNummer des Grundversorgers, der für diese Marktlokation zuständig ist. - [JsonProperty( - PropertyName = "grundversorgerCodeNr", - Order = 21, - Required = Required.Default - )] + [JsonProperty(PropertyName = "grundversorgerCodeNr", Order = 21, Required = Required.Default)] [JsonPropertyOrder(21)] [JsonPropertyName("grundversorgerCodeNr")] [ProtoMember(15)] @@ -203,11 +186,7 @@ public class Marktlokation : BusinessObject /// Flurstück erfolgen. /// [DataCategory(DataCategory.ADDRESS)] - [JsonProperty( - Required = Required.Default, - Order = 26, - PropertyName = "katasterinformation" - )] + [JsonProperty(Required = Required.Default, Order = 26, PropertyName = "katasterinformation")] [JsonPropertyOrder(26)] [JsonPropertyName("katasterinformation")] [ProtoMember(20)] @@ -394,11 +373,7 @@ public class Marktlokation : BusinessObject /// /// Produkt-Daten der Marktlokation /// - [JsonProperty( - Required = Required.Default, - Order = 40, - PropertyName = "konfigurationsprodukte" - )] + [JsonProperty(Required = Required.Default, Order = 40, PropertyName = "konfigurationsprodukte")] [JsonPropertyName("konfigurationsprodukte")] [ProtoMember(40)] [JsonPropertyOrder(40)] @@ -494,9 +469,7 @@ public static string GetChecksum(string input) if (!RegexNumericString.IsMatch(input)) { - throw new ArgumentException( - $"Input '{nameof(input)}' must be numeric was '{input}'" - ); + throw new ArgumentException($"Input '{nameof(input)}' must be numeric was '{input}'"); } var oddChecksum = 0; @@ -544,17 +517,17 @@ public bool IsValid( ) { return base.IsValid() - && (!checkId || HasValidId()) - && ( - !checkRegelZone - || (string.IsNullOrWhiteSpace(Regelzone) || Regelzone.IsGermanControlArea()) - ) - && ( - !checkBilanzierungsgebiet - || ( - string.IsNullOrWhiteSpace(Bilanzierungsgebiet) - || Bilanzierungsgebiet.IsValidBilanzierungsGebietId() - ) - ); + && (!checkId || HasValidId()) + && ( + !checkRegelZone + || (string.IsNullOrWhiteSpace(Regelzone) || Regelzone.IsGermanControlArea()) + ) + && ( + !checkBilanzierungsgebiet + || ( + string.IsNullOrWhiteSpace(Bilanzierungsgebiet) + || Bilanzierungsgebiet.IsValidBilanzierungsGebietId() + ) + ); } } diff --git a/BO4E/BO/Marktteilnehmer.cs b/BO4E/BO/Marktteilnehmer.cs index 6b6fc608..abe60b8c 100644 --- a/BO4E/BO/Marktteilnehmer.cs +++ b/BO4E/BO/Marktteilnehmer.cs @@ -49,8 +49,7 @@ public Marktteilnehmer() /// Die 1:1-Kommunikationsadresse des Marktteilnehmers. Diese wird in der /// Marktkommunikation verwendet. /// - [JsonProperty(Required = Required.Default, Order = 34, - PropertyName = "makoadresse")] // relaxed from always to default to make COM.Marktrolle obsolete. + [JsonProperty(Required = Required.Default, Order = 34, PropertyName = "makoadresse")] // relaxed from always to default to make COM.Marktrolle obsolete. [JsonPropertyName("makoadresse")] [JsonPropertyOrder(34)] //[ProtoMember(22)] diff --git a/BO4E/BO/Messlokation.cs b/BO4E/BO/Messlokation.cs index dc7151fa..dddf85b8 100644 --- a/BO4E/BO/Messlokation.cs +++ b/BO4E/BO/Messlokation.cs @@ -146,11 +146,7 @@ public class Messlokation : BusinessObject /// eine Adresse oder eine GeoKoordinate oder eine Katasteradresse. /// /// */ - [JsonProperty( - PropertyName = "katasterinformation", - Required = Required.Default, - Order = 19 - )] + [JsonProperty(PropertyName = "katasterinformation", Required = Required.Default, Order = 19)] [JsonPropertyOrder(19)] [JsonPropertyName("katasterinformation")] [ProtoMember(13)] @@ -172,11 +168,7 @@ public class Messlokation : BusinessObject public List? Messdienstleistung { get; set; } /// Zähler, die zu dieser Messlokation gehören. Details - [JsonProperty( - PropertyName = "messlokationszaehler", - Required = Required.Default, - Order = 22 - )] + [JsonProperty(PropertyName = "messlokationszaehler", Required = Required.Default, Order = 22)] [JsonPropertyOrder(22)] [JsonPropertyName("messlokationszaehler")] [ProtoMember(16)] @@ -185,11 +177,7 @@ public class Messlokation : BusinessObject /// /// /// - [JsonProperty( - PropertyName = "bilanzierungsmethode", - Required = Required.Default, - Order = 23 - )] + [JsonProperty(PropertyName = "bilanzierungsmethode", Required = Required.Default, Order = 23)] [JsonPropertyOrder(23)] [JsonPropertyName("bilanzierungsmethode")] [ProtoMember(17)] @@ -282,7 +270,6 @@ public class Messlokation : BusinessObject [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] public List? Messprodukte { get; set; } - // /// // /// Lokationszuordnung, um bspw. die zugehörigen Marktlokationen anzugeben // /// @@ -352,4 +339,4 @@ public bool IsValid(bool checkId = true) { return base.IsValid() && (!checkId || HasValidId()); } -} \ No newline at end of file +} diff --git a/BO4E/BO/Netzlokation.cs b/BO4E/BO/Netzlokation.cs index e1f85734..b49af05a 100644 --- a/BO4E/BO/Netzlokation.cs +++ b/BO4E/BO/Netzlokation.cs @@ -38,11 +38,7 @@ public class Netzlokation : BusinessObject /// /// Netzanschlussleistungsmenge der Netzlokation /// - [JsonProperty( - Required = Required.Default, - Order = 12, - PropertyName = "netzanschlussleistung" - )] + [JsonProperty(Required = Required.Default, Order = 12, PropertyName = "netzanschlussleistung")] [JsonPropertyOrder(12)] [JsonPropertyName("netzanschlussleistung")] [ProtoMember(6)] @@ -93,11 +89,7 @@ public class Netzlokation : BusinessObject /// /// Produkt-Daten der Netzlokation /// - [JsonProperty( - Required = Required.Default, - Order = 17, - PropertyName = "konfigurationsprodukte" - )] + [JsonProperty(Required = Required.Default, Order = 17, PropertyName = "konfigurationsprodukte")] [JsonPropertyName("konfigurationsprodukte")] [ProtoMember(11)] [JsonPropertyOrder(17)] @@ -107,11 +99,7 @@ public class Netzlokation : BusinessObject /// /// Eigenschaft des Messstellenbetreiber an der Lokation /// - [JsonProperty( - Required = Required.Default, - Order = 18, - PropertyName = "eigenschaftMSBLokation" - )] + [JsonProperty(Required = Required.Default, Order = 18, PropertyName = "eigenschaftMSBLokation")] [JsonPropertyName("eigenschaftMSBLokation")] [ProtoMember(12)] [JsonPropertyOrder(18)] diff --git a/BO4E/BO/Preisblatt.cs b/BO4E/BO/Preisblatt.cs index af61b0f4..4ce81668 100644 --- a/BO4E/BO/Preisblatt.cs +++ b/BO4E/BO/Preisblatt.cs @@ -75,4 +75,4 @@ public class Preisblatt : BusinessObject [JsonPropertyName("sparte")] [JsonPropertyOrder(15)] public Sparte? Sparte { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/PreisblattMessung.cs b/BO4E/BO/PreisblattMessung.cs index dd892a73..ef93e671 100644 --- a/BO4E/BO/PreisblattMessung.cs +++ b/BO4E/BO/PreisblattMessung.cs @@ -32,7 +32,11 @@ public class PreisblattMessung : Preisblatt /// /// Im Preis sind die hier angegebenen Dienstleistungen enthalten. Z.B. Jährliche Ablesung. /// - [JsonProperty(Required = Required.Default, Order = 10, PropertyName = "inklusiveDienstleistung")] + [JsonProperty( + Required = Required.Default, + Order = 10, + PropertyName = "inklusiveDienstleistung" + )] [JsonPropertyName("inklusiveDienstleistung")] //[ProtoMember(10)] public List? InklusiveDienstleistung { get; set; } diff --git a/BO4E/BO/PreisblattNetznutzung.cs b/BO4E/BO/PreisblattNetznutzung.cs index 381bded9..4f8d782e 100644 --- a/BO4E/BO/PreisblattNetznutzung.cs +++ b/BO4E/BO/PreisblattNetznutzung.cs @@ -10,7 +10,6 @@ namespace BO4E.BO; //[ProtoContract] public class PreisblattNetznutzung : Preisblatt { - /// /// Die Preise gelten für Marktlokationen der angegebenen Bilanzierungsmethode. /// diff --git a/BO4E/BO/PreisblattUmlagen.cs b/BO4E/BO/PreisblattUmlagen.cs index 436fa280..599517e7 100644 --- a/BO4E/BO/PreisblattUmlagen.cs +++ b/BO4E/BO/PreisblattUmlagen.cs @@ -4,7 +4,4 @@ namespace BO4E.BO; /// Die Variante des Preisblattmodells zur Abbildung von allgemeinen Abgaben. /// //[ProtoContract] -public class PreisblattUmlagen : Preisblatt -{ - -} +public class PreisblattUmlagen : Preisblatt { } diff --git a/BO4E/BO/Rechnung.cs b/BO4E/BO/Rechnung.cs index 001bbe86..4cd3ef7d 100644 --- a/BO4E/BO/Rechnung.cs +++ b/BO4E/BO/Rechnung.cs @@ -1,17 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -25,55 +22,84 @@ public class Rechnung : BusinessObject /// /// empty constructor for deserilization /// - public Rechnung() - { - } + public Rechnung() { } /// /// this constructor creates a BO4E.Rechnung from a JSON serialized SAP print document ("Druckbeleg") /// /// a JSON serialized SAP print document using lowerCamelCase naming convention - public Rechnung(JObject sapPrintDocument) : this() + public Rechnung(JObject sapPrintDocument) + : this() { // why is this method so bloated and always tries to access two different keys of the JSON document using the ?? operator? // Initially I exported the SAP print document "Druckbeleg") using the SAP library /ui2/cl_json which allows for pretty printing // the ALL_UPPER_CASE SAP internal keys to lowerCamelCase. Later on technical constraints in SAP forced me to use a different // serialization which is closer to SAPs internal structure and has no lower case keys at all. Furthermore in SAP there is // no difference between string.Empty and null; the latter doesn't even exist as a concept. - var infoToken = sapPrintDocument.SelectToken("erdk") ?? sapPrintDocument.SelectToken("ERDK"); - var tErdzToken = sapPrintDocument.SelectToken("tErdz") ?? sapPrintDocument.SelectToken("T_ERDZ"); + var infoToken = + sapPrintDocument.SelectToken("erdk") ?? sapPrintDocument.SelectToken("ERDK"); + var tErdzToken = + sapPrintDocument.SelectToken("tErdz") ?? sapPrintDocument.SelectToken("T_ERDZ"); if (tErdzToken == null) { throw new ArgumentException( - "The SAP print document did not contain a 'tErdz' token. Did you serialize using the right naming convention?"); + "The SAP print document did not contain a 'tErdz' token. Did you serialize using the right naming convention?" + ); } Rechnungsnummer = (infoToken["opbel"] ?? infoToken["OPBEL"]).Value(); - Rechnungsdatum = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (infoToken["bldat"] ?? infoToken["BLDAT"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)); + Rechnungsdatum = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (infoToken["bldat"] ?? infoToken["BLDAT"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ); Rechnungsperiode = new Zeitraum { - Startdatum = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (tErdzToken[0]["ab"] ?? tErdzToken[0]["AB"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)), - Enddatum = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (tErdzToken[0]["bis"] ?? tErdzToken[0]["BIS"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)) + Startdatum = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (tErdzToken[0]["ab"] ?? tErdzToken[0]["AB"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ), + Enddatum = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (tErdzToken[0]["bis"] ?? tErdzToken[0]["BIS"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ), }; - Faelligkeitsdatum = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (infoToken["faedn"] ?? infoToken["FAEDN"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)); + Faelligkeitsdatum = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (infoToken["faedn"] ?? infoToken["FAEDN"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ); Storno = false; - decimal gSteure, vGezahlt, rBrutto; + decimal gSteure, + vGezahlt, + rBrutto; var gNetto = gSteure = _ = vGezahlt = rBrutto = 0.00M; - var waehrungscode = (Waehrungscode)Enum.Parse(typeof(Waehrungscode), - (infoToken["totalWaer"] ?? infoToken["TOTAL_WAER"]).Value()); - var waehrungseinheit = (Waehrungseinheit)Enum.Parse(typeof(Waehrungseinheit), - (infoToken["totalWaer"] ?? infoToken["TOTAL_WAER"]).Value()); - var mengeneinheit = (Mengeneinheit)Enum.Parse(typeof(Mengeneinheit), - (tErdzToken[0]["massbill"] ?? tErdzToken[0]["MASSBILL"]).Value()); + var waehrungscode = (Waehrungscode) + Enum.Parse( + typeof(Waehrungscode), + (infoToken["totalWaer"] ?? infoToken["TOTAL_WAER"]).Value() + ); + var waehrungseinheit = (Waehrungseinheit) + Enum.Parse( + typeof(Waehrungseinheit), + (infoToken["totalWaer"] ?? infoToken["TOTAL_WAER"]).Value() + ); + var mengeneinheit = (Mengeneinheit) + Enum.Parse( + typeof(Mengeneinheit), + (tErdzToken[0]["massbill"] ?? tErdzToken[0]["MASSBILL"]).Value() + ); var rpList = new List(); var stList = new List(); @@ -97,13 +123,17 @@ public Rechnung(JObject sapPrintDocument) : this() rp.Positionstext = "PAUSCHALE"; mengeneinheit = Mengeneinheit.JAHR; zeitbezogeneMengeWert = (jrp["preisbtr"] ?? jrp["PREISBTR"]).Value(); - rp.ZeitbezogeneMenge = new Menge { Einheit = Mengeneinheit.TAG, Wert = zeitbezogeneMengeWert }; + rp.ZeitbezogeneMenge = new Menge + { + Einheit = Mengeneinheit.TAG, + Wert = zeitbezogeneMengeWert, + }; rp.Einzelpreis = new Preis { Wert = decimal.Parse((jrp["zeitant"] ?? jrp["ZEITANT"]).ToString()), Einheit = waehrungseinheit, - Bezugswert = mengeneinheit + Bezugswert = mengeneinheit, }; break; case "000004": @@ -121,19 +151,30 @@ public Rechnung(JObject sapPrintDocument) : this() break; } - if ((jrp["massbill"] ?? jrp["MASSBILL"]) != null && - !string.IsNullOrWhiteSpace((jrp["massbill"] ?? jrp["MASSBILL"]).Value())) + if ( + (jrp["massbill"] ?? jrp["MASSBILL"]) != null + && !string.IsNullOrWhiteSpace((jrp["massbill"] ?? jrp["MASSBILL"]).Value()) + ) { - mengeneinheit = (Mengeneinheit)Enum.Parse(typeof(Mengeneinheit), - (jrp["massbill"] ?? jrp["MASSBILL"]).Value()); + mengeneinheit = (Mengeneinheit) + Enum.Parse( + typeof(Mengeneinheit), + (jrp["massbill"] ?? jrp["MASSBILL"]).Value() + ); } - else if ((jrp["timbasis"] ?? jrp["TIMBASIS"]) != null && - !string.IsNullOrWhiteSpace((jrp["timbasis"] ?? jrp["TIMBASIS"]).Value())) + else if ( + (jrp["timbasis"] ?? jrp["TIMBASIS"]) != null + && !string.IsNullOrWhiteSpace((jrp["timbasis"] ?? jrp["TIMBASIS"]).Value()) + ) { if ((jrp["timbasis"] ?? jrp["TIMBASIS"]).Value() == "365") { mengeneinheit = Mengeneinheit.JAHR; - rp.ZeitbezogeneMenge = new Menge { Einheit = Mengeneinheit.TAG, Wert = zeitbezogeneMengeWert }; + rp.ZeitbezogeneMenge = new Menge + { + Einheit = Mengeneinheit.TAG, + Wert = zeitbezogeneMengeWert, + }; } } else @@ -149,7 +190,7 @@ public Rechnung(JObject sapPrintDocument) : this() { Wert = decimal.Parse((jrp["preisbtr"] ?? jrp["PREISBTR"]).ToString()), Einheit = waehrungseinheit, - Bezugswert = mengeneinheit + Bezugswert = mengeneinheit, }; } else @@ -158,24 +199,38 @@ public Rechnung(JObject sapPrintDocument) : this() { Wert = 0, Einheit = waehrungseinheit, - Bezugswert = mengeneinheit + Bezugswert = mengeneinheit, }; } } rp.Positionsnummer = (jrp["belzeile"] ?? jrp["BELZEILE"]).Value(); - if ((jrp["bis"] ?? jrp["BIS"]) != null && (jrp["bis"] ?? jrp["BIS"]).Value() != "0000-00-00") + if ( + (jrp["bis"] ?? jrp["BIS"]) != null + && (jrp["bis"] ?? jrp["BIS"]).Value() != "0000-00-00" + ) { - rp.LieferungBis = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (jrp["bis"] ?? jrp["BIS"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)); + rp.LieferungBis = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (jrp["bis"] ?? jrp["BIS"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ); } - if ((jrp["ab"] ?? jrp["AB"]) != null && (jrp["ab"] ?? jrp["AB"]).Value() != "0000-00-00") + if ( + (jrp["ab"] ?? jrp["AB"]) != null + && (jrp["ab"] ?? jrp["AB"]).Value() != "0000-00-00" + ) { - rp.LieferungVon = new DateTimeOffset(TimeZoneInfo.ConvertTime( - (jrp["ab"] ?? jrp["AB"]).Value(), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, TimeZoneInfo.Utc)); + rp.LieferungVon = new DateTimeOffset( + TimeZoneInfo.ConvertTime( + (jrp["ab"] ?? jrp["AB"]).Value(), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo, + TimeZoneInfo.Utc + ) + ); } if ((jrp["vertrag"] ?? jrp["VERTRAG"]) != null) @@ -190,7 +245,7 @@ public Rechnung(JObject sapPrintDocument) : this() rp.PositionsMenge = new Menge { Wert = (jrp["iAbrmenge"] ?? jrp["I_ABRMENGE"]).Value(), - Einheit = mengeneinheit + Einheit = mengeneinheit, }; } @@ -201,7 +256,7 @@ public Rechnung(JObject sapPrintDocument) : this() rp.TeilsummeNetto = new Betrag { Wert = (jrp["nettobtr"] ?? jrp["NETTOBTR"]).Value(), - Waehrung = waehrungscode + Waehrung = waehrungscode, }; } else @@ -209,22 +264,30 @@ public Rechnung(JObject sapPrintDocument) : this() rp.TeilsummeNetto = new Betrag { Wert = (jrp["sbasw"] ?? jrp["SBASW"]).Value(), - Waehrung = waehrungscode + Waehrung = waehrungscode, }; var steuerbetrag = new Steuerbetrag { Basiswert = (jrp["sbasw"] ?? jrp["SBASW"]).Value(), Steuerwert = (jrp["sbetw"] ?? jrp["SBETW"]).Value(), - Waehrung = (Waehrungscode)Enum.Parse(typeof(Waehrungscode), - (jrp["twaers"] ?? jrp["TWAERS"]).Value()) + Waehrung = (Waehrungscode) + Enum.Parse( + typeof(Waehrungscode), + (jrp["twaers"] ?? jrp["TWAERS"]).Value() + ), }; decimal steuerProzent; - if ((jrp["stprz"] ?? jrp["STPRZ"]) != null && - !string.IsNullOrWhiteSpace((jrp["stprz"] ?? jrp["STPRZ"]).Value())) + if ( + (jrp["stprz"] ?? jrp["STPRZ"]) != null + && !string.IsNullOrWhiteSpace( + (jrp["stprz"] ?? jrp["STPRZ"]).Value() + ) + ) { - steuerProzent = - decimal.Parse((jrp["stprz"] ?? jrp["STPRZ"]).Value().Replace(",", ".").Trim(), - CultureInfo.InvariantCulture); + steuerProzent = decimal.Parse( + (jrp["stprz"] ?? jrp["STPRZ"]).Value().Replace(",", ".").Trim(), + CultureInfo.InvariantCulture + ); } else { @@ -236,7 +299,8 @@ public Rechnung(JObject sapPrintDocument) : this() 19 => Steuerkennzeichen.UST_19, 7 => Steuerkennzeichen.UST_7, _ => throw new NotImplementedException( - $"Taxrate Internal '{jrp["taxrateInternal"]}' is not mapped.") + $"Taxrate Internal '{jrp["taxrateInternal"]}' is not mapped." + ), }; rp.TeilsummeSteuer = steuerbetrag; } @@ -244,7 +308,10 @@ public Rechnung(JObject sapPrintDocument) : this() if ((jrp["nettobtr"] ?? jrp["NETTOBTR"]).Value() <= 0) { Vorausgezahlt = new Betrag - { Waehrung = waehrungscode, Wert = (jrp["nettobtr"] ?? jrp["NETTOBTR"]).Value() }; + { + Waehrung = waehrungscode, + Wert = (jrp["nettobtr"] ?? jrp["NETTOBTR"]).Value(), + }; } } @@ -264,20 +331,30 @@ public Rechnung(JObject sapPrintDocument) : this() { Basiswert = (jrp["sbasw"] ?? jrp["SBASW"]).Value(), Steuerwert = (jrp["sbetw"] ?? jrp["SBETW"]).Value(), - Waehrung = (Waehrungscode)Enum.Parse(typeof(Waehrungscode), - (jrp["twaers"] ?? jrp["TWAERS"]).Value()) + Waehrung = (Waehrungscode) + Enum.Parse( + typeof(Waehrungscode), + (jrp["twaers"] ?? jrp["TWAERS"]).Value() + ), }; decimal steuerProzent; - if ((jrp["stprz"] ?? jrp["STPRZ"]) != null && - !string.IsNullOrWhiteSpace((jrp["stprz"] ?? jrp["STPRZ"]).Value())) + if ( + (jrp["stprz"] ?? jrp["STPRZ"]) != null + && !string.IsNullOrWhiteSpace( + (jrp["stprz"] ?? jrp["STPRZ"]).Value() + ) + ) { - steuerProzent = - decimal.Parse((jrp["stprz"] ?? jrp["STPRZ"]).Value().Replace(",", ".").Trim(), - CultureInfo.InvariantCulture); + steuerProzent = decimal.Parse( + (jrp["stprz"] ?? jrp["STPRZ"]).Value().Replace(",", ".").Trim(), + CultureInfo.InvariantCulture + ); } else { - steuerProzent = Math.Round(steuerbetrag.Steuerwert / steuerbetrag.Basiswert * 100.0M); + steuerProzent = Math.Round( + steuerbetrag.Steuerwert / steuerbetrag.Basiswert * 100.0M + ); } steuerbetrag.Steuerkennzeichen = steuerProzent switch @@ -285,7 +362,8 @@ public Rechnung(JObject sapPrintDocument) : this() 19.0M => Steuerkennzeichen.UST_19, 7.0M => Steuerkennzeichen.UST_7, _ => throw new NotImplementedException( - $"Taxrate Internal '{jrp["taxrateInternal"] ?? jrp["TAXRATE_INTERNAL"]}' is not mapped.") + $"Taxrate Internal '{jrp["taxrateInternal"] ?? jrp["TAXRATE_INTERNAL"]}' is not mapped." + ), }; stList.Add(steuerbetrag); gSteure += be.Value(); @@ -304,7 +382,10 @@ public Rechnung(JObject sapPrintDocument) : this() Rechnungsersteller = new Geschaeftspartner { - Geschaeftspartnerrolle = new List { Geschaeftspartnerrolle.LIEFERANT }, + Geschaeftspartnerrolle = new List + { + Geschaeftspartnerrolle.LIEFERANT, + }, Gewerbekennzeichnung = true, Anrede = Anrede.HERR, Name1 = "Mein super Lieferant", @@ -314,12 +395,15 @@ public Rechnung(JObject sapPrintDocument) : this() Hausnummer = "8", Postleitzahl = "90190", Landescode = Landescode.DE, - Ort = "Walldorf" - } + Ort = "Walldorf", + }, }; Rechnungsempfaenger = new Geschaeftspartner { - Geschaeftspartnerrolle = new List { Geschaeftspartnerrolle.KUNDE }, + Geschaeftspartnerrolle = new List + { + Geschaeftspartnerrolle.KUNDE, + }, Gewerbekennzeichnung = false, Anrede = Anrede.HERR, Name1 = "Lustig", @@ -330,8 +414,8 @@ public Rechnung(JObject sapPrintDocument) : this() Hausnummer = "20", Postleitzahl = "50672", Landescode = Landescode.DE, - Ort = "Köln" - } + Ort = "Köln", + }, }; } @@ -377,7 +461,6 @@ public Rechnung(JObject sapPrintDocument) : this() [FieldName("billNumber", Language.EN)] public string Rechnungsnummer { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(8, Name = nameof(Rechnungsdatum))] @@ -387,6 +470,7 @@ private DateTime _Rechnungsdatum get => Rechnungsdatum.UtcDateTime; set => Rechnungsdatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Ausstellungsdatum der Rechnung. /// @@ -397,7 +481,6 @@ private DateTime _Rechnungsdatum [FieldName("billDate", Language.EN)] public DateTimeOffset Rechnungsdatum { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(9, Name = nameof(Faelligkeitsdatum))] @@ -407,6 +490,7 @@ private DateTime _Faelligkeitsdatum get => Faelligkeitsdatum.UtcDateTime; set => Faelligkeitsdatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zu diesem Datum ist die Zahlung fällig. /// @@ -430,7 +514,11 @@ private DateTime _Faelligkeitsdatum /// /// Im Falle einer Stornorechnung (storno = true) steht hier die Rechnungsnummer der stornierten Rechnung. /// - [JsonProperty(Required = Required.Default, Order = 13, PropertyName = "originalRechnungsnummer")] + [JsonProperty( + Required = Required.Default, + Order = 13, + PropertyName = "originalRechnungsnummer" + )] [JsonPropertyName("originalRechnungsnummer")] [ProtoMember(11)] [JsonPropertyOrder(13)] @@ -595,6 +683,7 @@ private DateTime _Buchungsdatum get => Buchungsdatum?.UtcDateTime ?? DateTime.MinValue; set => Buchungsdatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zu diesem Datum ist die Zahlung fällig. /// @@ -604,4 +693,4 @@ private DateTime _Buchungsdatum [FieldName("bookingDate", Language.EN)] [JsonPropertyOrder(29)] public DateTimeOffset? Buchungsdatum { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Reklamation.cs b/BO4E/BO/Reklamation.cs index 20771795..e21c7cf8 100644 --- a/BO4E/BO/Reklamation.cs +++ b/BO4E/BO/Reklamation.cs @@ -1,15 +1,12 @@ +using System; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -39,7 +36,6 @@ public class Reklamation : BusinessObject [JsonPropertyOrder(11)] public Lokationstyp LokationsTyp { get; set; } - /// /// OBIS-Kennzahl /// @@ -58,7 +54,11 @@ public class Reklamation : BusinessObject /// Sollablesetermin / Zeitangabe für Messwertanfrage. Details /// /// DTM+163 and DTM+164 - [JsonProperty(PropertyName = "ZeitraumMesswertanfrage", Required = Required.Default, Order = 13)] + [JsonProperty( + PropertyName = "ZeitraumMesswertanfrage", + Required = Required.Default, + Order = 13 + )] [JsonPropertyName("ZeitraumMesswertanfrage")] [ProtoMember(1003)] [JsonPropertyOrder(13)] @@ -78,7 +78,11 @@ public class Reklamation : BusinessObject /// /// Freitext für eine weitere Beschreibung des Reklamationsgrunds /// - [JsonProperty(PropertyName = "reklamationsgrundBemerkung", Required = Required.Default, Order = 15)] + [JsonProperty( + PropertyName = "reklamationsgrundBemerkung", + Required = Required.Default, + Order = 15 + )] [JsonPropertyName("reklamationsgrundBemerkung")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(1005)] @@ -92,16 +96,23 @@ public class Reklamation : BusinessObject private DateTime _ZeitpunktFuerWertanfrage { get => ZeitpunktFuerWertanfrage?.UtcDateTime ?? default; - set => ZeitpunktFuerWertanfrage = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + ZeitpunktFuerWertanfrage = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zeitpunkt für Wertanfrage /// /// DTM+7 - [JsonProperty(PropertyName = "zeitpunktFuerWertanfrage", Required = Required.Default, Order = 16)] + [JsonProperty( + PropertyName = "zeitpunktFuerWertanfrage", + Required = Required.Default, + Order = 16 + )] [JsonPropertyName("zeitpunktFuerWertanfrage")] [JsonPropertyOrder(16)] [ProtoIgnore] [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? ZeitpunktFuerWertanfrage { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/Sperrauftrag.cs b/BO4E/BO/Sperrauftrag.cs index b7f7035a..10afd160 100644 --- a/BO4E/BO/Sperrauftrag.cs +++ b/BO4E/BO/Sperrauftrag.cs @@ -43,7 +43,6 @@ public class Sperrauftrag : Auftrag [JsonPropertyName("sperrauftragsverhinderungsgrund")] public Sperrauftragsverhinderungsgrund? Sperrauftragsverhinderungsgrund { get; set; } - /* /// /// True, falls der Netzbetreiber die Ansicht des MSB teilt, dass sich gesperrt werden darf. @@ -68,4 +67,4 @@ public class Sperrauftrag : Auftrag [JsonProperty("istVomGerichtsvollzieherAngeordnet", Required = Required.Always)] [JsonPropertyName("istVomGerichtsvollzieherAngeordnet")] public bool IstVomGerichtsvollzieherAngeordnet { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/BO/SperrauftragsStorno.cs b/BO4E/BO/SperrauftragsStorno.cs index 221587e4..2194eff9 100644 --- a/BO4E/BO/SperrauftragsStorno.cs +++ b/BO4E/BO/SperrauftragsStorno.cs @@ -10,7 +10,9 @@ namespace BO4E.BO; /// Das Storno eines s oder /// [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] -[Obsolete("This is not used in the implementation of the blocking process - we use the enum Auftragsstornogrund instead")] +[Obsolete( + "This is not used in the implementation of the blocking process - we use the enum Auftragsstornogrund instead" +)] public class SperrauftragsStorno : AuftragsStorno { /// diff --git a/BO4E/BO/Statusbericht.cs b/BO4E/BO/Statusbericht.cs index eaa6c282..f0d72c34 100644 --- a/BO4E/BO/Statusbericht.cs +++ b/BO4E/BO/Statusbericht.cs @@ -42,6 +42,7 @@ private DateTime _DatumPruefung get => DatumPruefung.UtcDateTime; set => DatumPruefung = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Pruefdatum (wann wurde der geprüft) /// diff --git a/BO4E/BO/SteuerbareRessource.cs b/BO4E/BO/SteuerbareRessource.cs index ac25c43f..467d722b 100644 --- a/BO4E/BO/SteuerbareRessource.cs +++ b/BO4E/BO/SteuerbareRessource.cs @@ -21,11 +21,7 @@ public class SteuerbareRessource : BusinessObject /// /// Edi-beispiel: LOC+Z19+C816417ST77' [DefaultValue("|null|")] - [JsonProperty( - Required = Required.Always, - Order = 10, - PropertyName = "steuerbareRessourceId" - )] + [JsonProperty(Required = Required.Always, Order = 10, PropertyName = "steuerbareRessourceId")] [JsonPropertyName("steuerbareRessourceId")] [JsonPropertyOrder(10)] [DataCategory(DataCategory.DEVICE)] @@ -52,11 +48,7 @@ public class SteuerbareRessource : BusinessObject /// Angabe des Messstellenbetreibers, der der Steuerbaren Ressource zugeordnet ist. /// /// Edi-beispiel: CAV+Z91:9900000000002' - [JsonProperty( - Required = Required.Default, - Order = 12, - PropertyName = "zugeordnetMSBCodeNr" - )] + [JsonProperty(Required = Required.Default, Order = 12, PropertyName = "zugeordnetMSBCodeNr")] [JsonPropertyOrder(12)] [JsonPropertyName("zugeordnetMSBCodeNr")] [ProtoMember(12)] @@ -65,11 +57,7 @@ public class SteuerbareRessource : BusinessObject /// /// Produkt-Daten der Steuerbaren Ressource /// - [JsonProperty( - Required = Required.Default, - Order = 13, - PropertyName = "konfigurationsprodukte" - )] + [JsonProperty(Required = Required.Default, Order = 13, PropertyName = "konfigurationsprodukte")] [JsonPropertyName("konfigurationsprodukte")] [ProtoMember(13)] [JsonPropertyOrder(13)] @@ -79,11 +67,7 @@ public class SteuerbareRessource : BusinessObject /// /// Eigenschaft des Messstellenbetreiber an der Lokation /// - [JsonProperty( - Required = Required.Default, - Order = 14, - PropertyName = "eigenschaftMSBLokation" - )] + [JsonProperty(Required = Required.Default, Order = 14, PropertyName = "eigenschaftMSBLokation")] [JsonPropertyName("eigenschaftMSBLokation")] [ProtoMember(14)] [JsonPropertyOrder(14)] diff --git a/BO4E/BO/Summenzeitreihe.cs b/BO4E/BO/Summenzeitreihe.cs index 50ebc15d..04473c12 100644 --- a/BO4E/BO/Summenzeitreihe.cs +++ b/BO4E/BO/Summenzeitreihe.cs @@ -1,16 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.EnergyIdentificationCodes; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -43,6 +40,7 @@ private DateTime _Bilanzierungsbeginn get => Bilanzierungsbeginn?.UtcDateTime ?? DateTime.MinValue; set => Bilanzierungsbeginn = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Inklusiver Start der Bilanzierung /// @@ -53,7 +51,6 @@ private DateTime _Bilanzierungsbeginn [ProtoIgnore] public DateTimeOffset? Bilanzierungsbeginn { get; set; } - /// /// Exklusives Ende der Bilanzierung /// @@ -66,6 +63,7 @@ private DateTime _Bilanzierungsende get => Bilanzierungsende?.UtcDateTime ?? DateTime.MinValue; set => Bilanzierungsende = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Exklusives Ende der Bilanzierung /// @@ -154,7 +152,6 @@ private DateTime _Bilanzierungsende [ProtoMember(1021)] public Netzebene? Spannungsebene { get; set; } - /// /// Produkte der Summenzeitreihe /// @@ -163,5 +160,4 @@ private DateTime _Bilanzierungsende [ProtoMember(1022)] [JsonPropertyOrder(22)] public List? Produkte { get; set; } - } diff --git a/BO4E/BO/TechnischeRessource.cs b/BO4E/BO/TechnischeRessource.cs index 8489d781..03a50900 100644 --- a/BO4E/BO/TechnischeRessource.cs +++ b/BO4E/BO/TechnischeRessource.cs @@ -20,11 +20,7 @@ public class TechnischeRessource : BusinessObject /// /// Edi-beispiel: LOC+Z19+C816417ST77' [DefaultValue("|null|")] - [JsonProperty( - PropertyName = "technischeRessourceId", - Required = Required.Default, - Order = 10 - )] + [JsonProperty(PropertyName = "technischeRessourceId", Required = Required.Default, Order = 10)] [JsonPropertyName("technischeRessourceId")] [JsonPropertyOrder(10)] [DataCategory(DataCategory.DEVICE)] @@ -84,11 +80,7 @@ public class TechnischeRessource : BusinessObject /// Nennleistung (Aufnahme) /// Beispiel: QTY+Z43:100:KWT' /// - [JsonProperty( - PropertyName = "nennleistungAufnahme", - Required = Required.Default, - Order = 14 - )] + [JsonProperty(PropertyName = "nennleistungAufnahme", Required = Required.Default, Order = 14)] [JsonPropertyName("nennleistungAufnahme")] [JsonPropertyOrder(14)] [NonOfficial(NonOfficialCategory.MISSING)] diff --git a/BO4E/BO/Vertrag.cs b/BO4E/BO/Vertrag.cs index f3536525..458f096e 100644 --- a/BO4E/BO/Vertrag.cs +++ b/BO4E/BO/Vertrag.cs @@ -1,13 +1,4 @@ #nullable enable -using BO4E.COM; -using BO4E.ENUM; -using BO4E.meta; -using BO4E.meta.LenientConverters; - -using Newtonsoft.Json; - -using ProtoBuf; - using System; using System.Collections.Generic; using System.IO; @@ -15,7 +6,12 @@ using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - +using BO4E.COM; +using BO4E.ENUM; +using BO4E.meta; +using BO4E.meta.LenientConverters; +using Newtonsoft.Json; +using ProtoBuf; using JsonSerializer = System.Text.Json.JsonSerializer; namespace BO4E.BO; @@ -32,13 +28,13 @@ public class Vertrag : BusinessObject /// static serializer options for Vertragsconverter /// public static JsonSerializerOptions? VertragsSerializerOptions; + /// /// Semaphore to protect access to the serializer /// public static readonly System.Threading.SemaphoreSlim SerializerSemaphore = new(1); - static Vertrag() - { - } + + static Vertrag() { } /// /// Eine im Verwendungskontext eindeutige Nummer für den Vertrag @@ -96,6 +92,7 @@ private DateTime _Vertragsbeginn get => Vertragsbeginn.UtcDateTime; set => Vertragsbeginn = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Gibt an, wann der Vertrag beginnt. /// @@ -106,7 +103,6 @@ private DateTime _Vertragsbeginn [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset Vertragsbeginn { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(10, Name = nameof(Vertragsende))] @@ -116,6 +112,7 @@ private DateTime _Vertragsende get => Vertragsende?.UtcDateTime ?? DateTime.MinValue; set => Vertragsende = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Gibt an, wann der Vertrag (voraussichtlich) endet oder beendet wurde. /// @@ -130,8 +127,7 @@ private DateTime _Vertragsende /// Der "erstgenannte" Vertragspartner. In der Regel der Aussteller des Vertrags. Beispiel: "Vertrag zwischen /// Vertagspartner 1 ..." Siehe BO Geschaeftspartner /// - [JsonProperty(Required = Required.Default, Order = 17, - PropertyName = "vertragspartner1")] // TODO: should be required but our CDS is missing the association + [JsonProperty(Required = Required.Default, Order = 17, PropertyName = "vertragspartner1")] // TODO: should be required but our CDS is missing the association [JsonPropertyName("vertragspartner1")] [JsonPropertyOrder(17)] [ProtoMember(11)] @@ -141,8 +137,7 @@ private DateTime _Vertragsende /// Der "zweitgenannte" Vertragspartner. In der Regel der Empfänger des Vertrags. Beispiel "Vertrag zwischen /// Vertagspartner 1 und Vertragspartner 2". Siehe BO Geschaeftspartner /// - [JsonProperty(Required = Required.Default, Order = 18, - PropertyName = "vertragspartner2")] // TODO: should be required but our CDS is missing the association + [JsonProperty(Required = Required.Default, Order = 18, PropertyName = "vertragspartner2")] // TODO: should be required but our CDS is missing the association [JsonPropertyName("vertragspartner2")] [JsonPropertyOrder(18)] [ProtoMember(12)] @@ -179,8 +174,7 @@ private DateTime _Vertragsende /// Der Vertragsteil wird dazu verwendet, eine vertragliche Leistung in Bezug zu einer Lokation (Markt- oder /// Messlokation) festzulegen. Details siehe COM Vertragsteil /// - [JsonProperty(Required = Required.Default, Order = 22, - PropertyName = "vertragsteile")] // TODO: should be required always but our CDS is missing the association + [JsonProperty(Required = Required.Default, Order = 22, PropertyName = "vertragsteile")] // TODO: should be required always but our CDS is missing the association [JsonPropertyName("vertragsteile")] [ProtoMember(16)] [JsonPropertyOrder(22)] @@ -215,8 +209,11 @@ private DateTime _Vertragsende [OnDeserialized] protected void OnDeserialized(StreamingContext context) { - if ((Vertragsteile == null || Vertragsteile.Count == 0) && UserProperties != null && - UserProperties.ContainsKey("lokationsId")) + if ( + (Vertragsteile == null || Vertragsteile.Count == 0) + && UserProperties != null + && UserProperties.ContainsKey("lokationsId") + ) { Vertragsteile = new List { @@ -224,8 +221,8 @@ protected void OnDeserialized(StreamingContext context) { Vertragsteilbeginn = Vertragsbeginn, Vertragsteilende = Vertragsende, - Lokation = UserProperties["lokationsId"] as string - } + Lokation = UserProperties["lokationsId"] as string, + }, }; } } @@ -242,7 +239,11 @@ public class VertragsConverter : System.Text.Json.Serialization.JsonConverter /// /// - public override Vertrag Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Vertrag Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { Vertrag.SerializerSemaphore.Wait(); try @@ -259,8 +260,11 @@ public override Vertrag Read(ref Utf8JsonReader reader, Type typeToConvert, Json { throw new InvalidDataException("Could not deserialize Vertrag"); } - if ((v.Vertragsteile == null || v.Vertragsteile.Count == 0) && v.UserProperties != null && - v.UserProperties.TryGetValue("lokationsId", out var property)) + if ( + (v.Vertragsteile == null || v.Vertragsteile.Count == 0) + && v.UserProperties != null + && v.UserProperties.TryGetValue("lokationsId", out var property) + ) { v.Vertragsteile = new List { @@ -268,8 +272,8 @@ public override Vertrag Read(ref Utf8JsonReader reader, Type typeToConvert, Json { Vertragsteilbeginn = v.Vertragsbeginn, Vertragsteilende = v.Vertragsende, - Lokation = ((JsonElement) property).GetString() - } + Lokation = ((JsonElement)property).GetString(), + }, }; } @@ -281,10 +285,17 @@ private static void RemoveDuplicateVertragsConverter(JsonSerializerOptions optio if (Vertrag.VertragsSerializerOptions == null) { Vertrag.VertragsSerializerOptions = new JsonSerializerOptions(options); - while (Vertrag.VertragsSerializerOptions.Converters.Any(s => s.GetType() == typeof(VertragsConverter))) + while ( + Vertrag.VertragsSerializerOptions.Converters.Any(s => + s.GetType() == typeof(VertragsConverter) + ) + ) { Vertrag.VertragsSerializerOptions.Converters.Remove( - Vertrag.VertragsSerializerOptions.Converters.First(s => s.GetType() == typeof(VertragsConverter))); + Vertrag.VertragsSerializerOptions.Converters.First(s => + s.GetType() == typeof(VertragsConverter) + ) + ); } } } diff --git a/BO4E/BO/Wechsel.cs b/BO4E/BO/Wechsel.cs index 3a29bcbb..e62c6fff 100644 --- a/BO4E/BO/Wechsel.cs +++ b/BO4E/BO/Wechsel.cs @@ -1,15 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -32,7 +29,6 @@ public class Wechsel : BusinessObject [JsonPropertyOrder(12)] public List? Geraete { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(13, Name = nameof(Wechseldatum))] @@ -42,6 +38,7 @@ private DateTime _Wechseldatum get => Wechseldatum?.UtcDateTime ?? DateTime.MinValue; set => Wechseldatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Gibt an, wann der Wechsel (voraussichtlich) stattfinden wird. /// diff --git a/BO4E/BO/Zaehler.cs b/BO4E/BO/Zaehler.cs index 08afa0c6..7ba2b84b 100644 --- a/BO4E/BO/Zaehler.cs +++ b/BO4E/BO/Zaehler.cs @@ -1,16 +1,13 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using BO4E.COM; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; - namespace BO4E.BO; /// @@ -50,12 +47,13 @@ public class Zaehler : BusinessObject /// [JsonProperty( Required = Required.Default, //Required = Required.Always, - Order = 13, PropertyName = "zaehlertyp")] + Order = 13, + PropertyName = "zaehlertyp" + )] [ProtoMember(7)] [JsonPropertyOrder(13)] [JsonPropertyName("zaehlertyp")] - [NonOfficial(NonOfficialCategory - .REGULATORY_REQUIREMENTS)] // this is ALWAYS required in BO4E standard; Maybe nullable if you as a LIEFERANT don't care about the type of Zähler, othern than in the grid + [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] // this is ALWAYS required in BO4E standard; Maybe nullable if you as a LIEFERANT don't care about the type of Zähler, othern than in the grid public Zaehlertyp? Zaehlertyp { get; set; } /// @@ -84,6 +82,7 @@ private DateTime _EichungBis get => EichungBis?.UtcDateTime ?? default; set => EichungBis = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Bis zu diesem Datum ist der Zähler geeicht. [JsonProperty(Required = Required.Default, Order = 16, PropertyName = "eichungBis")] [JsonPropertyName("eichungBis")] @@ -91,8 +90,6 @@ private DateTime _EichungBis [ProtoIgnore] public DateTimeOffset? EichungBis { get; set; } // ToDO implement date - - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(11, Name = nameof(LetzteEichung))] @@ -100,8 +97,10 @@ private DateTime _EichungBis private DateTime _LetzteEichung { get => LetzteEichung?.UtcDateTime ?? default; - set => LetzteEichung = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + LetzteEichung = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Zu diesem Datum fand die letzte Eichprüfung des Zählers statt. [JsonProperty(Required = Required.Default, Order = 17, PropertyName = "letzteEichung")] [JsonPropertyName("letzteEichung")] @@ -121,8 +120,12 @@ private DateTime _LetzteEichung public List? Zaehlwerke { get; set; } /// Der Hersteller des Zählers. Details - [JsonProperty(Required = Required.Default, Order = 19, NullValueHandling = NullValueHandling.Ignore, - PropertyName = "zaehlerhersteller")] + [JsonProperty( + Required = Required.Default, + Order = 19, + NullValueHandling = NullValueHandling.Ignore, + PropertyName = "zaehlerhersteller" + )] [JsonPropertyName("zaehlerhersteller")] [ProtoMember(13)] [JsonPropertyOrder(19)] @@ -164,14 +167,15 @@ private DateTime _LetzteEichung /// [JsonProperty( Required = Required.Default, - PropertyName = "zaehlertypspezifikation", Order = 23)] + PropertyName = "zaehlertypspezifikation", + Order = 23 + )] [ProtoMember(1017)] [JsonPropertyOrder(23)] [JsonPropertyName("zaehlertypspezifikation")] [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] public ZaehlertypSpezifikation? Zaehlertypspezifikation { get; set; } - /// /// Befestigungsart /// @@ -191,6 +195,7 @@ private DateTime _LetzteEichung [JsonPropertyOrder(25)] [NonOfficial(NonOfficialCategory.REGULATORY_REQUIREMENTS)] public Geraetemerkmal? Zaehlergroesse { get; set; } + /// Liste der Geräte, die zu diesem Zähler gehören. [JsonProperty(PropertyName = "geraete", Required = Required.Default, Order = 26)] [JsonPropertyOrder(26)] diff --git a/BO4E/BO/Zaehlzeitdefinition.cs b/BO4E/BO/Zaehlzeitdefinition.cs index 8bf0ae22..4d7283ea 100644 --- a/BO4E/BO/Zaehlzeitdefinition.cs +++ b/BO4E/BO/Zaehlzeitdefinition.cs @@ -111,11 +111,7 @@ private DateTime _Version /// /// Liste der ausgerollten Zählzeiten /// - [JsonProperty( - Required = Required.Always, - Order = 12, - PropertyName = "ausgerollteZaehlzeiten" - )] + [JsonProperty(Required = Required.Always, Order = 12, PropertyName = "ausgerollteZaehlzeiten")] [JsonPropertyName("ausgerollteZaehlzeiten")] [ProtoMember(12)] [JsonPropertyOrder(12)] diff --git a/BO4E/BoMapper.cs b/BO4E/BoMapper.cs index 12b21932..cfdf6457 100644 --- a/BO4E/BoMapper.cs +++ b/BO4E/BoMapper.cs @@ -12,7 +12,8 @@ namespace BO4E; /// This class maps generic JObjects to BO4E business objects. /// [Obsolete( - "The BoMapper is obsolete and should be replace with JsonConvert.DeserializeObject(...) in the long run. It's not a good coding style but still thoroughly tested.")] + "The BoMapper is obsolete and should be replace with JsonConvert.DeserializeObject(...) in the long run. It's not a good coding style but still thoroughly tested." +)] public abstract class BoMapper { /// @@ -20,8 +21,10 @@ public abstract class BoMapper /// public const string PackagePrefix = "BO4E.BO"; - private static readonly Regex BoRegex = new Regex(@"BO4E\.(?:Extensions\.)?BO\.\b(?\w+)\b", - RegexOptions.Compiled); + private static readonly Regex BoRegex = new Regex( + @"BO4E\.(?:Extensions\.)?BO\.\b(?\w+)\b", + RegexOptions.Compiled + ); /// /// Get a list of those strings that are known BO4E types (e.g. "Messlokation", "Energiemenge"...) @@ -64,12 +67,21 @@ public static Type GetTypeForBoName(string businessObjectName) } //Type[] types = Assembly.GetExecutingAssembly().GetTypes(); - var clazz = Assembly.GetExecutingAssembly().GetType(PackagePrefix + "." + businessObjectName); + var clazz = Assembly + .GetExecutingAssembly() + .GetType(PackagePrefix + "." + businessObjectName); return clazz != null ? clazz - : (from boName in GetValidBoNames() - where string.Equals(boName, businessObjectName, StringComparison.CurrentCultureIgnoreCase) - select Assembly.GetExecutingAssembly().GetType(PackagePrefix + "." + boName)).FirstOrDefault(); + : ( + from boName in GetValidBoNames() + where + string.Equals( + boName, + businessObjectName, + StringComparison.CurrentCultureIgnoreCase + ) + select Assembly.GetExecutingAssembly().GetType(PackagePrefix + "." + boName) + ).FirstOrDefault(); //throw new ArgumentException($"No implemented BusinessObject type matches the name '{businessObjectName}'."); } diff --git a/BO4E/COM/Abweichung.cs b/BO4E/COM/Abweichung.cs index feb77496..bafc57b9 100644 --- a/BO4E/COM/Abweichung.cs +++ b/BO4E/COM/Abweichung.cs @@ -1,13 +1,10 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Collections.Generic; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -29,7 +26,11 @@ public class Abweichung : COM /// /// Nähere Erläuterung zum Abweichungsgrund /// - [JsonProperty(PropertyName = "abweichungsgrundBemerkung", Required = Required.Default, Order = 4)] + [JsonProperty( + PropertyName = "abweichungsgrundBemerkung", + Required = Required.Default, + Order = 4 + )] [JsonPropertyName("abweichungsgrundBemerkung")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(4)] @@ -61,10 +62,15 @@ public class Abweichung : COM [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(8)] public string? AbweichungsgrundCode { get; set; } + /// /// Angabe des Abweichungsgrunds (Code) /// - [JsonProperty(PropertyName = "abweichungsgrundCodeliste", Required = Required.Always, Order = 9)] + [JsonProperty( + PropertyName = "abweichungsgrundCodeliste", + Required = Required.Always, + Order = 9 + )] [JsonPropertyName("abweichungsgrundCodeliste")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(9)] diff --git a/BO4E/COM/AbweichungsPosition.cs b/BO4E/COM/AbweichungsPosition.cs index f572672e..585c804f 100644 --- a/BO4E/COM/AbweichungsPosition.cs +++ b/BO4E/COM/AbweichungsPosition.cs @@ -1,9 +1,7 @@ +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -14,7 +12,6 @@ namespace BO4E.COM; [NonOfficial(NonOfficialCategory.MISSING)] public class Abweichungsposition : COM { - /// /// Angabe des Abweichungsgrunds (Code) /// @@ -24,10 +21,15 @@ public class Abweichungsposition : COM [ProtoMember(7)] [JsonPropertyOrder(7)] public string? AbweichungsgrundCode { get; set; } + /// /// Angabe des Abweichungsgrunds (Codeliste) /// - [JsonProperty(PropertyName = "abweichungsgrundCodeliste", Required = Required.Default, Order = 3)] + [JsonProperty( + PropertyName = "abweichungsgrundCodeliste", + Required = Required.Default, + Order = 3 + )] [JsonPropertyName("abweichungsgrundCodeliste")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(3)] @@ -37,7 +39,11 @@ public class Abweichungsposition : COM /// /// Nähere Erläuterung zum Abweichungsgrund /// - [JsonProperty(PropertyName = "abweichungsgrundBemerkung", Required = Required.Default, Order = 4)] + [JsonProperty( + PropertyName = "abweichungsgrundBemerkung", + Required = Required.Default, + Order = 4 + )] [JsonPropertyName("abweichungsgrundBemerkung")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(4)] @@ -63,5 +69,4 @@ public class Abweichungsposition : COM [ProtoMember(6)] [JsonPropertyOrder(6)] public string? ZugehoerigeBestellung { get; set; } - -} \ No newline at end of file +} diff --git a/BO4E/COM/Adresse.cs b/BO4E/COM/Adresse.cs index 04c8f733..e4aa2b1e 100644 --- a/BO4E/COM/Adresse.cs +++ b/BO4E/COM/Adresse.cs @@ -89,8 +89,12 @@ public class Adresse : COM /// /// Ortsteil für EDIFACT mapping /// - [JsonProperty(PropertyName = "ortsteil", Required = Required.Default, - NullValueHandling = NullValueHandling.Ignore, Order = 19)] + [JsonProperty( + PropertyName = "ortsteil", + Required = Required.Default, + NullValueHandling = NullValueHandling.Ignore, + Order = 19 + )] [JsonPropertyName("ortsteil")] [ProtoMember(1011)] [NonOfficial(NonOfficialCategory.MISSING)] diff --git a/BO4E/COM/Angebotsposition.cs b/BO4E/COM/Angebotsposition.cs index 953958f7..1297752a 100644 --- a/BO4E/COM/Angebotsposition.cs +++ b/BO4E/COM/Angebotsposition.cs @@ -1,12 +1,9 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -68,7 +65,7 @@ public class Angebotsposition : COM public BDEWArtikelnummer? BdewArtikelnummer { get; set; } /// - /// Die genauen Bedeutungen der einzelnen Artikel-IDs sind in der EDI@Energy Codeliste der Artikelnummern + /// Die genauen Bedeutungen der einzelnen Artikel-IDs sind in der EDI@Energy Codeliste der Artikelnummern /// und Artikel-IDs zu finden, die in der Spalte des entsprechenden Prüfidentifikator ein X haben /// [JsonProperty(PropertyName = "artikelId", Order = 16, Required = Required.Default)] diff --git a/BO4E/COM/Angebotsteil.cs b/BO4E/COM/Angebotsteil.cs index 2071515e..465f29e4 100644 --- a/BO4E/COM/Angebotsteil.cs +++ b/BO4E/COM/Angebotsteil.cs @@ -24,7 +24,11 @@ public class Angebotsteil : COM /// Marktlokationen, für die dieses Angebotsteil gilt, falls vorhanden. Durch die Marktlokation ist auch die /// Lieferadresse festgelegt. Details /// - [JsonProperty(PropertyName = "lieferstellenangebotsteil", Order = 11, Required = Required.Default)] + [JsonProperty( + PropertyName = "lieferstellenangebotsteil", + Order = 11, + Required = Required.Default + )] [JsonPropertyName("lieferstellenangebotsteil")] [JsonPropertyOrder(11)] [ProtoMember(4)] @@ -33,7 +37,11 @@ public class Angebotsteil : COM /// /// Summe der Verbräuche aller in diesem Angebotsteil eingeschlossenen Lieferstellen. Details /// - [JsonProperty(PropertyName = "gesamtmengeangebotsteil", Order = 12, Required = Required.Default)] + [JsonProperty( + PropertyName = "gesamtmengeangebotsteil", + Order = 12, + Required = Required.Default + )] [JsonPropertyName("gesamtmengeangebotsteil")] [JsonPropertyOrder(12)] [ProtoMember(5)] @@ -43,7 +51,11 @@ public class Angebotsteil : COM /// Summe der Jahresenergiekosten aller in diesem Angebotsteil enthaltenen Lieferstellen. Details /// /// - [JsonProperty(PropertyName = "gesamtkostenangebotsteil", Order = 13, Required = Required.Default)] + [JsonProperty( + PropertyName = "gesamtkostenangebotsteil", + Order = 13, + Required = Required.Default + )] [JsonPropertyName("gesamtkostenangebotsteil")] [JsonPropertyOrder(13)] [ProtoMember(6)] @@ -62,4 +74,4 @@ public class Angebotsteil : COM [JsonPropertyOrder(15)] [ProtoMember(8)] public Zeitraum? Lieferzeitraum { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Angebotsvariante.cs b/BO4E/COM/Angebotsvariante.cs index 91175ea3..fc92a31c 100644 --- a/BO4E/COM/Angebotsvariante.cs +++ b/BO4E/COM/Angebotsvariante.cs @@ -25,7 +25,6 @@ public class Angebotsvariante : COM [ProtoMember(5)] public string? Beschreibung { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(6, Name = nameof(Erstelldatum))] @@ -33,8 +32,10 @@ public class Angebotsvariante : COM private DateTime _Erstelldatum { get => Erstelldatum?.UtcDateTime ?? default; - set => Erstelldatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + Erstelldatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Datum der Erstellung der Angebotsvariante [JsonProperty(PropertyName = "erstelldatum", Order = 12, Required = Required.Default)] [JsonPropertyName("erstelldatum")] @@ -51,6 +52,7 @@ private DateTime _Bindefrist get => Bindefrist?.UtcDateTime ?? default; set => Bindefrist = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Bis zu diesem Zeitpunkt (Tag/Uhrzeit) inklusive gilt die Angebotsvariante, z.B. 31.12.2017, 17:00 Uhr. [JsonProperty(PropertyName = "bindefrist", Order = 13, Required = Required.Default)] [JsonPropertyName("bindefrist")] diff --git a/BO4E/COM/Aufgabe.cs b/BO4E/COM/Aufgabe.cs index d8395efe..c9afa77a 100644 --- a/BO4E/COM/Aufgabe.cs +++ b/BO4E/COM/Aufgabe.cs @@ -31,7 +31,6 @@ public class Aufgabe : COM [ProtoMember(4)] public string? Beschreibung { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(5, Name = nameof(Deadline))] @@ -41,6 +40,7 @@ private DateTime _Deadline get => Deadline?.UtcDateTime ?? default; set => Deadline = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Optionale Deadline bis zu der die Aufgabe ausführt werden kann oder ihre Ausführung /// sinnvoll ist. @@ -58,7 +58,6 @@ private DateTime _Deadline [ProtoMember(6)] public bool Ausgefuehrt { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(7, Name = nameof(Ausfuehrungszeitpunkt))] @@ -66,13 +65,18 @@ private DateTime _Deadline private DateTime _Ausfuehrungszeitpunkt { get => Ausfuehrungszeitpunkt?.UtcDateTime ?? default; - set => Ausfuehrungszeitpunkt = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + Ausfuehrungszeitpunkt = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zeitpunkt zu dem die Aufgabe ausgeführt wurde. (Nur sinnvoll, wenn ausgefuehrt==true) /// [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] - [System.Text.Json.Serialization.JsonConverter(typeof(LenientSystemTextJsonNullableDateTimeOffsetConverter))] + [System.Text.Json.Serialization.JsonConverter( + typeof(LenientSystemTextJsonNullableDateTimeOffsetConverter) + )] [JsonProperty(PropertyName = "ausfuehrungszeitpunkt", Required = Required.Default)] [JsonPropertyName("ausfuehrungszeitpunkt")] [ProtoIgnore] @@ -86,4 +90,4 @@ private DateTime _Ausfuehrungszeitpunkt [JsonPropertyName("ausfuehrender")] [ProtoMember(8)] public string? Ausfuehrender { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/AusgerollteZaehlzeit.cs b/BO4E/COM/AusgerollteZaehlzeit.cs index 862bcb1e..901996ab 100644 --- a/BO4E/COM/AusgerollteZaehlzeit.cs +++ b/BO4E/COM/AusgerollteZaehlzeit.cs @@ -1,12 +1,9 @@ +using System; +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -25,6 +22,7 @@ private DateTime _Aenderungszeitpunkt get => Aenderungszeitpunkt.UtcDateTime; set => Aenderungszeitpunkt = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Angabe eines Zeitpunktes, zu dem der Wechsel auf ein neues aktives Zählzeitregister erfolgt. /// diff --git a/BO4E/COM/Ausschreibungslos.cs b/BO4E/COM/Ausschreibungslos.cs index 56eba761..de1b751a 100644 --- a/BO4E/COM/Ausschreibungslos.cs +++ b/BO4E/COM/Ausschreibungslos.cs @@ -128,4 +128,4 @@ public class Ausschreibungslos : COM [JsonPropertyName("wunschZahlungsziel")] [ProtoMember(19)] public Zeitraum? WunschZahlungsziel { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Avisposition.cs b/BO4E/COM/Avisposition.cs index 821ff5f2..bf593703 100644 --- a/BO4E/COM/Avisposition.cs +++ b/BO4E/COM/Avisposition.cs @@ -35,6 +35,7 @@ protected DateTime _RechnungsDatum get => RechnungsDatum.UtcDateTime; set => RechnungsDatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Das Rechnungsdatum der Rechnung, auf die sich das Avis bezieht. /// @@ -107,4 +108,4 @@ protected DateTime _RechnungsDatum [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(8)] public List? Positionen { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/COM.cs b/BO4E/COM/COM.cs index 2cfd5001..5bb044e8 100644 --- a/BO4E/COM/COM.cs +++ b/BO4E/COM/COM.cs @@ -1,15 +1,12 @@ -using BO4E.BO; -using BO4E.meta; - -using Newtonsoft.Json; - -using ProtoBuf; - using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text.Json.Serialization; +using BO4E.BO; +using BO4E.meta; +using Newtonsoft.Json; +using ProtoBuf; namespace BO4E.COM; @@ -79,7 +76,6 @@ public abstract class COM : IUserProperties, IOptionalGuid // note that this inheritance protobuf thing doesn't work as expected. please see the comments in TestBO4E project->TestProfobufSerialization [ProtoMember(1)] - #pragma warning disable IDE1006 // Naming Styles // ReSharper disable once InconsistentNaming protected string guidSerialized @@ -105,8 +101,12 @@ protected DateTime _TimeStamp /// /// Store the latest timestamp (update from the database) /// - [JsonProperty(PropertyName = "timestamp", NullValueHandling = NullValueHandling.Ignore, - Required = Required.Default, Order = 0)] + [JsonProperty( + PropertyName = "timestamp", + NullValueHandling = NullValueHandling.Ignore, + Required = Required.Default, + Order = 0 + )] [JsonPropertyName("timestamp")] [ProtoIgnore] [JsonPropertyOrder(0)] @@ -130,8 +130,12 @@ public bool Equals(COM b) /// /// allows adding a GUID to COM objects for tracking across systems /// - [JsonProperty(PropertyName = "guid", NullValueHandling = NullValueHandling.Ignore, Required = Required.Default, - Order = 1)] + [JsonProperty( + PropertyName = "guid", + NullValueHandling = NullValueHandling.Ignore, + Required = Required.Default, + Order = 1 + )] [JsonPropertyName("guid")] [JsonPropertyOrder(1)] public Guid? Guid { get; set; } @@ -139,8 +143,12 @@ public bool Equals(COM b) /// /// User properties (non bo4e standard) /// - [JsonProperty(PropertyName = BusinessObject.USER_PROPERTIES_NAME, Required = Required.Default, Order = 2, - DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonProperty( + PropertyName = BusinessObject.USER_PROPERTIES_NAME, + Required = Required.Default, + Order = 2, + DefaultValueHandling = DefaultValueHandling.Ignore + )] [ProtoMember(2)] [Newtonsoft.Json.JsonExtensionData] [System.Text.Json.Serialization.JsonExtensionData] @@ -171,14 +179,14 @@ public List GetAmbiguousUserPropertiesKeys() { return new List(); } - var regularPropertyNames = GetType().GetProperties() + var regularPropertyNames = GetType() + .GetProperties() .Where(p => p.GetCustomAttribute() != null) .Select(p => p.GetCustomAttribute().Name) .Select(x => x.ToLower()) .ToHashSet(); var result = UserProperties - .Keys - .Where(k => regularPropertyNames.Contains(k.ToLower())) + .Keys.Where(k => regularPropertyNames.Contains(k.ToLower())) .ToList(); return result; } diff --git a/BO4E/COM/Erreichbarkeit.cs b/BO4E/COM/Erreichbarkeit.cs index 83274fbd..aa360ffa 100644 --- a/BO4E/COM/Erreichbarkeit.cs +++ b/BO4E/COM/Erreichbarkeit.cs @@ -1,7 +1,5 @@ using System.Text.Json.Serialization; - using Newtonsoft.Json; - using ProtoBuf; namespace BO4E.COM; @@ -34,7 +32,11 @@ public class Erreichbarkeit : COM public Zeitfenster? MittwochErreichbarkeit { get; set; } /// Erreichbarkeit am Donnerstag - [JsonProperty(PropertyName = "donnerstagErreichbarkeit", Required = Required.Default, Order = 6)] + [JsonProperty( + PropertyName = "donnerstagErreichbarkeit", + Required = Required.Default, + Order = 6 + )] [JsonPropertyName("donnerstagErreichbarkeit")] [ProtoMember(6)] [JsonPropertyOrder(6)] @@ -53,4 +55,4 @@ public class Erreichbarkeit : COM [ProtoMember(8)] [JsonPropertyOrder(8)] public Zeitfenster? Mittagspause { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/ExterneReferenz.cs b/BO4E/COM/ExterneReferenz.cs index 27ca31f0..d8b864cc 100644 --- a/BO4E/COM/ExterneReferenz.cs +++ b/BO4E/COM/ExterneReferenz.cs @@ -1,14 +1,11 @@ #nullable enable -using BO4E.BO; - -using Newtonsoft.Json; - -using ProtoBuf; - using System; using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; +using BO4E.BO; +using Newtonsoft.Json; +using ProtoBuf; namespace BO4E.COM; @@ -37,6 +34,7 @@ public class ExterneReferenz : COM [JsonPropertyName("exRefWert")] [ProtoMember(2)] public string? ExRefWert { get; set; } + /// /// Ist das Objekt valide /// @@ -59,8 +57,11 @@ internal static class ExterneReferenzExtensions /// non-null if the externe referenz was found /// list of external references /// true if externe referenz with name was found - public static bool TryGetExterneReferenz(this ICollection? extReferences, string? extRefName, - out string? extRefWert) + public static bool TryGetExterneReferenz( + this ICollection? extReferences, + string? extRefName, + out string? extRefWert + ) { if (extRefName == null) { @@ -94,8 +95,11 @@ public static bool TryGetExterneReferenz(this ICollection? extR /// if there is a conflicting value and /// is false /// - public static List SetExterneReferenz(this List? extReferences, - ExterneReferenz extRef, bool overwriteExisting = false) + public static List SetExterneReferenz( + this List? extReferences, + ExterneReferenz extRef, + bool overwriteExisting = false + ) { if (extRef == null) { @@ -106,13 +110,17 @@ public static List SetExterneReferenz(this List { extRef }; } - if (extReferences.Any() && extReferences.TryGetExterneReferenz(extRef.ExRefName, out var existingRefWert)) + if ( + extReferences.Any() + && extReferences.TryGetExterneReferenz(extRef.ExRefName, out var existingRefWert) + ) { if (overwriteExisting) { @@ -123,7 +131,8 @@ public static List SetExterneReferenz(this List? FehlerDetails { get; set; } = new System.Collections.Generic.List(); + public System.Collections.Generic.List? FehlerDetails { get; set; } = + new System.Collections.Generic.List(); } diff --git a/BO4E/COM/FehlerDetail.cs b/BO4E/COM/FehlerDetail.cs index 1a19ec12..913a7e94 100644 --- a/BO4E/COM/FehlerDetail.cs +++ b/BO4E/COM/FehlerDetail.cs @@ -32,4 +32,4 @@ public class FehlerDetail : COM [JsonPropertyOrder(12)] [ProtoMember(3)] public FehlerUrsache? Ursache { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/FehlerUrsache.cs b/BO4E/COM/FehlerUrsache.cs index 102dcaed..0f7ecb67 100644 --- a/BO4E/COM/FehlerUrsache.cs +++ b/BO4E/COM/FehlerUrsache.cs @@ -45,6 +45,4 @@ public class FehlerUrsache : COM [JsonPropertyName("beschreibung")] [ProtoMember(5)] public string? Beschreibung { get; set; } - - -} \ No newline at end of file +} diff --git a/BO4E/COM/Geraet.cs b/BO4E/COM/Geraet.cs index 0e4d6f6f..a0f329e8 100644 --- a/BO4E/COM/Geraet.cs +++ b/BO4E/COM/Geraet.cs @@ -1,11 +1,8 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// Mit dieser Komponente werden alle Geräte modelliert, die keine Zähler sind. diff --git a/BO4E/COM/Handelsunstimmigkeitsbegruendung.cs b/BO4E/COM/Handelsunstimmigkeitsbegruendung.cs index b88d3fee..e7896037 100644 --- a/BO4E/COM/Handelsunstimmigkeitsbegruendung.cs +++ b/BO4E/COM/Handelsunstimmigkeitsbegruendung.cs @@ -1,5 +1,5 @@ -using System.Text.Json.Serialization; using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; using Newtonsoft.Json; @@ -21,10 +21,8 @@ public class Handelsunstimmigkeitsbegruendung : COM [JsonPropertyName("referenzen")] [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(1)] - public List? Referenzen { get; set; } - /// /// Angabe des Handelsunstimmigkeitsgrunds /// @@ -33,5 +31,4 @@ public class Handelsunstimmigkeitsbegruendung : COM [NonOfficial(NonOfficialCategory.MISSING)] [ProtoMember(2)] public Handelsunstimmigkeitsgrund Grund { get; set; } - } diff --git a/BO4E/COM/Katasteradresse.cs b/BO4E/COM/Katasteradresse.cs index aff846e5..c6e824fa 100644 --- a/BO4E/COM/Katasteradresse.cs +++ b/BO4E/COM/Katasteradresse.cs @@ -22,4 +22,4 @@ public class Katasteradresse : COM [JsonPropertyName("flurstueck")] [ProtoMember(4)] public string Flurstueck { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Konfigurationsprodukt.cs b/BO4E/COM/Konfigurationsprodukt.cs index cf71effb..9196401d 100644 --- a/BO4E/COM/Konfigurationsprodukt.cs +++ b/BO4E/COM/Konfigurationsprodukt.cs @@ -1,12 +1,9 @@ +using System.Text.Json.Serialization; using BO4E.BO; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// Produkt-daten ein BO wie Netzlokation, Marktlokation usw. @@ -26,7 +23,11 @@ public class Konfigurationsprodukt : COM /// /// Code der Zugeordnete Leistungskurvendefinition für das Objekt /// - [JsonProperty(Required = Required.Default, Order = 2, PropertyName = "leistungskurvendefinition")] + [JsonProperty( + Required = Required.Default, + Order = 2, + PropertyName = "leistungskurvendefinition" + )] [JsonPropertyOrder(2)] [JsonPropertyName("leistungskurvendefinition")] [ProtoMember(2)] @@ -52,4 +53,4 @@ public class Konfigurationsprodukt : COM [ProtoMember(4)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] public Marktteilnehmer? Marktpartner { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Kostenblock.cs b/BO4E/COM/Kostenblock.cs index 25a6ceac..c75a2635 100644 --- a/BO4E/COM/Kostenblock.cs +++ b/BO4E/COM/Kostenblock.cs @@ -29,4 +29,4 @@ public class Kostenblock : COM [JsonPropertyName("kostenpositionen")] [ProtoMember(5)] public List? Kostenpositionen { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Kostenposition.cs b/BO4E/COM/Kostenposition.cs index 73192413..6003954a 100644 --- a/BO4E/COM/Kostenposition.cs +++ b/BO4E/COM/Kostenposition.cs @@ -27,13 +27,13 @@ private DateTime _Von get => Von?.UtcDateTime ?? default; set => Von = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// von-Datum der Kostenzeitscheibe. Z.B. 2017-01-01 [JsonProperty(PropertyName = "von", Required = Required.Default)] [JsonPropertyName("von")] [ProtoIgnore] public DateTimeOffset? Von { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(5, Name = nameof(Bis))] @@ -43,6 +43,7 @@ private DateTime _Bis get => Bis?.UtcDateTime ?? default; set => Bis = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// bis-Datum der Kostenzeitscheibe. Z.B. 2017-12-31 [JsonProperty(PropertyName = "bis", Required = Required.Default)] [JsonPropertyName("bis")] @@ -93,4 +94,4 @@ private DateTime _Bis [JsonPropertyName("betragKostenposition")] [ProtoMember(11)] public Betrag BetragKostenposition { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Lastprofil.cs b/BO4E/COM/Lastprofil.cs index d0b3f8ae..bd16ff6a 100644 --- a/BO4E/COM/Lastprofil.cs +++ b/BO4E/COM/Lastprofil.cs @@ -1,8 +1,8 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; using Newtonsoft.Json; using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -28,6 +28,7 @@ public class Lastprofil : COM [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1005)] public string? Profilschar { get; set; } + /// /// Verfahren des Profils (analytisch oder synthetisch) /// @@ -38,7 +39,7 @@ public class Lastprofil : COM public Profilverfahren? Verfahren { get; set; } /// - /// true, falls es sich um ein Einspeiseprofil handelt + /// true, falls es sich um ein Einspeiseprofil handelt /// [JsonProperty(PropertyName = "einspeisung", Required = Required.Default)] [JsonPropertyName("einspeisung")] @@ -46,7 +47,6 @@ public class Lastprofil : COM [ProtoMember(1003)] public bool? Einspeisung { get; set; } - /// /// Klimazone / Temperaturmessstelle /// @@ -73,5 +73,4 @@ public class Lastprofil : COM [JsonPropertyName("herausgeber")] [ProtoMember(1006)] public string? Herausgeber { get; set; } - -} \ No newline at end of file +} diff --git a/BO4E/COM/MarktpartnerDetails.cs b/BO4E/COM/MarktpartnerDetails.cs index f8bcc3d9..d5b168c9 100644 --- a/BO4E/COM/MarktpartnerDetails.cs +++ b/BO4E/COM/MarktpartnerDetails.cs @@ -1,21 +1,19 @@ +using System; +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; [Obsolete( - "This class has been renamed to COM." + nameof(MarktpartnerDetails) + " to avoid further naming confusion.", - true)] + "This class has been renamed to COM." + + nameof(MarktpartnerDetails) + + " to avoid further naming confusion.", + true +)] #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -public class Marktrolle : MarktpartnerDetails -{ -} +public class Marktrolle : MarktpartnerDetails { } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member @@ -62,4 +60,4 @@ public class MarktpartnerDetails : COM public bool? Weiterverpflichtet { get; set; } #pragma warning restore IDE1006 // Naming Styles -} \ No newline at end of file +} diff --git a/BO4E/COM/Menge.cs b/BO4E/COM/Menge.cs index 74b2e11e..587211ae 100644 --- a/BO4E/COM/Menge.cs +++ b/BO4E/COM/Menge.cs @@ -1,12 +1,9 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// Abbildung einer Menge mit Wert und Einheit. @@ -28,4 +25,4 @@ public class Menge : COM [JsonPropertyOrder(11)] [ProtoMember(4)] public Mengeneinheit? Einheit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Messlokationszuordnung.cs b/BO4E/COM/Messlokationszuordnung.cs index 0e88e544..838d9e47 100644 --- a/BO4E/COM/Messlokationszuordnung.cs +++ b/BO4E/COM/Messlokationszuordnung.cs @@ -27,8 +27,7 @@ public class Messlokationszuordnung : COM /// wird. Beispielsweise bei einer Untermessung, wird der Verbauch der Untermessung subtrahiert. Details /// /// - [JsonProperty(PropertyName = "arithmetik", - Required = Required.Default)] // Default weil Hochfrequenz/energy-service-hub#35 + [JsonProperty(PropertyName = "arithmetik", Required = Required.Default)] // Default weil Hochfrequenz/energy-service-hub#35 [JsonPropertyName("arithmetik")] [ProtoMember(4)] public ArithmetischeOperation? Arithmetik { get; set; } @@ -40,8 +39,10 @@ public class Messlokationszuordnung : COM private DateTime _GueltigSeit { get => GueltigSeit?.UtcDateTime ?? default; - set => GueltigSeit = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + GueltigSeit = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Zeitpunkt, ab dem die Messlokation zur Marktlokation gehört [JsonProperty(PropertyName = "gueltigSeit", Required = Required.Default)] [JsonPropertyName("gueltigSeit")] @@ -57,9 +58,10 @@ private DateTime _GueltigBis get => GueltigBis?.UtcDateTime ?? default; set => GueltigBis = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Zeitpunkt, bis zu dem die Messlokation zur Marktlokation gehört [JsonProperty(PropertyName = "gueltigBis", Required = Required.Default)] [JsonPropertyName("gueltigBis")] [ProtoIgnore] public DateTimeOffset? GueltigBis { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Messprodukt.cs b/BO4E/COM/Messprodukt.cs index 30e5f1ea..449f7f27 100644 --- a/BO4E/COM/Messprodukt.cs +++ b/BO4E/COM/Messprodukt.cs @@ -22,11 +22,7 @@ public class Messprodukt : COM public string? MessproduktId { get; set; } /// Verwendungungszweck der Werte Marktlokation - [JsonProperty( - PropertyName = "verwendungszwecke", - Order = 1011, - Required = Required.Default - )] + [JsonProperty(PropertyName = "verwendungszwecke", Order = 1011, Required = Required.Default)] [JsonPropertyName("verwendungszwecke")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1011)] @@ -42,11 +38,7 @@ public class Messprodukt : COM public Verbrauchsart? Verbrauchsart { get; set; } /// Stromverbrauchsart/Unterbrechbarkeit Marktlokation - [JsonProperty( - PropertyName = "unterbrechbarkeit", - Order = 1013, - Required = Required.Default - )] + [JsonProperty(PropertyName = "unterbrechbarkeit", Order = 1013, Required = Required.Default)] [JsonPropertyName("unterbrechbarkeit")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1013)] @@ -111,4 +103,4 @@ public class Messprodukt : COM public EMobilitaetsart? EMobilitaetsart { get; set; } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/COM/Netznutzungsabrechnungsdaten.cs b/BO4E/COM/Netznutzungsabrechnungsdaten.cs index 057cc823..5abe3d34 100644 --- a/BO4E/COM/Netznutzungsabrechnungsdaten.cs +++ b/BO4E/COM/Netznutzungsabrechnungsdaten.cs @@ -1,9 +1,7 @@ +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -23,7 +21,6 @@ public class Netznutzungsabrechnungsdaten : COM [ProtoMember(4)] public string? ArtikelId { get; set; } - /// /// Typ der ArtikelId (Einzel oder Gruppe) /// @@ -68,10 +65,15 @@ public class Netznutzungsabrechnungsdaten : COM [JsonPropertyOrder(9)] [ProtoMember(9)] public decimal? Abschlag { get; set; } + /// /// Singuläre Betriebsmittel /// - [JsonProperty(PropertyName = "singulaereBetriebsmittel", Order = 10, Required = Required.Default)] + [JsonProperty( + PropertyName = "singulaereBetriebsmittel", + Order = 10, + Required = Required.Default + )] [JsonPropertyOrder(10)] [JsonPropertyName("singulaereBetriebsmittel")] [ProtoMember(10)] @@ -80,7 +82,11 @@ public class Netznutzungsabrechnungsdaten : COM /// /// Preis für singuläre Betriebsmittel /// - [JsonProperty(PropertyName = "preisSingulaereBetriebsmittel", Order = 11, Required = Required.Default)] + [JsonProperty( + PropertyName = "preisSingulaereBetriebsmittel", + Order = 11, + Required = Required.Default + )] [JsonPropertyOrder(11)] [JsonPropertyName("preisSingulaereBetriebsmittel")] [ProtoMember(11)] @@ -95,4 +101,4 @@ public class Netznutzungsabrechnungsdaten : COM [ProtoMember(12)] [JsonPropertyOrder(12)] public Zaehlzeitregister? Zaehlzeit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Notiz.cs b/BO4E/COM/Notiz.cs index e7a377c9..3185ff58 100644 --- a/BO4E/COM/Notiz.cs +++ b/BO4E/COM/Notiz.cs @@ -20,8 +20,8 @@ public class Notiz : COM /// [Newtonsoft.Json.JsonIgnore] [System.Text.Json.Serialization.JsonIgnore] - private static readonly Regex TrailingMinusRegex = new(@"\r?(?:\\n|\n)?-*$", RegexOptions.Compiled); - + private static readonly Regex TrailingMinusRegex = + new(@"\r?(?:\\n|\n)?-*$", RegexOptions.Compiled); private string _inhalt; @@ -33,7 +33,6 @@ public class Notiz : COM [ProtoMember(3)] public string Autor { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(4, Name = nameof(Zeitpunkt))] @@ -43,6 +42,7 @@ private DateTime _Zeitpunkt get => Zeitpunkt.UtcDateTime; set => Zeitpunkt = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Zeitpunkt zu dem die Notiz angelegt wurde /// @@ -62,4 +62,4 @@ public string Inhalt get => _inhalt; set => _inhalt = TrailingMinusRegex.Replace(value, string.Empty); } -} \ No newline at end of file +} diff --git a/BO4E/COM/PhysikalischerWert.cs b/BO4E/COM/PhysikalischerWert.cs index 4ee2ce18..b79132c7 100644 --- a/BO4E/COM/PhysikalischerWert.cs +++ b/BO4E/COM/PhysikalischerWert.cs @@ -19,7 +19,8 @@ public class PhysikalischerWert : COM /// /// numerischer Wert /// zugehörige Mengeneinheit - public PhysikalischerWert(decimal wert, Mengeneinheit einheit) : this() + public PhysikalischerWert(decimal wert, Mengeneinheit einheit) + : this() { Wert = wert; Einheit = einheit; @@ -28,16 +29,15 @@ public PhysikalischerWert(decimal wert, Mengeneinheit einheit) : this() /// /// empty constructor for deserilization /// - public PhysikalischerWert() - { - } + public PhysikalischerWert() { } /// /// initialise with wert and string for einheit /// /// numerischer wert /// zugehörige Einheit als string (case insensitive) - public PhysikalischerWert(decimal wert, string einheitString) : this() + public PhysikalischerWert(decimal wert, string einheitString) + : this() { Wert = wert; @@ -64,4 +64,4 @@ public PhysikalischerWert(decimal wert, string einheitString) : this() [JsonProperty(Required = Required.Always, PropertyName = "einheit")] [JsonPropertyName("einheit")] public Mengeneinheit Einheit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/PositionsAufAbschlag.cs b/BO4E/COM/PositionsAufAbschlag.cs index eb60d1f8..4ebba741 100644 --- a/BO4E/COM/PositionsAufAbschlag.cs +++ b/BO4E/COM/PositionsAufAbschlag.cs @@ -44,4 +44,4 @@ public class PositionsAufAbschlag : COM [JsonPropertyName("aufAbschlagswaehrung")] [ProtoMember(7)] public Waehrungseinheit AufAbschlagswaehrung { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Preis.cs b/BO4E/COM/Preis.cs index 7037d34f..d8ce7ed1 100644 --- a/BO4E/COM/Preis.cs +++ b/BO4E/COM/Preis.cs @@ -38,4 +38,4 @@ public class Preis : COM [JsonPropertyName("status")] [ProtoMember(6)] public Preisstatus? Status { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Preisgarantie.cs b/BO4E/COM/Preisgarantie.cs index 03723d31..8c4b763a 100644 --- a/BO4E/COM/Preisgarantie.cs +++ b/BO4E/COM/Preisgarantie.cs @@ -35,4 +35,4 @@ public class Preisgarantie : COM [JsonPropertyName("zeitlicheGueltigkeit")] [ProtoMember(5)] public Zeitraum ZeitlicheGueltigkeit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Preisposition.cs b/BO4E/COM/Preisposition.cs index 046d8ac0..295ea98e 100644 --- a/BO4E/COM/Preisposition.cs +++ b/BO4E/COM/Preisposition.cs @@ -150,7 +150,7 @@ public class Preisposition : COM public Zeitraum? Verarbeitungszeitraum { get; set; } /// - /// Die genauen Bedeutungen der einzelnen Artikel-IDs sind in der EDI@Energy Codeliste der Artikelnummern + /// Die genauen Bedeutungen der einzelnen Artikel-IDs sind in der EDI@Energy Codeliste der Artikelnummern /// und Artikel-IDs zu finden, die in der Spalte "PRICAT Codeverwendung" ein X haben /// [JsonProperty(PropertyName = "artikelId", Order = 26, Required = Required.Default)] @@ -158,4 +158,4 @@ public class Preisposition : COM [NonOfficial(NonOfficialCategory.MISSING)] [JsonPropertyOrder(26)] public string? ArtikelId { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Preisstaffel.cs b/BO4E/COM/Preisstaffel.cs index 9f388b00..9ef083fd 100644 --- a/BO4E/COM/Preisstaffel.cs +++ b/BO4E/COM/Preisstaffel.cs @@ -35,4 +35,4 @@ public class Preisstaffel : COM [JsonPropertyName("sigmoidparameter")] [ProtoMember(6)] public Sigmoidparameter? Sigmoidparameter { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Rechenschritt.cs b/BO4E/COM/Rechenschritt.cs index 9dd85136..8c7a7312 100644 --- a/BO4E/COM/Rechenschritt.cs +++ b/BO4E/COM/Rechenschritt.cs @@ -68,7 +68,7 @@ public class Rechenschritt : COM /// gibt an, ob die gemessene Energie an der Messlokation zum Netz fließt(Erzeugung) oder vom Netz wegfließt(Verbrauch). /// Entsprechend dieser Aussage sind die zuvor durch die UTILMD ausgetauschten Register der Messlokation in der /// Berechnungsformel zu verwenden - /// + /// /// [JsonProperty(Required = Required.Default, Order = 7, PropertyName = "energieflussrichtung")] [JsonPropertyName("energieflussrichtung")] @@ -86,8 +86,12 @@ public class Rechenschritt : COM /// Aufteilungsfaktor Energiemenge /// /// UTILTS SG9 CCI ZG6 - [JsonProperty(Required = Required.Default, Order = 9, PropertyName = "aufteilungsfaktorEnergiemenge")] + [JsonProperty( + Required = Required.Default, + Order = 9, + PropertyName = "aufteilungsfaktorEnergiemenge" + )] [JsonPropertyName("aufteilungsfaktorEnergiemenge")] [ProtoMember(9)] public decimal? AufteilungsfaktorEnergiemenge { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Rechnungsposition.cs b/BO4E/COM/Rechnungsposition.cs index 71c5c414..3e6a5822 100644 --- a/BO4E/COM/Rechnungsposition.cs +++ b/BO4E/COM/Rechnungsposition.cs @@ -1,14 +1,11 @@ +using System; +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -26,7 +23,6 @@ public class Rechnungsposition : COM [ProtoMember(1)] public int Positionsnummer { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(2, Name = nameof(LieferungVon))] @@ -36,6 +32,7 @@ private DateTime _LieferungVon get => LieferungVon?.UtcDateTime ?? DateTime.MinValue; set => LieferungVon = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Start der Lieferung für die abgerechnete Leistung. [JsonProperty(PropertyName = "lieferungVon", Required = Required.Default, Order = 12)] [JsonPropertyName("lieferungVon")] @@ -45,7 +42,6 @@ private DateTime _LieferungVon [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? LieferungVon { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(3, Name = nameof(LieferungBis))] @@ -55,6 +51,7 @@ private DateTime _LieferungBis get => LieferungBis?.UtcDateTime ?? DateTime.MinValue; set => LieferungBis = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Ende der Lieferung für die abgerechnete Leistung. [JsonProperty(PropertyName = "lieferungBis", Required = Required.Default, Order = 13)] [JsonPropertyName("lieferungBis")] @@ -220,7 +217,9 @@ private DateTime _LieferungBis protected DateTime? _Ausfuehrungsdatum { get => Ausfuehrungsdatum?.UtcDateTime; - set => Ausfuehrungsdatum = value != null ? DateTime.SpecifyKind(value.Value, DateTimeKind.Utc) : null; + set => + Ausfuehrungsdatum = + value != null ? DateTime.SpecifyKind(value.Value, DateTimeKind.Utc) : null; } /// @@ -231,5 +230,4 @@ protected DateTime? _Ausfuehrungsdatum [JsonPropertyOrder(29)] [ProtoIgnore] public DateTimeOffset? Ausfuehrungsdatum { get; set; } - -} \ No newline at end of file +} diff --git a/BO4E/COM/RechnungspositionFlat.cs b/BO4E/COM/RechnungspositionFlat.cs index d4dffb81..bebedd1e 100644 --- a/BO4E/COM/RechnungspositionFlat.cs +++ b/BO4E/COM/RechnungspositionFlat.cs @@ -60,9 +60,7 @@ public RechnungspositionFlat(Rechnungsposition rp) /// /// empty constructor for serialization /// - public RechnungspositionFlat() - { - } + public RechnungspositionFlat() { } /// [JsonProperty(PropertyName = "positionsnummer", Required = Required.Always)] @@ -79,6 +77,7 @@ private DateTime _LieferungVon get => LieferungVon?.UtcDateTime ?? DateTime.MinValue; set => LieferungVon = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// [JsonProperty(PropertyName = "lieferungVon", Required = Required.Default)] [JsonPropertyName("lieferungVon")] @@ -95,6 +94,7 @@ private DateTime _LieferungBis get => LieferungBis?.UtcDateTime ?? DateTime.MinValue; set => LieferungBis = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// [JsonProperty(PropertyName = "lieferungBis", Required = Required.Default)] [JsonPropertyName("lieferungBis")] @@ -214,16 +214,22 @@ public Rechnungsposition ToRechnungsposition() Wert = PreisWert, Einheit = PreisEinheit, Bezugswert = PreisBezugswert, - Status = PreisStatus ?? Preisstatus.VORLAEUFIG // poor default choice + Status = + PreisStatus + ?? Preisstatus.VORLAEUFIG // poor default choice + , }, PositionsMenge = new Menge { Einheit = PositionsMengeEinheit ?? Mengeneinheit.KWH, // poor default choice - Wert = PositionsMengeWert ?? 0.0M // poor default choice + Wert = + PositionsMengeWert + ?? 0.0M // poor default choice + , }, Guid = Guid, - Status = Status + Status = Status, }; return result; } -} \ No newline at end of file +} diff --git a/BO4E/COM/RegionalePreisgarantie.cs b/BO4E/COM/RegionalePreisgarantie.cs index 51566d99..35759a3f 100644 --- a/BO4E/COM/RegionalePreisgarantie.cs +++ b/BO4E/COM/RegionalePreisgarantie.cs @@ -12,4 +12,4 @@ public class RegionalePreisgarantie : Preisgarantie [JsonPropertyName("regionaleGueltigkeit")] //[ProtoMember(6)] public RegionaleGueltigkeit RegionaleGueltigkeit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/RegionalePreisstaffel.cs b/BO4E/COM/RegionalePreisstaffel.cs index 11d38521..cc8227ea 100644 --- a/BO4E/COM/RegionalePreisstaffel.cs +++ b/BO4E/COM/RegionalePreisstaffel.cs @@ -12,4 +12,4 @@ public class RegionalePreisstaffel : Preisstaffel [JsonPropertyName("regionaleGueltigkeit")] //[ProtoMember(8)] public RegionaleGueltigkeit RegionaleGueltigkeit { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/RegionaleTarifpreisposition.cs b/BO4E/COM/RegionaleTarifpreisposition.cs index 308b292a..22655781 100644 --- a/BO4E/COM/RegionaleTarifpreisposition.cs +++ b/BO4E/COM/RegionaleTarifpreisposition.cs @@ -50,4 +50,4 @@ public class RegionaleTarifpreisposition : COM [JsonPropertyName("preisstaffeln")] [ProtoMember(7)] public List? Preisstaffeln { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/RegionalerAufAbschlag.cs b/BO4E/COM/RegionalerAufAbschlag.cs index a48863f5..7b17f486 100644 --- a/BO4E/COM/RegionalerAufAbschlag.cs +++ b/BO4E/COM/RegionalerAufAbschlag.cs @@ -123,4 +123,4 @@ public class RegionalerAufAbschlag : COM [JsonPropertyName("staffeln")] [ProtoMember(17)] public List Staffeln { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Regionskriterium.cs b/BO4E/COM/Regionskriterium.cs index 84c4e1dd..a5ff0e82 100644 --- a/BO4E/COM/Regionskriterium.cs +++ b/BO4E/COM/Regionskriterium.cs @@ -53,4 +53,4 @@ public class Regionskriterium : COM [JsonPropertyName("wert")] [ProtoMember(7)] public string Wert { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Rueckmeldungsposition.cs b/BO4E/COM/Rueckmeldungsposition.cs index e8ddab6d..79a940f9 100644 --- a/BO4E/COM/Rueckmeldungsposition.cs +++ b/BO4E/COM/Rueckmeldungsposition.cs @@ -1,12 +1,9 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Collections.Generic; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -16,7 +13,6 @@ namespace BO4E.COM; [NonOfficial(NonOfficialCategory.MISSING)] public class Rueckmeldungsposition : COM { - /// /// Positionsnummer der Referenzierung /// @@ -36,6 +32,4 @@ public class Rueckmeldungsposition : COM [ProtoMember(4)] [JsonPropertyOrder(4)] public List? Abweichungspositionen { get; set; } - - -} \ No newline at end of file +} diff --git a/BO4E/COM/Rufnummer.cs b/BO4E/COM/Rufnummer.cs index edb6d049..a287f8ba 100644 --- a/BO4E/COM/Rufnummer.cs +++ b/BO4E/COM/Rufnummer.cs @@ -25,4 +25,4 @@ public class Rufnummer : COM // ReSharper disable once InconsistentNaming public string rufnummer { get; set; } #pragma warning restore IDE1006 // Naming Styles -} \ No newline at end of file +} diff --git a/BO4E/COM/Sigmoidparameter.cs b/BO4E/COM/Sigmoidparameter.cs index 68b13cf2..f8a8cac3 100644 --- a/BO4E/COM/Sigmoidparameter.cs +++ b/BO4E/COM/Sigmoidparameter.cs @@ -32,4 +32,4 @@ public class Sigmoidparameter : COM [JsonPropertyName("D")] [ProtoMember(6)] public decimal D { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/StatusZusatzInformation.cs b/BO4E/COM/StatusZusatzInformation.cs index 6df7c762..467120a7 100644 --- a/BO4E/COM/StatusZusatzInformation.cs +++ b/BO4E/COM/StatusZusatzInformation.cs @@ -26,7 +26,6 @@ public class StatusZusatzInformation : COM [ProtoMember(1)] public StatusArt? Art { get; set; } - /// /// Enthält die Zusatzinformation Status des angegebenen Wertes /// @@ -36,4 +35,4 @@ public class StatusZusatzInformation : COM [NonOfficial(NonOfficialCategory.UNSPECIFIED)] [ProtoMember(2)] public Status? Status { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Steuerbetrag.cs b/BO4E/COM/Steuerbetrag.cs index f2d1e60e..bcad4610 100644 --- a/BO4E/COM/Steuerbetrag.cs +++ b/BO4E/COM/Steuerbetrag.cs @@ -1,12 +1,9 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// Abbildung eines Steuerbetrages. @@ -64,4 +61,4 @@ public class Steuerbetrag : COM [FieldName("taxValuePrepaid", Language.EN)] [ProtoMember(8)] public decimal? SteuerwertVorausgezahlt { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Tagesparameter.cs b/BO4E/COM/Tagesparameter.cs index b4b723ab..f3440f52 100644 --- a/BO4E/COM/Tagesparameter.cs +++ b/BO4E/COM/Tagesparameter.cs @@ -1,11 +1,8 @@ +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -50,5 +47,4 @@ public class Tagesparameter : COM [JsonPropertyName("herausgeber")] [ProtoMember(6)] public string? Herausgeber { get; set; } - -} \ No newline at end of file +} diff --git a/BO4E/COM/Tarifberechnungsparameter.cs b/BO4E/COM/Tarifberechnungsparameter.cs index a54b25d4..6cd5f432 100644 --- a/BO4E/COM/Tarifberechnungsparameter.cs +++ b/BO4E/COM/Tarifberechnungsparameter.cs @@ -72,4 +72,4 @@ public class Tarifberechnungsparameter : COM [JsonPropertyName("mindestpreis")] [ProtoMember(12)] public Preis? Mindestpreis { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Tarifeinschraenkung.cs b/BO4E/COM/Tarifeinschraenkung.cs index f1758592..509710f6 100644 --- a/BO4E/COM/Tarifeinschraenkung.cs +++ b/BO4E/COM/Tarifeinschraenkung.cs @@ -43,4 +43,4 @@ public class Tarifeinschraenkung : COM [JsonPropertyName("einschraenkungleistung")] [ProtoMember(6)] public Menge? Einschraenkungleistung { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Tarifpreisposition.cs b/BO4E/COM/Tarifpreisposition.cs index ce9202e5..7db0ba4c 100644 --- a/BO4E/COM/Tarifpreisposition.cs +++ b/BO4E/COM/Tarifpreisposition.cs @@ -43,4 +43,4 @@ public class Tarifpreisposition : COM [JsonPropertyName("preisstaffeln")] [ProtoMember(7)] public Preisstaffel Preisstaffeln { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Unterschrift.cs b/BO4E/COM/Unterschrift.cs index 131c6680..ae0f1e0f 100644 --- a/BO4E/COM/Unterschrift.cs +++ b/BO4E/COM/Unterschrift.cs @@ -45,4 +45,4 @@ private DateTime _Datum [JsonPropertyName("name")] [ProtoMember(5)] public string? Name { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Verbrauch.cs b/BO4E/COM/Verbrauch.cs index 2a9fccac..9da6ee00 100644 --- a/BO4E/COM/Verbrauch.cs +++ b/BO4E/COM/Verbrauch.cs @@ -1,16 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -19,7 +16,8 @@ namespace BO4E.COM; [ProtoContract] public class Verbrauch : COM { - [ProtoIgnore] internal const string SapProfdecimalsKey = "sap_profdecimals"; + [ProtoIgnore] + internal const string SapProfdecimalsKey = "sap_profdecimals"; /// /// static serializer options for Verbracuhconverter @@ -36,11 +34,16 @@ static Verbrauch() /// [ProtoIgnore] [Obsolete( - "This property moved. Use the property BO4E.meta." + nameof(CentralEuropeStandardTime) + "." + - nameof(CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) + " instead.", true)] + "This property moved. Use the property BO4E.meta." + + nameof(CentralEuropeStandardTime) + + "." + + nameof(CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) + + " instead.", + true + )] // ReSharper disable once InconsistentNaming - public static TimeZoneInfo CENTRAL_EUROPE_STANDARD_TIME - => CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo; + public static TimeZoneInfo CENTRAL_EUROPE_STANDARD_TIME => + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo; /// /// Beginn des Zeitraumes, für den der Verbrauch angegeben wird. @@ -57,6 +60,7 @@ private DateTime _Startdatum get => Startdatum?.UtcDateTime ?? default; set => Startdatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Gibt Tag und Uhrzeit (falls vorhanden) an, wann der Zeitraum startet. [JsonProperty(PropertyName = "startdatum", Required = Required.Default)] [JsonPropertyName("startdatum")] @@ -65,7 +69,6 @@ private DateTime _Startdatum [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? Startdatum { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(3, Name = nameof(Enddatum))] @@ -75,6 +78,7 @@ private DateTime _Enddatum get => Enddatum?.UtcDateTime ?? default; set => Enddatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Gibt Tag und Uhrzeit (falls vorhanden) an, wann der Zeitraum endet. [JsonProperty(PropertyName = "enddatum", Required = Required.Default)] [JsonPropertyName("enddatum")] @@ -87,7 +91,11 @@ private DateTime _Enddatum /// Gibt an, ob es sich um eine PROGNOSE oder eine MESSUNG handelt. /// /// - [JsonProperty(PropertyName = "wertermittlungsverfahren", Required = Required.Default, Order = 5)] + [JsonProperty( + PropertyName = "wertermittlungsverfahren", + Required = Required.Default, + Order = 5 + )] [JsonPropertyName("wertermittlungsverfahren")] [ProtoMember(5)] public Wertermittlungsverfahren? Wertermittlungsverfahren { get; set; } @@ -102,12 +110,15 @@ private DateTime _Enddatum [ProtoMember(10)] public Messwertstatus? Messwertstatus { get; set; } - /// /// Enthält die Auflistung der STS Segmente Plausibilisierungshinweis, Ersatzwertbildungsverfahren, /// Korrekturgrund, Gasqualität, Tarif, Grundlage der Energiemenge /// - [JsonProperty(PropertyName = "statuszusatzinformationen", Required = Required.Default, Order = 5)] + [JsonProperty( + PropertyName = "statuszusatzinformationen", + Required = Required.Default, + Order = 5 + )] [JsonPropertyName("statuszusatzinformationen")] [NonOfficial(NonOfficialCategory.UNSPECIFIED)] [ProtoMember(11)] @@ -164,8 +175,11 @@ private DateTime _Enddatum private DateTime _Nutzungszeitpunkt { get => Nutzungszeitpunkt?.UtcDateTime ?? default; - set => Nutzungszeitpunkt = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + Nutzungszeitpunkt = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Wird verwendet, um einen Zählerstand eindeutig einem Prozesszeitpunkt zuzuordnen. Dieser Prozesszeitpunkt kann entweder ein Zeitpunkt einer Stammdatenänderung sein(z. B.bei einem Gerätewechsel, in der die Änderung vor dem Versand des Zählerstandes übermittelt wurde) oder die Bestellung eines Wertes aufgrund eines eingetretenen Ereignisses(z.B. Lieferantenwechsel). Der Nutzungszeitpunkt ist für den Zählerstand der Zeitpunkt der für die weitere Verarbeitung relevant ist(z.B.Zuordnung bei Empfänger anhand der Zuordnungstupel). [JsonProperty(PropertyName = "nutzungszeitpunkt", Required = Required.Default, Order = 13)] [JsonPropertyName("nutzungszeitpunkt")] @@ -181,8 +195,11 @@ private DateTime _Nutzungszeitpunkt private DateTime _Ausfuehrungszeitpunkt { get => Ausfuehrungszeitpunkt?.UtcDateTime ?? default; - set => Ausfuehrungszeitpunkt = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + Ausfuehrungszeitpunkt = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Wird verwendet, um einen Zählerstand eindeutig einer tatsächlichen Änderung zuzuordnen, z.B.bei einem Gerätewechsel oder Geräteparameteränderung der tatsächliche Zeitpunkt an dem die Änderung an der Messlokation durchgeführt wurde.Der Nutzungszeitpunkt ist für den Zählerstand der Zeitpunkt der für die weitere Verarbeitung relevant ist(z.B. Zuordnung bei Empfänger anhand der Zuordnungstupel). [JsonProperty(PropertyName = "ausfuehrungszeitpunkt", Required = Required.Default, Order = 14)] [JsonPropertyName("ausfuehrungszeitpunkt")] @@ -190,6 +207,4 @@ private DateTime _Ausfuehrungszeitpunkt [JsonPropertyOrder(14)] [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? Ausfuehrungszeitpunkt { get; set; } - - -} \ No newline at end of file +} diff --git a/BO4E/COM/Vertragskonditionen.cs b/BO4E/COM/Vertragskonditionen.cs index c5940478..342697ab 100644 --- a/BO4E/COM/Vertragskonditionen.cs +++ b/BO4E/COM/Vertragskonditionen.cs @@ -1,14 +1,11 @@ +using System; +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// Abbildung für Vertragskonditionen. Die Komponente wird sowohl im Vertrag als auch im Tarif verwendet. @@ -70,8 +67,11 @@ public class Vertragskonditionen : COM private DateTime _StartAbrechnungsjahr { get => StartAbrechnungsjahr?.UtcDateTime ?? default; - set => StartAbrechnungsjahr = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); + set => + StartAbrechnungsjahr = + value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + // ToDo: Docstring! [JsonProperty(PropertyName = "startAbrechnungsjahr", Required = Required.Default, Order = 16)] [JsonPropertyName("startAbrechnungsjahr")] @@ -94,7 +94,11 @@ private DateTime _StartAbrechnungsjahr // ToDo: Docstring! what is the unit? days? why don't you use zeitraum? // todo @hamid: add a docstring - [JsonProperty(PropertyName = "turnusablesungIntervall", Required = Required.Default, Order = 18)] + [JsonProperty( + PropertyName = "turnusablesungIntervall", + Required = Required.Default, + Order = 18 + )] [JsonPropertyName("turnusablesungIntervall")] [JsonPropertyOrder(18)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -112,7 +116,11 @@ private DateTime _StartAbrechnungsjahr // ToDo: Docstring! what is the unit? days? why dont you use zeitraum? // todo @hamid: add a docstring - [JsonProperty(PropertyName = "netznutzungsabrechnungIntervall", Required = Required.Default, Order = 20)] + [JsonProperty( + PropertyName = "netznutzungsabrechnungIntervall", + Required = Required.Default, + Order = 20 + )] [JsonPropertyName("netznutzungsabrechnungIntervall")] [JsonPropertyOrder(20)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -137,7 +145,6 @@ private DateTime _StartAbrechnungsjahr [ProtoMember(1015)] public Netznutzungsvertragsart? Netznutzungsvertragsart { get; set; } - // ToDo: Docstring! // todo @hamid: add a docstring [JsonProperty(PropertyName = "netznutzungszahler", Required = Required.Default, Order = 23)] @@ -149,7 +156,11 @@ private DateTime _StartAbrechnungsjahr // ToDo: Docstring! // todo @hamid: add a docstring - [JsonProperty(PropertyName = "netznutzungsabrechnungsvariante", Required = Required.Default, Order = 24)] + [JsonProperty( + PropertyName = "netznutzungsabrechnungsvariante", + Required = Required.Default, + Order = 24 + )] [JsonPropertyName("netznutzungsabrechnungsvariante")] [JsonPropertyOrder(24)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -158,7 +169,11 @@ private DateTime _StartAbrechnungsjahr // ToDo: Docstring! // todo @hamid: add a docstring - [JsonProperty(PropertyName = "netznutzungsabrechnungsgrundlage", Required = Required.Default, Order = 25)] + [JsonProperty( + PropertyName = "netznutzungsabrechnungsgrundlage", + Required = Required.Default, + Order = 25 + )] [JsonPropertyName("netznutzungsabrechnungsgrundlage")] [JsonPropertyOrder(25)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -167,11 +182,15 @@ private DateTime _StartAbrechnungsjahr /// /// Singulär genutzte Betriebsmittel in der Netznutzungsabrechnung - /// Hier wird angegeben, ob in der Netznutzungsabrechnung der verbrauchenden Marktlokation singulär + /// Hier wird angegeben, ob in der Netznutzungsabrechnung der verbrauchenden Marktlokation singulär /// genutzte Betriebsmittel abgerechnet werden. /// /// für EDIFACT mapping - [JsonProperty(PropertyName = "beinhaltetSingulaerGenutzteBetriebsmittel", Required = Required.Default, Order = 26)] + [JsonProperty( + PropertyName = "beinhaltetSingulaerGenutzteBetriebsmittel", + Required = Required.Default, + Order = 26 + )] [JsonPropertyName("beinhaltetSingulaerGenutzteBetriebsmittel")] [JsonPropertyOrder(26)] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] @@ -179,4 +198,4 @@ private DateTime _StartAbrechnungsjahr public bool? BeinhaltetSingulaerGenutzteBetriebsmittel { get; set; } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/COM/Vertragsteil.cs b/BO4E/COM/Vertragsteil.cs index f04009bd..3e9b0400 100644 --- a/BO4E/COM/Vertragsteil.cs +++ b/BO4E/COM/Vertragsteil.cs @@ -1,13 +1,10 @@ +using System; +using System.Text.Json.Serialization; using BO4E.meta; using BO4E.meta.LenientConverters; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -27,6 +24,7 @@ private DateTime _Vertragsteilbeginn get => Vertragsteilbeginn?.UtcDateTime ?? DateTime.MinValue; set => Vertragsteilbeginn = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Start der Gültigkeit des Vertragsteils. /// @@ -36,7 +34,6 @@ private DateTime _Vertragsteilbeginn [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? Vertragsteilbeginn { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(4, Name = nameof(Vertragsteilende))] @@ -46,6 +43,7 @@ private DateTime _Vertragsteilende get => Vertragsteilende?.UtcDateTime ?? DateTime.MinValue; set => Vertragsteilende = DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// /// Ende der Gültigkeit des Vertragsteils. /// @@ -113,4 +111,4 @@ private DateTime _Vertragsteilende [JsonPropertyName("verbrauchsaufteilung")] [ProtoMember(1011)] public string? Verbrauchsaufteilung { get; set; } // ToDo: evaluate if this actually should be an enum -} \ No newline at end of file +} diff --git a/BO4E/COM/Verwendungszweck.cs b/BO4E/COM/Verwendungszweck.cs index e2d0a81f..ba1f5378 100644 --- a/BO4E/COM/Verwendungszweck.cs +++ b/BO4E/COM/Verwendungszweck.cs @@ -28,4 +28,4 @@ public class Verwendungszweck : COM [JsonPropertyName("zweck")] [ProtoMember(4)] public List? Zweck { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Vorauszahlung.cs b/BO4E/COM/Vorauszahlung.cs index c8b27a97..5ab489b4 100644 --- a/BO4E/COM/Vorauszahlung.cs +++ b/BO4E/COM/Vorauszahlung.cs @@ -1,12 +1,9 @@ +using System; +using System.Text.Json.Serialization; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System; -using System.Text.Json.Serialization; - namespace BO4E.COM; /// @@ -23,7 +20,6 @@ public class Vorauszahlung : COM [JsonPropertyOrder(3)] public Betrag Betrag { get; set; } - /// /// Referenz auf die Rechnungsnummer, die durch diesen Betrag bezahlt wurde /// @@ -54,4 +50,4 @@ private DateTime _ReferenzDatum get => ReferenzDatum?.UtcDateTime ?? DateTime.MinValue; set => ReferenzDatum = DateTime.SpecifyKind(value, DateTimeKind.Utc); } -} \ No newline at end of file +} diff --git a/BO4E/COM/Zaehlwerk.cs b/BO4E/COM/Zaehlwerk.cs index c16a5787..e61ac06a 100644 --- a/BO4E/COM/Zaehlwerk.cs +++ b/BO4E/COM/Zaehlwerk.cs @@ -74,11 +74,7 @@ public class Zaehlwerk : COM public string? Kennzahl { get; set; } /// schwachlastfaehig - [JsonProperty( - PropertyName = "schwachlastfaehig", - Order = 1010, - Required = Required.Default - )] + [JsonProperty(PropertyName = "schwachlastfaehig", Order = 1010, Required = Required.Default)] [JsonPropertyName("schwachlastfaehig")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1010)] @@ -86,11 +82,7 @@ public class Zaehlwerk : COM public Schwachlastfaehig? Schwachlastfaehig { get; set; } /// Verwendungungszweck der Werte Marktlokation - [JsonProperty( - PropertyName = "verwendungszwecke", - Order = 1011, - Required = Required.Default - )] + [JsonProperty(PropertyName = "verwendungszwecke", Order = 1011, Required = Required.Default)] [JsonPropertyName("verwendungszwecke")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1011)] @@ -106,11 +98,7 @@ public class Zaehlwerk : COM public Verbrauchsart? Verbrauchsart { get; set; } /// Stromverbrauchsart/Unterbrechbarkeit Marktlokation - [JsonProperty( - PropertyName = "unterbrechbarkeit", - Order = 1013, - Required = Required.Default - )] + [JsonProperty(PropertyName = "unterbrechbarkeit", Order = 1013, Required = Required.Default)] [JsonPropertyName("unterbrechbarkeit")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1013)] @@ -125,11 +113,7 @@ public class Zaehlwerk : COM [JsonPropertyOrder(1014)] public Waermenutzung? Waermenutzung { get; set; } - [JsonProperty( - PropertyName = "konzessionsabgabe", - Order = 1015, - Required = Required.Default - )] + [JsonProperty(PropertyName = "konzessionsabgabe", Order = 1015, Required = Required.Default)] [JsonPropertyName("konzessionsabgabe")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1015)] @@ -162,11 +146,7 @@ public class Zaehlwerk : COM // Todo @hamid: add a docstring public int? Nachkommastelle { get; set; } - [JsonProperty( - PropertyName = "abrechnungsrelevant", - Order = 1019, - Required = Required.Default - )] + [JsonProperty(PropertyName = "abrechnungsrelevant", Order = 1019, Required = Required.Default)] [JsonPropertyName("abrechnungsrelevant")] [NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)] [ProtoMember(1019)] @@ -214,4 +194,4 @@ public class Zaehlwerk : COM public EMobilitaetsart? EMobilitaetsart { get; set; } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/COM/Zaehlzeit.cs b/BO4E/COM/Zaehlzeit.cs index 5ee4e53f..55f3f2e6 100644 --- a/BO4E/COM/Zaehlzeit.cs +++ b/BO4E/COM/Zaehlzeit.cs @@ -1,10 +1,8 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -45,7 +43,11 @@ public class Zaehlzeit : COM /// /// Ermittlung Leistungsmaximum /// - [JsonProperty(PropertyName = "ermittlungLeistungsmaximum", Order = 7, Required = Required.Default)] + [JsonProperty( + PropertyName = "ermittlungLeistungsmaximum", + Order = 7, + Required = Required.Default + )] [JsonPropertyName("ermittlungLeistungsmaximum")] [JsonPropertyOrder(7)] [ProtoMember(7)] @@ -77,4 +79,4 @@ public class Zaehlzeit : COM [JsonPropertyOrder(10)] [ProtoMember(10)] public string? BeschreibungTyp { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Zaehlzeitregister.cs b/BO4E/COM/Zaehlzeitregister.cs index 88382087..cc3e2af1 100644 --- a/BO4E/COM/Zaehlzeitregister.cs +++ b/BO4E/COM/Zaehlzeitregister.cs @@ -1,10 +1,8 @@ +using System.Text.Json.Serialization; using BO4E.ENUM; using BO4E.meta; - using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -41,4 +39,4 @@ public class Zaehlzeitregister : COM [JsonPropertyOrder(6)] [ProtoMember(6)] public Schwachlastfaehig? Schwachlastfaehig { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/COM/Zeitfenster.cs b/BO4E/COM/Zeitfenster.cs index de29aff2..9f83d72b 100644 --- a/BO4E/COM/Zeitfenster.cs +++ b/BO4E/COM/Zeitfenster.cs @@ -1,8 +1,6 @@ using System; using System.Text.Json.Serialization; - using Newtonsoft.Json; - using ProtoBuf; namespace BO4E.COM; @@ -61,7 +59,9 @@ public Zeitfenster(string zeitfensterString) } catch (FormatException) { - throw new ArgumentException("Der Zeitfenster-String muss im Format HHMMHHMM vorliegen und gültige Zeitwerte enthalten."); + throw new ArgumentException( + "Der Zeitfenster-String muss im Format HHMMHHMM vorliegen und gültige Zeitwerte enthalten." + ); } } -} \ No newline at end of file +} diff --git a/BO4E/COM/Zeitraum.cs b/BO4E/COM/Zeitraum.cs index 17968744..b45f0427 100644 --- a/BO4E/COM/Zeitraum.cs +++ b/BO4E/COM/Zeitraum.cs @@ -30,7 +30,6 @@ public class Zeitraum : COM [ProtoMember(4)] public decimal? Dauer { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(5, Name = nameof(Startdatum))] @@ -40,6 +39,7 @@ private DateTime _Startdatum get => Startdatum?.UtcDateTime ?? default; set => Startdatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Gibt Tag und Uhrzeit (falls vorhanden) an, wann der Zeitraum startet. [JsonProperty(PropertyName = "startdatum", Required = Required.Default)] [JsonPropertyName("startdatum")] @@ -48,7 +48,6 @@ private DateTime _Startdatum [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? Startdatum { get; set; } - [System.Text.Json.Serialization.JsonIgnore] [Newtonsoft.Json.JsonIgnore] [ProtoMember(6, Name = nameof(Enddatum))] @@ -58,6 +57,7 @@ private DateTime _Enddatum get => Enddatum?.UtcDateTime ?? default; set => Enddatum = value == default ? null : DateTime.SpecifyKind(value, DateTimeKind.Utc); } + /// Gibt Tag und Uhrzeit (falls vorhanden) an, wann der Zeitraum endet. [JsonProperty(PropertyName = "enddatum", Required = Required.Default)] [JsonPropertyName("enddatum")] @@ -66,7 +66,6 @@ private DateTime _Enddatum [Newtonsoft.Json.JsonConverter(typeof(LenientDateTimeConverter))] public DateTimeOffset? Enddatum { get; set; } - // we disagree with the official bo4e standard that there should be 2xtwo separate properties where one property does contain a date and the other one contains a datetime. // we only want datetimes and we already have them present in start- and enddatum above. They are, to be honest, also not ideal because their name ends with "datum". // To be compatible with libraries that provide a start or end ZEITPUNKT we introduce properties that always hold the same value as their "datum" neighbours. @@ -151,4 +150,4 @@ public void CheckConsistency() }*/ // ToDo: Implement typeconverter for Zeitraum<-->TimeRange -} \ No newline at end of file +} diff --git a/BO4E/COM/Zeitreihenprodukt.cs b/BO4E/COM/Zeitreihenprodukt.cs index 68d8d0b9..de15ae19 100644 --- a/BO4E/COM/Zeitreihenprodukt.cs +++ b/BO4E/COM/Zeitreihenprodukt.cs @@ -1,7 +1,6 @@ +using System.Text.Json.Serialization; using Newtonsoft.Json; - using ProtoBuf; -using System.Text.Json.Serialization; namespace BO4E.COM; @@ -9,9 +8,8 @@ namespace BO4E.COM; [ProtoContract] public class Zeitreihenprodukt : COM { - /// - /// Die OBIS-Kennzahl für das Produkt, die festlegt, welche auf die gemessene Größe mit dem Stand gemeldet wird. + /// Die OBIS-Kennzahl für das Produkt, die festlegt, welche auf die gemessene Größe mit dem Stand gemeldet wird. /// [JsonProperty(PropertyName = "identifikation", Order = 6, Required = Required.Default)] [JsonPropertyName("identifikation")] @@ -35,7 +33,5 @@ public class Zeitreihenprodukt : COM [JsonPropertyOrder(8)] public Verbrauch? Verbrauch { get; set; } - - #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/COM/Zustaendigkeit.cs b/BO4E/COM/Zustaendigkeit.cs index e9286c4e..cb02bb9e 100644 --- a/BO4E/COM/Zustaendigkeit.cs +++ b/BO4E/COM/Zustaendigkeit.cs @@ -27,4 +27,4 @@ public class Zustaendigkeit : COM [JsonPropertyName("themengebiet")] [ProtoMember(5)] public string? Themengebiet { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/ENUM/AbgabeArt.cs b/BO4E/ENUM/AbgabeArt.cs index 55c26df1..140db9d6 100644 --- a/BO4E/ENUM/AbgabeArt.cs +++ b/BO4E/ENUM/AbgabeArt.cs @@ -42,5 +42,5 @@ public enum AbgabeArt /// TSS: Kennzeichnung, dass ein abweichender Preis für Schwachlast angewendet wird [EnumMember(Value = "TSS")] - TSS + TSS, } diff --git a/BO4E/ENUM/Abweichungsgrund.cs b/BO4E/ENUM/Abweichungsgrund.cs index 51fd990f..8a594a6a 100644 --- a/BO4E/ENUM/Abweichungsgrund.cs +++ b/BO4E/ENUM/Abweichungsgrund.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using BO4E.meta; namespace BO4E.ENUM; @@ -132,7 +131,9 @@ public enum Abweichungsgrund /// RECHNUNGSEMPFAENGER_WIDERSPRICHT_DER_STEUERRECHTLICHEN_EINSCHAETZUNG_DES_RECHNUNGSSTELLERS /// Z45 - [EnumMember(Value = "RECHNUNGSEMPFAENGER_WIDERSPRICHT_DER_STEUERRECHTLICHEN_EINSCHAETZUNG_DES_RECHNUNGSSTELLERS")] + [EnumMember( + Value = "RECHNUNGSEMPFAENGER_WIDERSPRICHT_DER_STEUERRECHTLICHEN_EINSCHAETZUNG_DES_RECHNUNGSSTELLERS" + )] RECHNUNGSEMPFAENGER_WIDERSPRICHT_DER_STEUERRECHTLICHEN_EINSCHAETZUNG_DES_RECHNUNGSSTELLERS, /// ANGEGEBENE_QUOTES_AN_MARKTLOKATION_NICHT_VORHANDEN @@ -184,4 +185,4 @@ public enum Abweichungsgrund /// AF2 [EnumMember(Value = "ARTIKELID_FUER_RECHNUNGSTYP_IM_POSITIONSZEITRAUM_NICHT_ZULAESSIG")] ARTIKELID_FUER_RECHNUNGSTYP_IM_POSITIONSZEITRAUM_NICHT_ZULAESSIG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Abwicklungsmodell.cs b/BO4E/ENUM/Abwicklungsmodell.cs index 6bde4b08..92157918 100644 --- a/BO4E/ENUM/Abwicklungsmodell.cs +++ b/BO4E/ENUM/Abwicklungsmodell.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -17,4 +16,4 @@ public enum Abwicklungsmodell /// ZF0 [EnumMember(Value = "MODELL_2")] MODELL_2, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Aggregationsverantwortung.cs b/BO4E/ENUM/Aggregationsverantwortung.cs index 0c52e430..d4014bad 100644 --- a/BO4E/ENUM/Aggregationsverantwortung.cs +++ b/BO4E/ENUM/Aggregationsverantwortung.cs @@ -1,8 +1,7 @@ +using System.Runtime.Serialization; using BO4E.meta; using ProtoBuf; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// Mögliche Qualifier für die Aggregationsverantwortung @@ -17,5 +16,5 @@ public enum Aggregationsverantwortung /// Netzbetreiber [ProtoEnum(Name = nameof(Aggregationsverantwortung) + "_" + nameof(VNB))] [EnumMember(Value = "VNB")] - VNB -} \ No newline at end of file + VNB, +} diff --git a/BO4E/ENUM/Anfragekategorie.cs b/BO4E/ENUM/Anfragekategorie.cs index 7ee39b70..19d530e6 100644 --- a/BO4E/ENUM/Anfragekategorie.cs +++ b/BO4E/ENUM/Anfragekategorie.cs @@ -1,8 +1,7 @@ +using System.Runtime.Serialization; using BO4E.meta; using ProtoBuf; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// @@ -16,7 +15,6 @@ public enum Anfragekategorie [EnumMember(Value = "PROZESSDATENBERICHT")] PROZESSDATENBERICHT, - /// GERAETEUEBERNAHME /// Z10 [EnumMember(Value = "GERAETEUEBERNAHME")] @@ -27,7 +25,6 @@ public enum Anfragekategorie [EnumMember(Value = "WEITERVERPFLICHTUNG_BETRIEB_MELO")] WEITERVERPFLICHTUNG_BETRIEB_MELO, - /// AENDERUNG_MELO /// Z12 [EnumMember(Value = "AENDERUNG_MELO")] @@ -88,6 +85,5 @@ public enum Anfragekategorie /// Z52 [ProtoEnum(Name = "Anfragekategorie_ENTSPERRUNG")] [EnumMember(Value = "ENTSPERRUNG")] - ENTSPERRUNG - -} \ No newline at end of file + ENTSPERRUNG, +} diff --git a/BO4E/ENUM/Anfragetyp.cs b/BO4E/ENUM/Anfragetyp.cs index 5aa816f3..4b6f757d 100644 --- a/BO4E/ENUM/Anfragetyp.cs +++ b/BO4E/ENUM/Anfragetyp.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -74,6 +74,4 @@ public enum Anfragetyp /// Z35 [EnumMember(Value = "ENERGIEMENGE_EINZELWERT")] ENERGIEMENGE_EINZELWERT, - - -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Angebotsstatus.cs b/BO4E/ENUM/Angebotsstatus.cs index 06d02a40..323aaaba 100644 --- a/BO4E/ENUM/Angebotsstatus.cs +++ b/BO4E/ENUM/Angebotsstatus.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -60,5 +59,5 @@ public enum Angebotsstatus /// erledigt /// [EnumMember(Value = "ERLEDIGT")] - ERLEDIGT -} \ No newline at end of file + ERLEDIGT, +} diff --git a/BO4E/ENUM/Anrede.cs b/BO4E/ENUM/Anrede.cs index f000c2bc..3e7aa012 100644 --- a/BO4E/ENUM/Anrede.cs +++ b/BO4E/ENUM/Anrede.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using BO4E.meta; using ProtoBuf; @@ -64,5 +63,5 @@ public enum Anrede [Obsolete("Use BO4E.ENUM.Titel instead", true)] [ProtoEnum(Name = nameof(Anrede) + "_" + "DR")] [EnumMember(Value = "DR")] - DR -} \ No newline at end of file + DR, +} diff --git a/BO4E/ENUM/ArithmetischeOperation.cs b/BO4E/ENUM/ArithmetischeOperation.cs index 906d0e8c..4d67434a 100644 --- a/BO4E/ENUM/ArithmetischeOperation.cs +++ b/BO4E/ENUM/ArithmetischeOperation.cs @@ -34,5 +34,5 @@ public enum ArithmetischeOperation /// Positivwert /// UTILTS SG9 CAV Z83 [EnumMember(Value = "POSITIVWERT")] - POSITIVWERT -} \ No newline at end of file + POSITIVWERT, +} diff --git a/BO4E/ENUM/ArtikelIdTyp.cs b/BO4E/ENUM/ArtikelIdTyp.cs index b4c85d9e..ddabdf1b 100644 --- a/BO4E/ENUM/ArtikelIdTyp.cs +++ b/BO4E/ENUM/ArtikelIdTyp.cs @@ -1,8 +1,7 @@ +using System.Runtime.Serialization; using BO4E.meta; using ProtoBuf; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// Unterscheidung zwischen ArtikelId und GruppenArtikelId @@ -17,5 +16,5 @@ public enum ArtikelIdTyp /// Netzbetreiber [ProtoEnum(Name = nameof(ArtikelIdTyp) + "_" + nameof(GRUPPENARTIKELID))] [EnumMember(Value = "GRUPPENARTIKELID")] - GRUPPENARTIKELID -} \ No newline at end of file + GRUPPENARTIKELID, +} diff --git a/BO4E/ENUM/AufAbschlagstyp.cs b/BO4E/ENUM/AufAbschlagstyp.cs index d8a2d3d7..063a9f58 100644 --- a/BO4E/ENUM/AufAbschlagstyp.cs +++ b/BO4E/ENUM/AufAbschlagstyp.cs @@ -11,5 +11,5 @@ public enum AufAbschlagstyp /// Absoluter AufAbschlag [EnumMember(Value = "ABSOLUT")] - ABSOLUT -} \ No newline at end of file + ABSOLUT, +} diff --git a/BO4E/ENUM/AufAbschlagsziel.cs b/BO4E/ENUM/AufAbschlagsziel.cs index f19cd323..f83cb68f 100644 --- a/BO4E/ENUM/AufAbschlagsziel.cs +++ b/BO4E/ENUM/AufAbschlagsziel.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -30,5 +29,5 @@ public enum AufAbschlagsziel /// Auf/Abschlag auf den Gesamtpreis [ProtoEnum(Name = nameof(AufAbschlagsziel) + "_" + nameof(GESAMTPREIS))] [EnumMember(Value = "GESAMTPREIS")] - GESAMTPREIS -} \ No newline at end of file + GESAMTPREIS, +} diff --git a/BO4E/ENUM/Auftragsstatus.cs b/BO4E/ENUM/Auftragsstatus.cs index 8a89fb12..8a3c3ecb 100644 --- a/BO4E/ENUM/Auftragsstatus.cs +++ b/BO4E/ENUM/Auftragsstatus.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -51,4 +51,4 @@ public enum Auftragsstatus /// EDIFACT DE4405: Z32 [EnumMember(Value = "ABGELEHNT")] ABGELEHNT, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Auftragsstornogrund.cs b/BO4E/ENUM/Auftragsstornogrund.cs index de69c23a..eacb6f0a 100644 --- a/BO4E/ENUM/Auftragsstornogrund.cs +++ b/BO4E/ENUM/Auftragsstornogrund.cs @@ -23,5 +23,5 @@ public enum Auftragsstornogrund /// A03 [EnumMember(Value = "STORNIERUNG_DER_SPERRUNG_BIS_ZUM_VORTAG_ERFOLGT")] - STORNIERUNG_DER_SPERRUNG_BIS_ZUM_VORTAG_ERFOLGT -} \ No newline at end of file + STORNIERUNG_DER_SPERRUNG_BIS_ZUM_VORTAG_ERFOLGT, +} diff --git a/BO4E/ENUM/Ausschreibungsportal.cs b/BO4E/ENUM/Ausschreibungsportal.cs index 7587121c..320089b6 100644 --- a/BO4E/ENUM/Ausschreibungsportal.cs +++ b/BO4E/ENUM/Ausschreibungsportal.cs @@ -43,5 +43,5 @@ public enum Ausschreibungsportal /// dtad.de [EnumMember(Value = "DTAD")] - DTAD -} \ No newline at end of file + DTAD, +} diff --git a/BO4E/ENUM/Ausschreibungsstatus.cs b/BO4E/ENUM/Ausschreibungsstatus.cs index a7c48d14..e2dcfd9b 100644 --- a/BO4E/ENUM/Ausschreibungsstatus.cs +++ b/BO4E/ENUM/Ausschreibungsstatus.cs @@ -19,5 +19,5 @@ public enum Ausschreibungsstatus /// Phase4: Zuschlagserteilung [EnumMember(Value = "PHASE4")] - PHASE4 -} \ No newline at end of file + PHASE4, +} diff --git a/BO4E/ENUM/Ausschreibungstyp.cs b/BO4E/ENUM/Ausschreibungstyp.cs index c4028569..c089980e 100644 --- a/BO4E/ENUM/Ausschreibungstyp.cs +++ b/BO4E/ENUM/Ausschreibungstyp.cs @@ -11,5 +11,5 @@ public enum Ausschreibungstyp /// Europaweit [EnumMember(Value = "EUROPAWEIT")] - EUROPAWEIT -} \ No newline at end of file + EUROPAWEIT, +} diff --git a/BO4E/ENUM/AvisTyp.cs b/BO4E/ENUM/AvisTyp.cs index 6fb96ce7..4a53b568 100644 --- a/BO4E/ENUM/AvisTyp.cs +++ b/BO4E/ENUM/AvisTyp.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -18,4 +18,4 @@ public enum AvisTyp /// 481 [EnumMember(Value = "ZAHLUNGSAVIS")] ZAHLUNGSAVIS, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/BDEWArtikelnummer.cs b/BO4E/ENUM/BDEWArtikelnummer.cs index 6b17a877..c6089c55 100644 --- a/BO4E/ENUM/BDEWArtikelnummer.cs +++ b/BO4E/ENUM/BDEWArtikelnummer.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -143,7 +142,9 @@ public enum BDEWArtikelnummer ENTGELT_MESSUNG_ABLESUNG, /// 9990001000623 - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ENTGELT_EINBAU_BETRIEB_WARTUNG_MESSTECHNIK))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ENTGELT_EINBAU_BETRIEB_WARTUNG_MESSTECHNIK) + )] [EnumMember(Value = "ENTGELT_EINBAU_BETRIEB_WARTUNG_MESSTECHNIK")] ENTGELT_EINBAU_BETRIEB_WARTUNG_MESSTECHNIK, @@ -242,37 +243,49 @@ public enum BDEWArtikelnummer /// 9990001000813 /// Zusatzdienstleistung nach § 35 Abs. 2 Nr. 1 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_1_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_1_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_1_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_1_MSBG, /// 9990001000821 /// Zusatzdienstleistung nach § 35 Abs. 2 Nr. 2 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_2_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_2_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_2_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_2_MSBG, /// 9990001000839 /// Zusatzdienstleistung nach § 35 Abs. 2 Nr. 3 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_3_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_3_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_3_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_3_MSBG, /// 9990001000847 /// Zusatzdienstleistung nach § 35 Abs. 2 Nr. 4 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_4_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_4_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_4_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_4_MSBG, /// 9990001000855 /// Zusatzdienstleistung nach § 35 Abs. 2 Nr. 5 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_5_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_5_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_5_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_2_5_MSBG, /// 9990001000863 /// Zusatzdienstleistung nach § 35 Abs. 3 MsbG - [ProtoEnum(Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_3_MSBG))] + [ProtoEnum( + Name = nameof(BDEWArtikelnummer) + "_" + nameof(ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_3_MSBG) + )] [EnumMember(Value = "ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_3_MSBG")] ZUSATZDIENSTLEISTUNG_PARAGRAPH_35_3_MSBG, } diff --git a/BO4E/ENUM/Bearbeitungsstatus.cs b/BO4E/ENUM/Bearbeitungsstatus.cs index d672308d..4867b4ae 100644 --- a/BO4E/ENUM/Bearbeitungsstatus.cs +++ b/BO4E/ENUM/Bearbeitungsstatus.cs @@ -41,5 +41,5 @@ public enum Bearbeitungsstatus /// Benachrichtigung ist auf Wunsch des Users standardmäßig ausgeblendet. /// [EnumMember(Value = "IGNORIERT")] - IGNORIERT -} \ No newline at end of file + IGNORIERT, +} diff --git a/BO4E/ENUM/Befestigungsart.cs b/BO4E/ENUM/Befestigungsart.cs index 3178fb01..8517ca3f 100644 --- a/BO4E/ENUM/Befestigungsart.cs +++ b/BO4E/ENUM/Befestigungsart.cs @@ -23,5 +23,5 @@ public enum Befestigungsart /// Z32 [EnumMember(Value = "ZWEISTUTZEN")] - ZWEISTUTZEN -} \ No newline at end of file + ZWEISTUTZEN, +} diff --git a/BO4E/ENUM/Bemessungsgroesse.cs b/BO4E/ENUM/Bemessungsgroesse.cs index 9ad6a9f1..3201cdc8 100644 --- a/BO4E/ENUM/Bemessungsgroesse.cs +++ b/BO4E/ENUM/Bemessungsgroesse.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -65,5 +64,5 @@ public enum Bemessungsgroesse /// Darstellung einer Stückzahl [ProtoEnum(Name = nameof(Bemessungsgroesse) + "_" + nameof(ANZAHL))] [EnumMember(Value = "ANZAHL")] - ANZAHL -} \ No newline at end of file + ANZAHL, +} diff --git a/BO4E/ENUM/BerechnungsformelAblehngrund.cs b/BO4E/ENUM/BerechnungsformelAblehngrund.cs index 7cda9d53..5509913c 100644 --- a/BO4E/ENUM/BerechnungsformelAblehngrund.cs +++ b/BO4E/ENUM/BerechnungsformelAblehngrund.cs @@ -41,5 +41,5 @@ public enum BerechnungsformelAblehngrund /// Der Marktlokation ist nicht genau eine Messlokation zugeordnet /// E_0218: A10 [EnumMember(Value = "MARKTLOKATION_IST_NICHT_GENAU_DER_MESSLOKATION_ZUGEORDNET")] - MARKTLOKATION_IST_NICHT_GENAU_DER_MESSLOKATION_ZUGEORDNET -} \ No newline at end of file + MARKTLOKATION_IST_NICHT_GENAU_DER_MESSLOKATION_ZUGEORDNET, +} diff --git a/BO4E/ENUM/BerechnungsformelNotwendigkeit.cs b/BO4E/ENUM/BerechnungsformelNotwendigkeit.cs index 5f9771f1..d400ea10 100644 --- a/BO4E/ENUM/BerechnungsformelNotwendigkeit.cs +++ b/BO4E/ENUM/BerechnungsformelNotwendigkeit.cs @@ -14,21 +14,24 @@ public enum BerechnungsformelNotwendigkeit /// Z33 [EnumMember(Value = "BERECHNUNGSFORMEL_NOTWENDIG")] BERECHNUNGSFORMEL_NOTWENDIG, + /// /// Berechnungsformel muss beim Absender angefragt werden /// /// Z34 [EnumMember(Value = "BERECHNUNGSFORMEL_MUSS_ANGEFRAGT_WERDEN")] BERECHNUNGSFORMEL_MUSS_ANGEFRAGT_WERDEN, + /// /// Berechnungsformel besitzt keine Rechenoperation /// /// Z40 [EnumMember(Value = "BERECHNUNGSFORMEL_TRIVIAL")] BERECHNUNGSFORMEL_TRIVIAL, + /// /// Berechnungsformel ist nicht erforderlich /// [EnumMember(Value = "BERECHNUNGSFORMEL_NICHT_NOTWENDIG")] BERECHNUNGSFORMEL_NICHT_NOTWENDIG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/BerichtStatus.cs b/BO4E/ENUM/BerichtStatus.cs index 23885194..64cc7a41 100644 --- a/BO4E/ENUM/BerichtStatus.cs +++ b/BO4E/ENUM/BerichtStatus.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -17,5 +16,5 @@ public enum BerichtStatus /// Fehler im Bericht [ProtoEnum(Name = "BerichtStatus_FEHLER")] [EnumMember(Value = "FEHLER")] - FEHLER -} \ No newline at end of file + FEHLER, +} diff --git a/BO4E/ENUM/Betriebszustand.cs b/BO4E/ENUM/Betriebszustand.cs index fa677453..6e49ea71 100644 --- a/BO4E/ENUM/Betriebszustand.cs +++ b/BO4E/ENUM/Betriebszustand.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -20,5 +19,5 @@ public enum Betriebszustand /// ZC3 [ProtoEnum(Name = nameof(Betriebszustand) + "_" + nameof(REGELBETRIEB))] [EnumMember(Value = "REGELBETRIEB")] - REGELBETRIEB -} \ No newline at end of file + REGELBETRIEB, +} diff --git a/BO4E/ENUM/BezeichnungSummenzeitreihe.cs b/BO4E/ENUM/BezeichnungSummenzeitreihe.cs index a264cd2a..98dd5d19 100644 --- a/BO4E/ENUM/BezeichnungSummenzeitreihe.cs +++ b/BO4E/ENUM/BezeichnungSummenzeitreihe.cs @@ -1,9 +1,7 @@ +using System.Runtime.Serialization; using BO4E.meta; - using ProtoBuf; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// Mögliche Qualifier für die Aggregationsverantwortung @@ -19,44 +17,54 @@ public enum BezeichnungSummenzeitreihe [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(BG_SZR_C))] [EnumMember(Value = "BG_SZR_C")] BG_SZR_C, + /// BK-SZR Kategorie A (Z97) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(BK_SZR_A))] [EnumMember(Value = "BK_SZR_A")] BK_SZR_A, + /// BK-SZR Kategorie B Ebene Regelzone (Z98) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(BK_SZR_B_RZ))] [EnumMember(Value = "BK_SZR_B_RZ")] BK_SZR_B_RZ, + /// BK-SZR Kategorie B Ebene Bilanzierungsgebiet (Z99) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(BK_SZR_B_BG))] [EnumMember(Value = "BK_SZR_B_BG")] BK_SZR_B_BG, + /// BK-SZR Kategorie C (ZA0) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(BK_SZR_C))] [EnumMember(Value = "BK_SZR_C")] BK_SZR_C, + /// LF-SZR Kategorie A (ZA1) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(LF_SZR_A))] [EnumMember(Value = "LF_SZR_A")] LF_SZR_A, + /// LF-SZR Kategorie B Ebene Regelzone (ZA2) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(LF_SZR_B_RZ))] [EnumMember(Value = "LF_SZR_B_RZ")] LF_SZR_B_RZ, + /// LF-SZR Kategorie B Ebene Bilanzierungsgebiet (ZA3) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(LF_SZR_B_BG))] [EnumMember(Value = "LF_SZR_B_BG")] LF_SZR_B_BG, + /// Deltazeitreihe (ZA4) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(DZUE))] [EnumMember(Value = "DZUE")] DZUE, + /// Netzzeitreihe (ZA5) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(NZR))] [EnumMember(Value = "NZR")] NZR, + /// Abrechnungssummenzeitreih (ZA6) [ProtoEnum(Name = nameof(BezeichnungSummenzeitreihe) + "_" + nameof(ASZR))] [EnumMember(Value = "ASZR")] - ASZR -} \ No newline at end of file + ASZR, +} diff --git a/BO4E/ENUM/Bilanzierungsmethode.cs b/BO4E/ENUM/Bilanzierungsmethode.cs index 426d4d6c..49b179e2 100644 --- a/BO4E/ENUM/Bilanzierungsmethode.cs +++ b/BO4E/ENUM/Bilanzierungsmethode.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -37,5 +36,5 @@ public enum Bilanzierungsmethode /// [ProtoEnum(Name = nameof(Bilanzierungsmethode) + "_" + nameof(IMS))] [EnumMember(Value = "IMS")] - IMS -} \ No newline at end of file + IMS, +} diff --git a/BO4E/ENUM/BoTyp.cs b/BO4E/ENUM/BoTyp.cs index e8d895b8..f40796fc 100644 --- a/BO4E/ENUM/BoTyp.cs +++ b/BO4E/ENUM/BoTyp.cs @@ -87,5 +87,5 @@ public enum BoTyp /// 1 [EnumMember(Value = "ANFRAGE")] - ANFRAGE -} \ No newline at end of file + ANFRAGE, +} diff --git a/BO4E/ENUM/DefinitionenNotwendigkeit.cs b/BO4E/ENUM/DefinitionenNotwendigkeit.cs index 4e005727..1d48694a 100644 --- a/BO4E/ENUM/DefinitionenNotwendigkeit.cs +++ b/BO4E/ENUM/DefinitionenNotwendigkeit.cs @@ -9,11 +9,12 @@ namespace BO4E.ENUM; public enum DefinitionenNotwendigkeit { /// - /// Zählzeitdefinitionen werden verwendet + /// Zählzeitdefinitionen werden verwendet /// /// Z02 [EnumMember(Value = "ZAEHLZEITDEFINITIONEN_WERDEN_VERWENDET")] ZAEHLZEITDEFINITIONEN_WERDEN_VERWENDET, + /// /// Zählzeitdefinitionen werden nicht verwendet /// @@ -22,15 +23,16 @@ public enum DefinitionenNotwendigkeit ZAEHLZEITDEFINITIONEN_WERDEN_NICHT_VERWENDET, /// - /// Definitionen werden verwendet + /// Definitionen werden verwendet /// /// Z45 [EnumMember(Value = "DEFINITIONEN_WERDEN_VERWENDET")] DEFINITIONEN_WERDEN_VERWENDET, + /// /// Definitionen werden nicht verwendet /// /// Z46 [EnumMember(Value = "DEFINITIONEN_WERDEN_NICHT_VERWENDET")] DEFINITIONEN_WERDEN_NICHT_VERWENDET, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Dienstleistungstyp.cs b/BO4E/ENUM/Dienstleistungstyp.cs index 0e3d1c7d..3b6a3442 100644 --- a/BO4E/ENUM/Dienstleistungstyp.cs +++ b/BO4E/ENUM/Dienstleistungstyp.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -28,7 +27,9 @@ public enum Dienstleistungstyp DATENBEREITSTELLUNG_JAEHRLICH, /// Datenbereitstellung historischer Lastgänge - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_HISTORISCHE_LG))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_HISTORISCHE_LG) + )] [EnumMember(Value = "DATENBEREITSTELLUNG_HISTORISCHE_LG")] DATENBEREITSTELLUNG_HISTORISCHE_LG, @@ -38,7 +39,9 @@ public enum Dienstleistungstyp DATENBEREITSTELLUNG_STUENDLICH, /// Datenbereitstellung vierteljährlich - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_VIERTELJAEHRLICH))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_VIERTELJAEHRLICH) + )] [EnumMember(Value = "DATENBEREITSTELLUNG_VIERTELJAEHRLICH")] DATENBEREITSTELLUNG_VIERTELJAEHRLICH, @@ -48,7 +51,9 @@ public enum Dienstleistungstyp DATENBEREITSTELLUNG_HALBJAEHRLICH, /// Datenbereitstellung monatlich zusätzlich - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_MONATLICH_ZUSAETZLICH))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(DATENBEREITSTELLUNG_MONATLICH_ZUSAETZLICH) + )] [EnumMember(Value = "DATENBEREITSTELLUNG_MONATLICH_ZUSAETZLICH")] DATENBEREITSTELLUNG_MONATLICH_ZUSAETZLICH, @@ -58,7 +63,9 @@ public enum Dienstleistungstyp DATENBEREITSTELLUNG_EINMALIG, /// Auslesung 2x täglich mittels Fernauslesung - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_2X_TAEGLICH_FERNAUSLESUNG))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_2X_TAEGLICH_FERNAUSLESUNG) + )] [EnumMember(Value = "AUSLESUNG_2X_TAEGLICH_FERNAUSLESUNG")] AUSLESUNG_2X_TAEGLICH_FERNAUSLESUNG, @@ -73,12 +80,16 @@ public enum Dienstleistungstyp AUSLESUNG_LGK_MANUELL_MSB, /// Auslesung monatlich bei SLP mittels Fernauslesung - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_MONATLICH_SLP_FERNAUSLESUNG))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_MONATLICH_SLP_FERNAUSLESUNG) + )] [EnumMember(Value = "AUSLESUNG_MONATLICH_SLP_FERNAUSLESUNG")] AUSLESUNG_MONATLICH_SLP_FERNAUSLESUNG, /// Auslesung jährlich bei SLP mittels Fernauslesung - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_JAEHRLICH_SLP_FERNAUSLESUNG))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_JAEHRLICH_SLP_FERNAUSLESUNG) + )] [EnumMember(Value = "AUSLESUNG_JAEHRLICH_SLP_FERNAUSLESUNG")] AUSLESUNG_JAEHRLICH_SLP_FERNAUSLESUNG, @@ -123,7 +134,11 @@ public enum Dienstleistungstyp ABLESUNG_SLP_ZUSAETZLICH_KUNDE, /// Auslesung mittels Fernauslesung, zusätzlich vom Messstellenbetreiber vorgenommen - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_LGK_FERNAUSLESUNG_ZUSAETZLICH_MSB))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + + "_" + + nameof(AUSLESUNG_LGK_FERNAUSLESUNG_ZUSAETZLICH_MSB) + )] [EnumMember(Value = "AUSLESUNG_LGK_FERNAUSLESUNG_ZUSAETZLICH_MSB")] AUSLESUNG_LGK_FERNAUSLESUNG_ZUSAETZLICH_MSB, @@ -133,7 +148,9 @@ public enum Dienstleistungstyp AUSLESUNG_MOATLICH_FERNAUSLESUNG, /// Auslesung stündlich mittels Fernauslesung - [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_STUENDLICH_FERNAUSLESUNG))] + [ProtoEnum( + Name = nameof(Dienstleistungstyp) + "_" + nameof(AUSLESUNG_STUENDLICH_FERNAUSLESUNG) + )] [EnumMember(Value = "AUSLESUNG_STUENDLICH_FERNAUSLESUNG")] AUSLESUNG_STUENDLICH_FERNAUSLESUNG, @@ -200,5 +217,5 @@ public enum Dienstleistungstyp /// Inkassokosten [ProtoEnum(Name = nameof(Dienstleistungstyp) + "_" + nameof(INKASSOKOSTEN))] [EnumMember(Value = "INKASSOKOSTEN")] - INKASSOKOSTEN -} \ No newline at end of file + INKASSOKOSTEN, +} diff --git a/BO4E/ENUM/EEGVermarktungsform.cs b/BO4E/ENUM/EEGVermarktungsform.cs index f8453eba..e296fae9 100644 --- a/BO4E/ENUM/EEGVermarktungsform.cs +++ b/BO4E/ENUM/EEGVermarktungsform.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -32,5 +31,5 @@ public enum EEGVermarktungsform /// Z94 [ProtoEnum(Name = nameof(EEGVermarktungsform) + "_" + nameof(KWKG_VERGUETUNG))] [EnumMember(Value = "KWKG_VERGUETUNG")] - KWKG_VERGUETUNG -} \ No newline at end of file + KWKG_VERGUETUNG, +} diff --git a/BO4E/ENUM/EMobilitaetsart.cs b/BO4E/ENUM/EMobilitaetsart.cs index 4109a5b8..c0b14395 100644 --- a/BO4E/ENUM/EMobilitaetsart.cs +++ b/BO4E/ENUM/EMobilitaetsart.cs @@ -16,4 +16,4 @@ public enum EMobilitaetsart /// ZE7: Ladepark [EnumMember(Value = "LADEPARK")] LADEPARK, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Energieflussrichtung.cs b/BO4E/ENUM/Energieflussrichtung.cs index 310a0623..e47691a0 100644 --- a/BO4E/ENUM/Energieflussrichtung.cs +++ b/BO4E/ENUM/Energieflussrichtung.cs @@ -18,4 +18,4 @@ public enum Energieflussrichtung /// [EnumMember(Value = "ERZEUGUNG")] ERZEUGUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Energierichtung.cs b/BO4E/ENUM/Energierichtung.cs index 5d1195d4..9b721869 100644 --- a/BO4E/ENUM/Energierichtung.cs +++ b/BO4E/ENUM/Energierichtung.cs @@ -13,5 +13,5 @@ public enum Energierichtung /// Einspeisung /// UTILTS DE7037 Z06: Erzeugung [EnumMember(Value = "EINSP")] - EINSP -} \ No newline at end of file + EINSP, +} diff --git a/BO4E/ENUM/ErmittlungLeistungsmaximum.cs b/BO4E/ENUM/ErmittlungLeistungsmaximum.cs index b83207bd..e2b63fdd 100644 --- a/BO4E/ENUM/ErmittlungLeistungsmaximum.cs +++ b/BO4E/ENUM/ErmittlungLeistungsmaximum.cs @@ -11,5 +11,5 @@ public enum ErmittlungLeistungsmaximum /// keine Verwendung des Hochlastzeitfensters [EnumMember(Value = "KEINE_VERWENDUNG_HOCHLASTFENSTER")] - KEINE_VERWENDUNG_HOCHLASTFENSTER -} \ No newline at end of file + KEINE_VERWENDUNG_HOCHLASTFENSTER, +} diff --git a/BO4E/ENUM/Erzeugungsart.cs b/BO4E/ENUM/Erzeugungsart.cs index 84e8cdef..036ffa8d 100644 --- a/BO4E/ENUM/Erzeugungsart.cs +++ b/BO4E/ENUM/Erzeugungsart.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -60,5 +59,5 @@ public enum Erzeugungsart /// Sonstige nach EEG [ProtoEnum(Name = nameof(Erzeugungsart) + "_" + nameof(SONSTIGE_EEG))] [EnumMember(Value = "SONSTIGE_EEG")] - SONSTIGE_EEG -} \ No newline at end of file + SONSTIGE_EEG, +} diff --git a/BO4E/ENUM/Fallgruppenzuordnung.cs b/BO4E/ENUM/Fallgruppenzuordnung.cs index 5d40163b..7884ccb5 100644 --- a/BO4E/ENUM/Fallgruppenzuordnung.cs +++ b/BO4E/ENUM/Fallgruppenzuordnung.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -10,10 +10,12 @@ public enum Fallgruppenzuordnung /// RLM mit Tagesband [EnumMember(Value = "GABI_RLMmT")] GABI_RLMmT, + /// RLM ohne Tagesband [EnumMember(Value = "GABI_RLMoT")] GABI_RLMoT, + /// RLM im Nominierungsersatzverfahren [EnumMember(Value = "GABI_RLMNEV")] - GABI_RLMNEV -} \ No newline at end of file + GABI_RLMNEV, +} diff --git a/BO4E/ENUM/FehlerCode.cs b/BO4E/ENUM/FehlerCode.cs index d693bf1e..a43a3cd9 100644 --- a/BO4E/ENUM/FehlerCode.cs +++ b/BO4E/ENUM/FehlerCode.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -12,185 +11,221 @@ public enum FehlerCode /// [EnumMember(Value = "ID_UNBEKANNT")] ID_UNBEKANNT, + /// /// Absender zum Zeitpunkt nicht zugeordnet /// [EnumMember(Value = "ABSENDER_NICHT_ZUGEORDNET")] ABSENDER_NICHT_ZUGEORDNET, + /// /// Empfaenger zum Zeitpunkt nicht zugeordnet /// [EnumMember(Value = "EMPFAENGER_NICHT_ZUGEORDNET")] EMPFAENGER_NICHT_ZUGEORDNET, + /// /// Geraet in Messlokation nicht bekannt /// [EnumMember(Value = "GERAET_UNBEKANNT")] GERAET_UNBEKANNT, + /// /// Obis-Kennzahl in Meldepunkt/Tranche nicht bekannt /// [EnumMember(Value = "OBIS_UNBEKANNT")] OBIS_UNBEKANNT, + /// /// Fehlerhafte Referenzierung /// [EnumMember(Value = "REFERENZIERUNG_FEHLERHAFT")] REFERENZIERUNG_FEHLERHAFT, + /// /// Zuodnungstupel unbekannt /// [EnumMember(Value = "TUPEL_UNBEKANNT")] TUPEL_UNBEKANNT, + /// /// Absender zum Zeitpunkt dem Tupel nicht zugeordnet /// [EnumMember(Value = "ABSENDER_TUPEL_NICHT_ZUGEORDNET")] ABSENDER_TUPEL_NICHT_ZUGEORDNET, + /// /// Empfaenger zum Zeitpunkt dem Tupel nicht zugeordnet /// [EnumMember(Value = "EMPFAENGER_TUPEL_NICHT_ZUGEORDNET")] EMPFAENGER_TUPEL_NICHT_ZUGEORDNET, + /// /// Vorkommastellen zu lang /// [EnumMember(Value = "VORKOMMA_ZU_VIELE_STELLEN")] VORKOMMA_ZU_VIELE_STELLEN, + /// /// Zeitreihe ist unvollständig /// [EnumMember(Value = "ZEITREIHE_UNVOLLSTAENDIG")] ZEITREIHE_UNVOLLSTAENDIG, + /// /// Referenziertes Tupel ist unbekannt /// [EnumMember(Value = "REFERENZIERTES_TUPEL_UNBEKANNT")] REFERENZIERTES_TUPEL_UNBEKANNT, + /// /// Marktlokation nicht gefunden /// [EnumMember(Value = "MARKTLOKATION_UNBEKANNT")] MARKTLOKATION_UNBEKANNT, + /// /// Messlokation nicht gefunden /// [EnumMember(Value = "MESSLOKATION_UNBEKANNT")] MESSLOKATION_UNBEKANNT, + /// /// Meldepunkt nicht mehr im Netzgebiet /// [EnumMember(Value = "MELDEPUNKT_NICHT_MEHR_IM_NETZ")] MELDEPUNKT_NICHT_MEHR_IM_NETZ, + /// /// Pflichtfeld nicht gefüllt /// [EnumMember(Value = "ERFORDERLICHE_ANGABE_FEHLT")] ERFORDERLICHE_ANGABE_FEHLT, + /// /// Geschaeftsvorfall wurde zurückgewiesen /// [EnumMember(Value = "GESCHAEFTSVORFALL_ZURUECKGEWIESEN")] GESCHAEFTSVORFALL_ZURUECKGEWIESEN, + /// /// Zeitintervall ist negativ oder null /// [EnumMember(Value = "ZEITINTERVALL_NEGATIV")] ZEITINTERVALL_NEGATIV, + /// /// Formatvorgaben wurden nicht eingehalten /// [EnumMember(Value = "FORMAT_NICHT_EINGEHALTEN")] FORMAT_NICHT_EINGEHALTEN, + /// /// Geschaeftsvorfall darf vom Absender nicht benutzt werden /// [EnumMember(Value = "GESCHAEFTSVORFALL_ABSENDER")] GESCHAEFTSVORFALL_ABSENDER, + /// /// Konfigurations-ID zum angegebenen Zeitpunkt nicht bekannt /// [EnumMember(Value = "KONFIGURATIONSID_UNBEKANNT")] KONFIGURATIONSID_UNBEKANNT, + /// /// Maximale Segmentwiederholung überschritten /// [EnumMember(Value = "SEGMENTWIEDERHOLUNG_UEBERSCHRITTEN")] SEGMENTWIEDERHOLUNG_UEBERSCHRITTEN, + /// /// Anzahl der Codes überschreitet Paketdefinition /// [EnumMember(Value = "ANZAHLCODES_UEBERSCHRITTEN")] ANZAHLCODES_UEBERSCHRITTEN, + /// /// Zeitangabe unplausibel /// [EnumMember(Value = "ZEITANGABE_UNPLAUSIBEL")] ZEITANGABE_UNPLAUSIBEL, + /// /// Syntaxversion nicht unterstützt /// [EnumMember(Value = "SYNTAXVERSION_NICHT_UNTERSTUETZT")] SYNTAXVERSION_NICHT_UNTERSTUETZT, + /// /// Falscher Empfänger /// [EnumMember(Value = "FALSCHER_EMPFAENGER")] FALSCHER_EMPFAENGER, + /// /// Ungültiger Wert /// [EnumMember(Value = "WERT_UNGUELTIG")] WERT_UNGUELTIG, + /// /// Wert fehlt /// [EnumMember(Value = "WERT_FEHLT")] WERT_FEHLT, + /// /// Zu viele Werte /// [EnumMember(Value = "WERT_UEBERFLUESSIG")] WERT_UEBERFLUESSIG, + /// /// Falsches Service-Zeichen /// [EnumMember(Value = "BEGRENZER_UNPLAUSIBEL")] BEGRENZER_UNPLAUSIBEL, + /// /// Zeichen unplausibel /// [EnumMember(Value = "ZEICHEN_UNPLAUSIBEL")] ZEICHEN_UNPLAUSIBEL, + /// /// Absender unbekannt /// [EnumMember(Value = "ABSENDER_UNBEKANNT")] ABSENDER_UNBEKANNT, + /// /// Testkennzeichen nicht unterstützt /// [EnumMember(Value = "TESTKENNZEICHEN_UNPLAUSIBEL")] TESTKENNZEICHEN_UNPLAUSIBEL, + /// /// Duplikat /// [EnumMember(Value = "DUPLIKAT")] [ProtoEnum(Name = "FehlerCode_" + nameof(DUPLIKAT))] DUPLIKAT, + /// /// Kontrollzähler unplausibel /// [EnumMember(Value = "KONTROLLZAEHLER_UNPLAUSIBEL")] KONTROLLZAEHLER_UNPLAUSIBEL, + /// /// Wert zu lang /// [EnumMember(Value = "WERT_ZU_LANG")] WERT_ZU_LANG, + /// /// Zu viele Wiederholungen /// [EnumMember(Value = "WIEDERHOLUNG_UNPLAUSIBEL")] WIEDERHOLUNG_UNPLAUSIBEL, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/FehlerTyp.cs b/BO4E/ENUM/FehlerTyp.cs index 73293e3e..92a51b69 100644 --- a/BO4E/ENUM/FehlerTyp.cs +++ b/BO4E/ENUM/FehlerTyp.cs @@ -13,5 +13,5 @@ public enum FehlerTyp /// Fehler in der Verarbeitung [EnumMember(Value = "VERARBEITUNG")] - VERARBEITUNG -} \ No newline at end of file + VERARBEITUNG, +} diff --git a/BO4E/ENUM/Fernschaltung.cs b/BO4E/ENUM/Fernschaltung.cs index 7b1f6d77..39496cf6 100644 --- a/BO4E/ENUM/Fernschaltung.cs +++ b/BO4E/ENUM/Fernschaltung.cs @@ -11,5 +11,5 @@ public enum Fernschaltung /// Z07: nicht vorhanden [EnumMember(Value = "NICHT_VORHANDEN")] - NICHT_VORHANDEN -} \ No newline at end of file + NICHT_VORHANDEN, +} diff --git a/BO4E/ENUM/FernsteuerbarkeitStatus.cs b/BO4E/ENUM/FernsteuerbarkeitStatus.cs index 5384c064..b37551a3 100644 --- a/BO4E/ENUM/FernsteuerbarkeitStatus.cs +++ b/BO4E/ENUM/FernsteuerbarkeitStatus.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -35,5 +34,5 @@ public enum FernsteuerbarkeitStatus /// Z98 [ProtoEnum(Name = nameof(FernsteuerbarkeitStatus) + "_" + nameof(LIEFERANT_FERNSTEUERBAR))] [EnumMember(Value = "LIEFERANT_FERNSTEUERBAR")] - LIEFERANT_FERNSTEUERBAR -} \ No newline at end of file + LIEFERANT_FERNSTEUERBAR, +} diff --git a/BO4E/ENUM/Gasqualitaet.cs b/BO4E/ENUM/Gasqualitaet.cs index 93d1921c..c016bc5c 100644 --- a/BO4E/ENUM/Gasqualitaet.cs +++ b/BO4E/ENUM/Gasqualitaet.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -8,7 +7,9 @@ namespace BO4E.ENUM; /// Unterscheidung für hoch- und niedrig-kalorisches Gas. public enum Gasqualitaet { - [Obsolete("This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it")] + [Obsolete( + "This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it" + )] #pragma warning disable CS0618 // Type or member is obsolete [ProtoEnum(Name = nameof(Gasqualitaet) + "_" + nameof(ZERO))] #pragma warning restore CS0618 // Type or member is obsolete diff --git a/BO4E/ENUM/Gebiettyp.cs b/BO4E/ENUM/Gebiettyp.cs index 100611c0..436ce28c 100644 --- a/BO4E/ENUM/Gebiettyp.cs +++ b/BO4E/ENUM/Gebiettyp.cs @@ -39,5 +39,5 @@ public enum Gebiettyp /// Versorgungsgebiet [EnumMember(Value = "VERSORGUNGSGEBIET")] - VERSORGUNGSGEBIET -} \ No newline at end of file + VERSORGUNGSGEBIET, +} diff --git a/BO4E/ENUM/Geraeteart.cs b/BO4E/ENUM/Geraeteart.cs index 5afae6a3..617548f4 100644 --- a/BO4E/ENUM/Geraeteart.cs +++ b/BO4E/ENUM/Geraeteart.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -11,29 +10,34 @@ public enum Geraeteart [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(WANDLER))] [EnumMember(Value = "WANDLER")] WANDLER, + /// Kommunikationseinrichtung [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(KOMMUNIKATIONSEINRICHTUNG))] [EnumMember(Value = "KOMMUNIKATIONSEINRICHTUNG")] KOMMUNIKATIONSEINRICHTUNG, + /// Technische Steuereinrichtung [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(TECHNISCHE_STEUEREINRICHTUNG))] [EnumMember(Value = "TECHNISCHE_STEUEREINRICHTUNG")] TECHNISCHE_STEUEREINRICHTUNG, + /// Mengenumwerter [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(MENGENUMWERTER))] [EnumMember(Value = "MENGENUMWERTER")] MENGENUMWERTER, + /// Smartmeter-Gateway [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(SMARTMETER_GATEWAY))] [EnumMember(Value = "SMARTMETER_GATEWAY")] SMARTMETER_GATEWAY, + /// Steuerbox [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(STEUERBOX))] [EnumMember(Value = "STEUERBOX")] STEUERBOX, + /// Zaehleinrichtung [ProtoEnum(Name = nameof(Geraeteart) + "_" + nameof(ZAEHLEINRICHTUNG))] [EnumMember(Value = "ZAEHLEINRICHTUNG")] - ZAEHLEINRICHTUNG - -} \ No newline at end of file + ZAEHLEINRICHTUNG, +} diff --git a/BO4E/ENUM/Geraetemerkmal.cs b/BO4E/ENUM/Geraetemerkmal.cs index c84dbc0e..cef27c08 100644 --- a/BO4E/ENUM/Geraetemerkmal.cs +++ b/BO4E/ENUM/Geraetemerkmal.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -440,4 +439,4 @@ public enum Geraetemerkmal [ProtoEnum(Name = nameof(Geraetemerkmal) + "_" + nameof(GAS_G16000))] [EnumMember(Value = "GAS_G16000")] GAS_G16000, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Geraetetyp.cs b/BO4E/ENUM/Geraetetyp.cs index 49deb451..487d9dac 100644 --- a/BO4E/ENUM/Geraetetyp.cs +++ b/BO4E/ENUM/Geraetetyp.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -229,4 +228,4 @@ public enum Geraetetyp [ProtoEnum(Name = nameof(Geraetetyp) + "_" + nameof(KOMBIMESSWANDLER))] [EnumMember(Value = "KOMBIMESSWANDLER")] KOMBIMESSWANDLER, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Geschaeftspartnerrolle.cs b/BO4E/ENUM/Geschaeftspartnerrolle.cs index 521531cc..3564589e 100644 --- a/BO4E/ENUM/Geschaeftspartnerrolle.cs +++ b/BO4E/ENUM/Geschaeftspartnerrolle.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/GrundDerPrivilegierungNachEnFG.cs b/BO4E/ENUM/GrundDerPrivilegierungNachEnFG.cs index f60df06e..5fa804a0 100644 --- a/BO4E/ENUM/GrundDerPrivilegierungNachEnFG.cs +++ b/BO4E/ENUM/GrundDerPrivilegierungNachEnFG.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using BO4E.meta; namespace BO4E.ENUM; @@ -54,4 +53,4 @@ public enum GrundDerPrivilegierungNachEnFG /// ZV3 [EnumMember(Value = "LANDSTROMANLAGEN")] LANDSTROMANLAGEN, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/GrundlageZurVerringerungDerUmlagenNachEnfg.cs b/BO4E/ENUM/GrundlageZurVerringerungDerUmlagenNachEnfg.cs index 44c7c22e..943e9903 100644 --- a/BO4E/ENUM/GrundlageZurVerringerungDerUmlagenNachEnfg.cs +++ b/BO4E/ENUM/GrundlageZurVerringerungDerUmlagenNachEnfg.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -23,4 +23,4 @@ public enum GrundlageZurVerringerungDerUmlagenNachEnfg /// ZG1 [EnumMember(Value = "KEINE_ANGABE")] KEINE_ANGABE, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Gueltigkeitstyp.cs b/BO4E/ENUM/Gueltigkeitstyp.cs index c0f3e844..5bdb1736 100644 --- a/BO4E/ENUM/Gueltigkeitstyp.cs +++ b/BO4E/ENUM/Gueltigkeitstyp.cs @@ -7,5 +7,5 @@ public enum Gueltigkeitstyp { /// Ein so eingeschränktes Merkmal gilt nicht mit den angegebenen Werten [EnumMember(Value = "NICHT_IN")] - NICHT_IN -} \ No newline at end of file + NICHT_IN, +} diff --git a/BO4E/ENUM/HaeufigkeitZaehlzeit.cs b/BO4E/ENUM/HaeufigkeitZaehlzeit.cs index fb076e0e..2faeeb79 100644 --- a/BO4E/ENUM/HaeufigkeitZaehlzeit.cs +++ b/BO4E/ENUM/HaeufigkeitZaehlzeit.cs @@ -11,5 +11,5 @@ public enum HaeufigkeitZaehlzeit /// Jährlich [EnumMember(Value = "JAEHRLICH")] - JAEHRLICH -} \ No newline at end of file + JAEHRLICH, +} diff --git a/BO4E/ENUM/Handelsunstimmigkeitsgrund.cs b/BO4E/ENUM/Handelsunstimmigkeitsgrund.cs index d7ee4819..1f30a6d8 100644 --- a/BO4E/ENUM/Handelsunstimmigkeitsgrund.cs +++ b/BO4E/ENUM/Handelsunstimmigkeitsgrund.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -84,4 +83,4 @@ public enum Handelsunstimmigkeitsgrund /// A15 [EnumMember(Value = "KORREKTE_ARTIKEL_ID_FUER_ABRECHNUNG_STORNIERTER_SPERRAUFTRAG_ANGEGEBEN")] KORREKTE_ARTIKEL_ID_FUER_ABRECHNUNG_STORNIERTER_SPERRAUFTRAG_ANGEGEBEN, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Handelsunstimmigkeitstyp.cs b/BO4E/ENUM/Handelsunstimmigkeitstyp.cs index e1f69c47..4f876d63 100644 --- a/BO4E/ENUM/Handelsunstimmigkeitstyp.cs +++ b/BO4E/ENUM/Handelsunstimmigkeitstyp.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Kalkulationsmethode.cs b/BO4E/ENUM/Kalkulationsmethode.cs index 3f19204f..db50a386 100644 --- a/BO4E/ENUM/Kalkulationsmethode.cs +++ b/BO4E/ENUM/Kalkulationsmethode.cs @@ -1,4 +1,3 @@ - using System.Runtime.Serialization; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Kontaktart.cs b/BO4E/ENUM/Kontaktart.cs index 79ed765d..1aecef18 100644 --- a/BO4E/ENUM/Kontaktart.cs +++ b/BO4E/ENUM/Kontaktart.cs @@ -24,4 +24,4 @@ public enum Kontaktart /// SMS [EnumMember(Value = "SMS")] SMS, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Kostenklasse.cs b/BO4E/ENUM/Kostenklasse.cs index c8bdba45..4bf938dd 100644 --- a/BO4E/ENUM/Kostenklasse.cs +++ b/BO4E/ENUM/Kostenklasse.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -11,7 +10,9 @@ namespace BO4E.ENUM; /// public enum Kostenklasse { - [Obsolete("This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it")] + [Obsolete( + "This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it" + )] #pragma warning disable CS0618 // Type or member is obsolete [ProtoEnum(Name = nameof(Kostenklasse) + "_" + nameof(ZERO))] #pragma warning restore CS0618 // Type or member is obsolete @@ -22,4 +23,4 @@ public enum Kostenklasse ZERO, #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Kundentyp.cs b/BO4E/ENUM/Kundentyp.cs index 0495343b..e54964bd 100644 --- a/BO4E/ENUM/Kundentyp.cs +++ b/BO4E/ENUM/Kundentyp.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -76,4 +75,4 @@ public enum Kundentyp [ProtoEnum(Name = nameof(Kundentyp) + "_" + nameof(WAERMEPUMPE))] [EnumMember(Value = "WAERMEPUMPE")] WAERMEPUMPE, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Landescode.cs b/BO4E/ENUM/Landescode.cs index 6274c3f2..abbcaf4a 100644 --- a/BO4E/ENUM/Landescode.cs +++ b/BO4E/ENUM/Landescode.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -1341,4 +1340,4 @@ public enum Landescode [ProtoEnum(Name = nameof(Landescode) + "_" + nameof(ZW))] [EnumMember(Value = "ZW")] ZW, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/LeistungsbeschreibungDesSteuerkanals.cs b/BO4E/ENUM/LeistungsbeschreibungDesSteuerkanals.cs index 88190268..3f340491 100644 --- a/BO4E/ENUM/LeistungsbeschreibungDesSteuerkanals.cs +++ b/BO4E/ENUM/LeistungsbeschreibungDesSteuerkanals.cs @@ -1,5 +1,5 @@ -using BO4E.meta; using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Leistungsbezeichung.cs b/BO4E/ENUM/Leistungsbezeichung.cs index 5329ead4..a5e8318b 100644 --- a/BO4E/ENUM/Leistungsbezeichung.cs +++ b/BO4E/ENUM/Leistungsbezeichung.cs @@ -8,51 +8,67 @@ public enum Leistungsbezeichnung /// Z15 POG bei verbrauchender Marktlokation > 100.000 kWh/a mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_UEBER_100K")] POG_VERBRAUCH_IMS_UEBER_100K, + /// Z16 POG bei verbrauchender Marktlokation [50.000 kWh/a; 100.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_50K_BIS_100K")] POG_VERBRAUCH_IMS_50K_BIS_100K, + /// Z17 POG bei verbrauchender Marktlokation [20.000 kWh/a; 50.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_20K_BIS_50K")] POG_VERBRAUCH_IMS_20K_BIS_50K, + /// Z18 POG bei verbrauchender Marktlokation [10.000 kWh/a; 20.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_10K_BIS_20K")] POG_VERBRAUCH_IMS_10K_BIS_20K, + /// Z19 POG bei verbrauchender Marktlokation mit unterbrechbaren Verbrauchseinrichtung nach § 14a EnWG mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_UNTERBRECHBAR")] POG_VERBRAUCH_IMS_UNTERBRECHBAR, + /// Z20 POG bei verbrauchender Marktlokation [6.000 kWh/a; 10.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_6K_BIS_10K")] POG_VERBRAUCH_IMS_6K_BIS_10K, + /// Z21 POG bei erzeugender Marktlokation [7 kW; 15kW] mit iMS [EnumMember(Value = "POG_ERZEUGUNG_IMS_7_BIS_15")] POG_ERZEUGUNG_IMS_7_BIS_15, + /// Z22 POG bei erzeugender Marktlokation [15 kW; 30kW] mit iMS [EnumMember(Value = "POG_ERZEUGUNG_IMS_15_BIS_30")] POG_ERZEUGUNG_IMS_15_BIS_30, + /// Z23 POG bei erzeugender Marktlokation [30 kW; 100 kW] mit iMS [EnumMember(Value = "POG_ERZEUGUNG_IMS_30_BIS_100")] POG_ERZEUGUNG_IMS_30_BIS_100, + /// Z24 POG bei erzeugender Marktlokation > 100 kW mit iMS [EnumMember(Value = "POG_ERZEUGUNG_IMS_UEBER_100")] POG_ERZEUGUNG_IMS_UEBER_100, + /// Z25 POG bei Marktlokation mit mME [EnumMember(Value = "POG_MME")] POG_MME, + /// Z28 POG bei verbrauchender Marktlokation [4.000 kWh/a; 6.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_4K_BIS_6K")] POG_VERBRAUCH_IMS_4K_BIS_6K, + /// Z29 POG bei verbrauchender Marktlokation [3.000 kWh/a; 4.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_3K_BIS_4K")] POG_VERBRAUCH_IMS_3K_BIS_4K, + /// Z30 POG bei verbrauchender Marktlokation [2.000 kWh/a; 3.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_2K_BIS_3K")] POG_VERBRAUCH_IMS_2K_BIS_3K, + /// Z31 POG bei verbrauchender Marktlokation [0 kWh/a; 2.000 kWh/a] mit iMS [EnumMember(Value = "POG_VERBRAUCH_IMS_0_BIS_2K")] POG_VERBRAUCH_IMS_0_BIS_2K, + /// Z32 POG bei optionaler Ausstattung mit iMS von Neuanlagen von erzeugender Marktlokation [EnumMember(Value = "POG_ERZEUGUNG_IMS_OPTIONAL")] POG_ERZEUGUNG_IMS_OPTIONAL, + /// Z41 Zusatzleistung [EnumMember(Value = "ZUSATZLEISTUNG")] ZUSATZLEISTUNG, diff --git a/BO4E/ENUM/Lokationstyp.cs b/BO4E/ENUM/Lokationstyp.cs index f611b7cb..676a30ab 100644 --- a/BO4E/ENUM/Lokationstyp.cs +++ b/BO4E/ENUM/Lokationstyp.cs @@ -12,4 +12,4 @@ public enum Lokationstyp /// Messlokation [EnumMember(Value = "MELO")] MELO, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Marktrolle.cs b/BO4E/ENUM/Marktrolle.cs index d279a577..8d3219d6 100644 --- a/BO4E/ENUM/Marktrolle.cs +++ b/BO4E/ENUM/Marktrolle.cs @@ -100,4 +100,4 @@ public enum Marktrolle /// [EnumMember(Value = "AMSB")] AMSB, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Mengeneinheit.cs b/BO4E/ENUM/Mengeneinheit.cs index d8fafc57..abca37a5 100644 --- a/BO4E/ENUM/Mengeneinheit.cs +++ b/BO4E/ENUM/Mengeneinheit.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -10,7 +9,9 @@ namespace BO4E.ENUM; /// public enum Mengeneinheit { - [Obsolete("This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it")] + [Obsolete( + "This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it" + )] #pragma warning disable CS0618 // Type or member is obsolete [ProtoEnum(Name = nameof(Mengeneinheit) + "_" + nameof(ZERO))] #pragma warning restore CS0618 // Type or member is obsolete diff --git a/BO4E/ENUM/MesstechnischeEinordnung.cs b/BO4E/ENUM/MesstechnischeEinordnung.cs index 8ee87226..11e1b6be 100644 --- a/BO4E/ENUM/MesstechnischeEinordnung.cs +++ b/BO4E/ENUM/MesstechnischeEinordnung.cs @@ -18,4 +18,4 @@ public enum MesstechnischeEinordnung /// [EnumMember(Value = "KEINE_MESSUNG")] KEINE_MESSUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Messwertstatus.cs b/BO4E/ENUM/Messwertstatus.cs index 763d2523..94e1a9e3 100644 --- a/BO4E/ENUM/Messwertstatus.cs +++ b/BO4E/ENUM/Messwertstatus.cs @@ -1,11 +1,10 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; /// -/// Gibt auskunft über die Gültigkeit des angegebenen Verbrauchswertes. Bildet MSCONS SG10 QTY 6063 ab. +/// Gibt auskunft über die Gültigkeit des angegebenen Verbrauchswertes. Bildet MSCONS SG10 QTY 6063 ab. /// public enum Messwertstatus { @@ -49,4 +48,4 @@ public enum Messwertstatus /// Grundlage POG-Ermittlung: Z47 [EnumMember(Value = "GRUNDLAGE_POG_ERMITTLUNG")] GRUNDLAGE_POG_ERMITTLUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/NNRechnungstyp.cs b/BO4E/ENUM/NNRechnungstyp.cs index 702a2b7a..dedf007a 100644 --- a/BO4E/ENUM/NNRechnungstyp.cs +++ b/BO4E/ENUM/NNRechnungstyp.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -46,4 +45,4 @@ public enum NNRechnungstyp [ProtoEnum(Name = nameof(NNRechnungstyp) + "_" + nameof(MEHRMINDERMENGENRECHNUNG))] [EnumMember(Value = "MEHRMINDERMENGENRECHNUNG")] MEHRMINDERMENGENRECHNUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Netznutzungszahler.cs b/BO4E/ENUM/Netznutzungszahler.cs index 9d6d5199..bbf864ad 100644 --- a/BO4E/ENUM/Netznutzungszahler.cs +++ b/BO4E/ENUM/Netznutzungszahler.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Preismodell.cs b/BO4E/ENUM/Preismodell.cs index ffb400c7..60831c7f 100644 --- a/BO4E/ENUM/Preismodell.cs +++ b/BO4E/ENUM/Preismodell.cs @@ -8,4 +8,4 @@ public enum Preismodell /// Tranche [EnumMember(Value = "TRANCHE")] TRANCHE, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Preisstatus.cs b/BO4E/ENUM/Preisstatus.cs index 3269d188..1d9719d1 100644 --- a/BO4E/ENUM/Preisstatus.cs +++ b/BO4E/ENUM/Preisstatus.cs @@ -16,4 +16,4 @@ public enum Preisstatus /// [EnumMember(Value = "ENDGUELTIG")] ENDGUELTIG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Profilart.cs b/BO4E/ENUM/Profilart.cs index 5e74c30b..a8016332 100644 --- a/BO4E/ENUM/Profilart.cs +++ b/BO4E/ENUM/Profilart.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -31,5 +30,5 @@ public enum Profilart /// Z05 tagesparameterabhängiges Einspeiseprofil /// Z05 [EnumMember(Value = "ART_TAGESPARAMETERABHAENGIGES_EINSPEISEPROFIL")] - ART_TAGESPARAMETERABHAENGIGES_EINSPEISEPROFIL -} \ No newline at end of file + ART_TAGESPARAMETERABHAENGIGES_EINSPEISEPROFIL, +} diff --git a/BO4E/ENUM/Profiltyp.cs b/BO4E/ENUM/Profiltyp.cs index a5bd648f..6acfecd4 100644 --- a/BO4E/ENUM/Profiltyp.cs +++ b/BO4E/ENUM/Profiltyp.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -15,4 +14,4 @@ public enum Profiltyp /// TLP/TEP [EnumMember(Value = "TLP_TEP")] TLP_TEP, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Profilverfahren.cs b/BO4E/ENUM/Profilverfahren.cs index f69ca9e9..09ca2a8f 100644 --- a/BO4E/ENUM/Profilverfahren.cs +++ b/BO4E/ENUM/Profilverfahren.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -15,4 +14,4 @@ public enum Profilverfahren /// ALP [EnumMember(Value = "ANALYTISCH")] ANALYTISCH, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Prognosegrundlage.cs b/BO4E/ENUM/Prognosegrundlage.cs index 30ab7548..299d4f94 100644 --- a/BO4E/ENUM/Prognosegrundlage.cs +++ b/BO4E/ENUM/Prognosegrundlage.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -15,4 +14,4 @@ public enum Prognosegrundlage /// Prognose auf der Basis von Profilen [EnumMember(Value = "PROFILE")] PROFILE, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/RechnungspositionsStatus.cs b/BO4E/ENUM/RechnungspositionsStatus.cs index a988aab4..f008a259 100644 --- a/BO4E/ENUM/RechnungspositionsStatus.cs +++ b/BO4E/ENUM/RechnungspositionsStatus.cs @@ -13,11 +13,14 @@ public enum RechnungspositionsStatus [EnumMember(Value = "ROH_AUSGENOMMEN")] ROH_AUSGENOMMEN = 1, + [EnumMember(Value = "ABRECHENBAR")] ABRECHENBAR = 2, + [EnumMember(Value = "ABRECHENBAR_AUSGENOMMEN")] ABRECHENBAR_AUSGENOMMEN = 3, + [EnumMember(Value = "ABGERECHNET")] ABGERECHNET = 4 #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Rechnungsstatus.cs b/BO4E/ENUM/Rechnungsstatus.cs index a27069d7..8b2b4c51 100644 --- a/BO4E/ENUM/Rechnungsstatus.cs +++ b/BO4E/ENUM/Rechnungsstatus.cs @@ -23,4 +23,4 @@ public enum Rechnungsstatus /// Rechnungen zwischen einem Händler und Einkäufer von Energie. [EnumMember(Value = "BEZAHLT")] BEZAHLT, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Rechnungstyp.cs b/BO4E/ENUM/Rechnungstyp.cs index 9953668d..30023e92 100644 --- a/BO4E/ENUM/Rechnungstyp.cs +++ b/BO4E/ENUM/Rechnungstyp.cs @@ -40,33 +40,40 @@ public enum Rechnungstyp /// Abschlussrechnung [EnumMember(Value = "ABSCHLUSSRECHNUNG")] ABSCHLUSSRECHNUNG, + /// Rechnung für Messstellenbetrieb [EnumMember(Value = "MSBRECHNUNG")] MSBRECHNUNG, + /// Kapazitätsrechnung [EnumMember(Value = "KAPAZITAETSRECHNUNG")] KAPAZITAETSRECHNUNG, + /// Rechnung für Sperren und Wiederinbetriebnahme [EnumMember(Value = "SPERRUNG_INBETRIEBNAHME")] SPERRUNG_INBETRIEBNAHME, + /// /// Verzugskostenrechnung /// [EnumMember(Value = "VERZUGSKOSTEN")] VERZUGSKOSTEN, + /// /// Blindarbeitsrechnung /// [EnumMember(Value = "BLINDARBEIT")] BLINDARBEIT, + /// /// Sonderrechnung /// [EnumMember(Value = "SONDERRECHNUNG")] SONDERRECHNUNG, + /// /// Abrechnung von Konfigurationen (Universalbestellprozess) /// [EnumMember(Value = "ABRECHNUNG_VON_KONFIGURATIONEN_UNIVERSALBESTELLPROZESS")] - ABRECHNUNG_VON_KONFIGURATIONEN_UNIVERSALBESTELLPROZESS -} \ No newline at end of file + ABRECHNUNG_VON_KONFIGURATIONEN_UNIVERSALBESTELLPROZESS, +} diff --git a/BO4E/ENUM/Rollencodetyp.cs b/BO4E/ENUM/Rollencodetyp.cs index 0b1a4785..f36ec143 100644 --- a/BO4E/ENUM/Rollencodetyp.cs +++ b/BO4E/ENUM/Rollencodetyp.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.Serialization; - using ProtoBuf; namespace BO4E.ENUM; @@ -8,7 +7,9 @@ namespace BO4E.ENUM; /// Gibt den Codetyp einer Rolle, beispielsweise einer Marktrolle, an. public enum Rollencodetyp { - [Obsolete("This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it")] + [Obsolete( + "This value is only a workaround for the proto3 syntax generation. You shouldn't actually use it" + )] #pragma warning disable CS0618 // Type or member is obsolete [ProtoEnum(Name = nameof(Rollencodetyp) + "_" + nameof(ZERO))] #pragma warning restore CS0618 // Type or member is obsolete @@ -30,5 +31,5 @@ public enum Rollencodetyp /// Global Location Number [EnumMember(Value = "GLN")] - GLN = 9 -} \ No newline at end of file + GLN = 9, +} diff --git a/BO4E/ENUM/Servicetyp.cs b/BO4E/ENUM/Servicetyp.cs index 1621967d..f4d34174 100644 --- a/BO4E/ENUM/Servicetyp.cs +++ b/BO4E/ENUM/Servicetyp.cs @@ -40,4 +40,4 @@ public enum Servicetyp /// [EnumMember(Value = "GAS_LIEF")] GAS_LIEF, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/SonderrechnungsArt.cs b/BO4E/ENUM/SonderrechnungsArt.cs index 8042653e..278a8ef2 100644 --- a/BO4E/ENUM/SonderrechnungsArt.cs +++ b/BO4E/ENUM/SonderrechnungsArt.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -12,46 +11,53 @@ public enum Sonderrechnungsart /// [EnumMember(Value = "KONZESSIONSABGABE_TESTAT")] KONZESSIONSABGABE_TESTAT, + /// /// Z02: Individuelle Vereinbarung für atypische und energieintensive Netznutzung /// [EnumMember(Value = "INDIVIDUELL_ATYPISCH")] INDIVIDUELL_ATYPISCH, + /// /// Z03: Individuelle Vereinbarung für singuläre Netznutzung /// [EnumMember(Value = "INDIVIDUELL_SINGULAER")] INDIVIDUELL_SINGULAER, + /// /// Z04: KWKG-Umlage /// [EnumMember(Value = "KWKG_UMLAGE")] KWKG_UMLAGE, + /// /// Z05: Offshore-Netzumlage /// [ProtoEnum(Name = nameof(Sonderrechnungsart) + "_" + nameof(OFFSHORE_UMLAGE))] [EnumMember(Value = "OFFSHORE_UMLAGE")] OFFSHORE_UMLAGE, + /// /// Z06: § 19 StromNEV-Umlage /// [EnumMember(Value = "P19_STROM_NEV_UMLAGE")] P19_STROM_NEV_UMLAGE, + /// /// Z07: §18 AbLaV /// [EnumMember(Value = "P18_ABLAV")] P18_ABLAV, + /// /// Z08: Konzessionsabgabe (Wechsel auf Lastgangmessung) /// [EnumMember(Value = "KONZESSIONSABGABE_WECHSEL_RLM")] KONZESSIONSABGABE_WECHSEL_RLM, + /// /// Z09: Privilegierung nach EnFG /// [EnumMember(Value = "PRIVILEGIERUNG_NACH_ENFG")] PRIVILEGIERUNG_NACH_ENFG, - } diff --git a/BO4E/ENUM/Sparte.cs b/BO4E/ENUM/Sparte.cs index 8da1371c..031002c1 100644 --- a/BO4E/ENUM/Sparte.cs +++ b/BO4E/ENUM/Sparte.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -36,4 +35,4 @@ public enum Sparte [ProtoEnum(Name = nameof(Sparte) + "_" + nameof(ABWASSER))] [EnumMember(Value = "ABWASSER")] ABWASSER, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Sperrauftragsablehngrund.cs b/BO4E/ENUM/Sperrauftragsablehngrund.cs index 5d797633..e7c35a06 100644 --- a/BO4E/ENUM/Sperrauftragsablehngrund.cs +++ b/BO4E/ENUM/Sperrauftragsablehngrund.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -19,7 +18,7 @@ public enum Sperrauftragsablehngrund DUPLIKAT, /// - /// An mindestens einer Messlokation ist ein anderer MSB zugeordnet als an der Marktlokation. + /// An mindestens einer Messlokation ist ein anderer MSB zugeordnet als an der Marktlokation. /// /// EBD 0470 A02 [EnumMember(Value = "FALSCHER_MSB")] @@ -33,7 +32,7 @@ public enum Sperrauftragsablehngrund FALSCHE_SPANNUNGSEBENE, /// - /// Mindestens eine weitere Marktlokation ist von der Sperrung betroffen. + /// Mindestens eine weitere Marktlokation ist von der Sperrung betroffen. /// /// EBD 0470 A04 [EnumMember(Value = "WEITERE_MALO_BETROFFEN")] @@ -75,7 +74,7 @@ public enum Sperrauftragsablehngrund LIEGT_BEREITS_VOR, /// - /// Zukünftiger bestätigter Lieferbeginn liegt gegenüber anderem Lieferanten bereits vor. + /// Zukünftiger bestätigter Lieferbeginn liegt gegenüber anderem Lieferanten bereits vor. /// /// FV2304 EBD 0470 A11 [EnumMember(Value = "ANDERER_ZUKUENFTIGER_LIEFERANT")] @@ -86,6 +85,5 @@ public enum Sperrauftragsablehngrund /// /// FV2304 EBD 0470 A12 [EnumMember(Value = "BESTAETIGTER_LIEFERBEGINN")] - BESTAETIGTER_LIEFERBEGINN - -} \ No newline at end of file + BESTAETIGTER_LIEFERBEGINN, +} diff --git a/BO4E/ENUM/Sperrauftragsart.cs b/BO4E/ENUM/Sperrauftragsart.cs index 35ae0bfe..8c9f61a4 100644 --- a/BO4E/ENUM/Sperrauftragsart.cs +++ b/BO4E/ENUM/Sperrauftragsart.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -23,4 +22,4 @@ public enum Sperrauftragsart /// EDIFACT Z52 in Nachricht 17117 [EnumMember(Value = "ENTSPERREN")] ENTSPERREN, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Sperrauftragsverhinderungsgrund.cs b/BO4E/ENUM/Sperrauftragsverhinderungsgrund.cs index f999ee50..f8082387 100644 --- a/BO4E/ENUM/Sperrauftragsverhinderungsgrund.cs +++ b/BO4E/ENUM/Sperrauftragsverhinderungsgrund.cs @@ -1,8 +1,7 @@ +using System.Runtime.Serialization; using BO4E.BO; using BO4E.meta; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// @@ -43,7 +42,7 @@ public enum Sperrauftragsverhinderungsgrund /// /// Ein tatsächlicher Verhinderungsgrund liegt vor, wenn z.B. die MaLo nicht identifizierbar, der Zugang nicht möglich war oder ein Kundenwechsel festgestellt wurde - /// Details werden im Freitext vermerkt. + /// Details werden im Freitext vermerkt. /// /// EBD 0472 A05 [EnumMember(Value = "TATSAECHLICHER_VERHINDERUNGSGRUND")] @@ -64,4 +63,4 @@ public enum Sperrauftragsverhinderungsgrund /// EBD 0472 A08 [EnumMember(Value = "ANSCHLUSSNUTZER_WURDE_NICHT_ANGETROFFEN")] ANSCHLUSSNUTZER_WURDE_NICHT_ANGETROFFEN, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Sperrstatus.cs b/BO4E/ENUM/Sperrstatus.cs index 201d08a9..9d783c12 100644 --- a/BO4E/ENUM/Sperrstatus.cs +++ b/BO4E/ENUM/Sperrstatus.cs @@ -1,9 +1,7 @@ +using System.Runtime.Serialization; using BO4E.meta; - using ProtoBuf; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// @@ -25,4 +23,4 @@ public enum Sperrstatus [ProtoEnum(Name = nameof(Sperrstatus) + "_" + nameof(GESPERRT))] [EnumMember(Value = "GESPERRT")] GESPERRT, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Status.cs b/BO4E/ENUM/Status.cs index c8b3c360..12ccbf57 100644 --- a/BO4E/ENUM/Status.cs +++ b/BO4E/ENUM/Status.cs @@ -1,11 +1,10 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; /// -/// Represents the Status Code (MSCONS SG10 STS 4405) +/// Represents the Status Code (MSCONS SG10 STS 4405) /// [NonOfficial(NonOfficialCategory.UNSPECIFIED)] public enum Status @@ -57,22 +56,30 @@ public enum Status /// ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT /// Z36 - [EnumMember(Value = "ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT")] + [EnumMember( + Value = "ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT" + )] ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT, /// ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT /// Z37 - [EnumMember(Value = "ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT")] + [EnumMember( + Value = "ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT" + )] ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_VORHANDEN_UND_KOMMUNIZIERT, /// ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG /// Z38 - [EnumMember(Value = "ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG")] + [EnumMember( + Value = "ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG" + )] ZAEHLERSTAND_ZUM_BEGINN_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG, /// ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG /// Z39 - [EnumMember(Value = "ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG")] + [EnumMember( + Value = "ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG" + )] ZAEHLERSTAND_ZUM_ENDE_DER_ANGEGEBENEN_ENERGIEMENGE_NICHT_VORHANDEN_DA_MENGENABGRENZUNG, /// KEIN_ZUGANG @@ -330,17 +337,21 @@ public enum Status /// ZS0 [EnumMember(Value = "ANGABEN_MESSLOKATION")] ANGABEN_MESSLOKATION, + /// BASIS_MME /// ZS2 [EnumMember(Value = "BASIS_MME")] BASIS_MME, + /// GRUND_ANGABEN_MESSLOKATION /// ZS9 [EnumMember(Value = "GRUND_ANGABEN_MESSLOKATION")] GRUND_ANGABEN_MESSLOKATION, + /// ANFORDERUNG_IN_DIE_VERGANGENHEIT_ZUM_ANGEFORDERTEN_ZEITPUNKT_LIEGT_KEIN_WERT_VOR /// ZT8 - [EnumMember(Value = "ANFORDERUNG_IN_DIE_VERGANGENHEIT_ZUM_ANGEFORDERTEN_ZEITPUNKT_LIEGT_KEIN_WERT_VOR")] + [EnumMember( + Value = "ANFORDERUNG_IN_DIE_VERGANGENHEIT_ZUM_ANGEFORDERTEN_ZEITPUNKT_LIEGT_KEIN_WERT_VOR" + )] ANFORDERUNG_IN_DIE_VERGANGENHEIT_ZUM_ANGEFORDERTEN_ZEITPUNKT_LIEGT_KEIN_WERT_VOR, - } diff --git a/BO4E/ENUM/StatusArt.cs b/BO4E/ENUM/StatusArt.cs index 5efcffd6..d599c96f 100644 --- a/BO4E/ENUM/StatusArt.cs +++ b/BO4E/ENUM/StatusArt.cs @@ -1,8 +1,7 @@ +using System.Runtime.Serialization; using BO4E.COM; using BO4E.meta; -using System.Runtime.Serialization; - namespace BO4E.ENUM; /// @@ -51,4 +50,4 @@ public enum StatusArt /// Z31 [EnumMember(Value = "GASQUALITAET")] GASQUALITAET, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Steuerkennzeichen.cs b/BO4E/ENUM/Steuerkennzeichen.cs index 87a0ff35..738f2aba 100644 --- a/BO4E/ENUM/Steuerkennzeichen.cs +++ b/BO4E/ENUM/Steuerkennzeichen.cs @@ -9,9 +9,11 @@ public enum Steuerkennzeichen /// Soll verwendet werden, wenn weder noch noch anwendbar sind. [EnumMember(Value = "UST_SONDER")] UST_SONDER, + /// Umsatzsteuer 19% [EnumMember(Value = "UST_19")] UST_19, + /// Umsatzsteuer 16% [EnumMember(Value = "UST_16")] UST_16, @@ -27,6 +29,7 @@ public enum Steuerkennzeichen /// Vorsteuer 19% [EnumMember(Value = "VST_19")] VST_19, + /// Vorsteuer 16% [EnumMember(Value = "VST_16")] VST_16, diff --git a/BO4E/ENUM/Tarifkalkulationsmethode.cs b/BO4E/ENUM/Tarifkalkulationsmethode.cs index f65894fc..799b63e3 100644 --- a/BO4E/ENUM/Tarifkalkulationsmethode.cs +++ b/BO4E/ENUM/Tarifkalkulationsmethode.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Tarifmerkmal.cs b/BO4E/ENUM/Tarifmerkmal.cs index f13eb666..53d10e9c 100644 --- a/BO4E/ENUM/Tarifmerkmal.cs +++ b/BO4E/ENUM/Tarifmerkmal.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -41,4 +40,4 @@ public enum Tarifmerkmal [ProtoEnum(Name = nameof(Tarifmerkmal) + "_" + nameof(HEIZSTROM))] [EnumMember(Value = "HEIZSTROM")] HEIZSTROM, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Tarifregionskriterium.cs b/BO4E/ENUM/Tarifregionskriterium.cs index 059bb856..18550610 100644 --- a/BO4E/ENUM/Tarifregionskriterium.cs +++ b/BO4E/ENUM/Tarifregionskriterium.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Tarifstufe.cs b/BO4E/ENUM/Tarifstufe.cs index ed502322..19d5bad6 100644 --- a/BO4E/ENUM/Tarifstufe.cs +++ b/BO4E/ENUM/Tarifstufe.cs @@ -1,14 +1,12 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; /// -/// In IFTSTA 21035 "Rückmeldung auf Lieferschein" (IFTSTA SG16 QTY 6063) +/// In IFTSTA 21035 "Rückmeldung auf Lieferschein" (IFTSTA SG16 QTY 6063) /// [NonOfficial(NonOfficialCategory.UNSPECIFIED)] - public enum Tarifstufe { /// TARIFSTUFE_0 @@ -30,10 +28,12 @@ public enum Tarifstufe /// Z23 [EnumMember(Value = "TARIFSTUFE_3")] TARIFSTUFE_3, + /// TARIFSTUFE_4 /// Z24 [EnumMember(Value = "TARIFSTUFE_4")] TARIFSTUFE_4, + /// TARIFSTUFE_5 /// Z25 [EnumMember(Value = "TARIFSTUFE_5")] @@ -58,4 +58,4 @@ public enum Tarifstufe /// Z29 [EnumMember(Value = "TARIFSTUFE_9")] TARIFSTUFE_9, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Tariftyp.cs b/BO4E/ENUM/Tariftyp.cs index 8c00bc1e..60840f21 100644 --- a/BO4E/ENUM/Tariftyp.cs +++ b/BO4E/ENUM/Tariftyp.cs @@ -23,4 +23,4 @@ public enum Tariftyp /// Sondertarif [EnumMember(Value = "SONDERTARIF")] SONDERTARIF, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Tarifzeit.cs b/BO4E/ENUM/Tarifzeit.cs index 1a9030c1..a82ec5b2 100644 --- a/BO4E/ENUM/Tarifzeit.cs +++ b/BO4E/ENUM/Tarifzeit.cs @@ -16,4 +16,4 @@ public enum Tarifzeit /// Tarifzeit für Niedritarif bei Mehrtarif-Konfigurationen [EnumMember(Value = "TZ_NT")] TZ_NT, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/TechnischeRessourceNutzung.cs b/BO4E/ENUM/TechnischeRessourceNutzung.cs index 0f89071f..831bc6d3 100644 --- a/BO4E/ENUM/TechnischeRessourceNutzung.cs +++ b/BO4E/ENUM/TechnischeRessourceNutzung.cs @@ -15,5 +15,5 @@ public enum TechnischeRessourceNutzung /// Z56: Speicher [EnumMember(Value = "SPEICHER")] - SPEICHER -} \ No newline at end of file + SPEICHER, +} diff --git a/BO4E/ENUM/Themengebiet.cs b/BO4E/ENUM/Themengebiet.cs index 3cb768a4..ad03b532 100644 --- a/BO4E/ENUM/Themengebiet.cs +++ b/BO4E/ENUM/Themengebiet.cs @@ -240,4 +240,4 @@ public enum Themengebiet /// Zuordnungsvereinbarung [EnumMember(Value = "ZUORDNUNGSVEREINBARUNG")] ZUORDNUNGSVEREINBARUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/UebermittelbarkeitZaehlzeit.cs b/BO4E/ENUM/UebermittelbarkeitZaehlzeit.cs index ab919af1..aeb59030 100644 --- a/BO4E/ENUM/UebermittelbarkeitZaehlzeit.cs +++ b/BO4E/ENUM/UebermittelbarkeitZaehlzeit.cs @@ -12,4 +12,4 @@ public enum UebermittelbarkeitZaehlzeit /// Der NB übermittelt die ausgerollte Zählzeit auf einem bilateral vereinbarten Weg. Dieser Weg wird hier nicht weiter beschrieben [EnumMember(Value = "NICHT_ELEKTRONISCH")] NICHT_ELEKTRONISCH, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Verbrauchsart.cs b/BO4E/ENUM/Verbrauchsart.cs index 884722f9..1d845802 100644 --- a/BO4E/ENUM/Verbrauchsart.cs +++ b/BO4E/ENUM/Verbrauchsart.cs @@ -24,4 +24,4 @@ public enum Verbrauchsart /// Wärme/Speicherheizung [EnumMember(Value = "WS")] WS, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Vertragsart.cs b/BO4E/ENUM/Vertragsart.cs index 43351d1a..976d1003 100644 --- a/BO4E/ENUM/Vertragsart.cs +++ b/BO4E/ENUM/Vertragsart.cs @@ -36,4 +36,4 @@ public enum Vertragsart /// [EnumMember(Value = "BUENDELVERTRAG")] BUENDELVERTRAG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Vertragsform.cs b/BO4E/ENUM/Vertragsform.cs index c689bcdc..5ab4ba94 100644 --- a/BO4E/ENUM/Vertragsform.cs +++ b/BO4E/ENUM/Vertragsform.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Vertragstatus.cs b/BO4E/ENUM/Vertragstatus.cs index 513b1bd7..c961f5f8 100644 --- a/BO4E/ENUM/Vertragstatus.cs +++ b/BO4E/ENUM/Vertragstatus.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -71,4 +70,4 @@ public enum Vertragstatus [ProtoEnum(Name = nameof(Vertragstatus) + "_" + nameof(BEENDET))] [EnumMember(Value = "BEENDET")] BEENDET, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Verwendungszweck.cs b/BO4E/ENUM/Verwendungszweck.cs index d5e471fe..24291128 100644 --- a/BO4E/ENUM/Verwendungszweck.cs +++ b/BO4E/ENUM/Verwendungszweck.cs @@ -39,4 +39,4 @@ public enum Verwendungszweck /// ZB5 [EnumMember(Value = "ERMITTLUNG_AUSGEGLICHENHEIT_BILANZKREIS")] ERMITTLUNG_AUSGEGLICHENHEIT_BILANZKREIS, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Waehrungscode.cs b/BO4E/ENUM/Waehrungscode.cs index 0a6929fd..388e85b7 100644 --- a/BO4E/ENUM/Waehrungscode.cs +++ b/BO4E/ENUM/Waehrungscode.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Waehrungseinheit.cs b/BO4E/ENUM/Waehrungseinheit.cs index ad2804dc..8dcf0875 100644 --- a/BO4E/ENUM/Waehrungseinheit.cs +++ b/BO4E/ENUM/Waehrungseinheit.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Waermenutzung.cs b/BO4E/ENUM/Waermenutzung.cs index 5eee95b8..f4f8ab6d 100644 --- a/BO4E/ENUM/Waermenutzung.cs +++ b/BO4E/ENUM/Waermenutzung.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; @@ -21,4 +20,4 @@ public enum Waermenutzung [ProtoEnum(Name = nameof(Waermenutzung) + "_" + nameof(DIREKTHEIZUNG))] [EnumMember(Value = "DIREKTHEIZUNG")] DIREKTHEIZUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/WahlrechtPrognosegrundlage.cs b/BO4E/ENUM/WahlrechtPrognosegrundlage.cs index 67209121..9c9b7af3 100644 --- a/BO4E/ENUM/WahlrechtPrognosegrundlage.cs +++ b/BO4E/ENUM/WahlrechtPrognosegrundlage.cs @@ -14,6 +14,7 @@ public enum WahlrechtPrognosegrundlage /// CAV+Z54 [EnumMember(Value = "DURCH_LF")] DURCH_LF, + /// /// Wahlrecht durch LF gegeben /// diff --git a/BO4E/ENUM/Wertermittlungsverfahren.cs b/BO4E/ENUM/Wertermittlungsverfahren.cs index cd218f8f..c03ca232 100644 --- a/BO4E/ENUM/Wertermittlungsverfahren.cs +++ b/BO4E/ENUM/Wertermittlungsverfahren.cs @@ -18,4 +18,4 @@ public enum Wertermittlungsverfahren /// [EnumMember(Value = "MESSUNG")] MESSUNG, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/Zaehlerauspraegung.cs b/BO4E/ENUM/Zaehlerauspraegung.cs index 397ed03a..4398d81f 100644 --- a/BO4E/ENUM/Zaehlerauspraegung.cs +++ b/BO4E/ENUM/Zaehlerauspraegung.cs @@ -12,4 +12,4 @@ public enum Zaehlerauspraegung /// Zweirichtungszaehler [EnumMember(Value = "ZWEIRICHTUNGSZAEHLER")] ZWEIRICHTUNGSZAEHLER, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/ZaehlertypSpezifikation.cs b/BO4E/ENUM/ZaehlertypSpezifikation.cs index 0e72f5c6..9b1085ac 100644 --- a/BO4E/ENUM/ZaehlertypSpezifikation.cs +++ b/BO4E/ENUM/ZaehlertypSpezifikation.cs @@ -26,4 +26,4 @@ public enum ZaehlertypSpezifikation /// Z05 [EnumMember(Value = "MME_MEDA")] MME_MEDA, -} \ No newline at end of file +} diff --git a/BO4E/ENUM/ZaehlzeitdefinitionTyp.cs b/BO4E/ENUM/ZaehlzeitdefinitionTyp.cs index 9bd96b79..6db62d25 100644 --- a/BO4E/ENUM/ZaehlzeitdefinitionTyp.cs +++ b/BO4E/ENUM/ZaehlzeitdefinitionTyp.cs @@ -13,24 +13,28 @@ public enum ZaehlzeitdefinitionTyp /// Z29 [EnumMember(Value = "WAERMEPUMPE")] WAERMEPUMPE, + /// /// Nachtspeicherheizung /// /// Z30 [EnumMember(Value = "NACHTSPEICHERHEIZUNG")] NACHTSPEICHERHEIZUNG, + /// /// Schwachlastzeifenster /// /// Z31 [EnumMember(Value = "SCHWACHLASTZEITFENSTER")] SCHWACHLASTZEITFENSTER, + /// /// sonstige Zaehlzeitdefinition /// /// Z32 [EnumMember(Value = "SONSTIGE")] SONSTIGE, + /// /// Hochlastzeitfenster /// diff --git a/BO4E/ENUM/Zeiteinheit.cs b/BO4E/ENUM/Zeiteinheit.cs index 2f374122..8ef75fe8 100644 --- a/BO4E/ENUM/Zeiteinheit.cs +++ b/BO4E/ENUM/Zeiteinheit.cs @@ -1,6 +1,5 @@ -using ProtoBuf; - using System.Runtime.Serialization; +using ProtoBuf; namespace BO4E.ENUM; diff --git a/BO4E/ENUM/Zeitreihentyp.cs b/BO4E/ENUM/Zeitreihentyp.cs index 722714d8..284318bb 100644 --- a/BO4E/ENUM/Zeitreihentyp.cs +++ b/BO4E/ENUM/Zeitreihentyp.cs @@ -1,6 +1,5 @@ -using BO4E.meta; - using System.Runtime.Serialization; +using BO4E.meta; namespace BO4E.ENUM; @@ -36,14 +35,16 @@ public enum Zeitreihentyp /// Tagesparameterabhängige Lastprofilsumme [EnumMember(Value = "TLS")] TLS, + /// /// gemeinsame Messung aus SLS und TLS /// [EnumMember(Value = "SLS_TLS")] SLS_TLS, + /// /// Gemeinsame Messung aus SES und TES /// [EnumMember(Value = "SES_TES")] SES_TES, -} \ No newline at end of file +} diff --git a/BO4E/EnergyIdentificationCodes/EnergyIdentificationCodeExtensions.cs b/BO4E/EnergyIdentificationCodes/EnergyIdentificationCodeExtensions.cs index 4cc71a2a..7d26b651 100644 --- a/BO4E/EnergyIdentificationCodes/EnergyIdentificationCodeExtensions.cs +++ b/BO4E/EnergyIdentificationCodes/EnergyIdentificationCodeExtensions.cs @@ -13,7 +13,7 @@ namespace BO4E.EnergyIdentificationCodes; public enum EicType { /// - /// object type “Y”, Areas for inter System Operator data interchange + /// object type “Y”, Areas for inter System Operator data interchange /// [EnumMember(Value = "AREA")] AREA, @@ -53,7 +53,7 @@ public enum EicType /// Parties - object type "X" /// [EnumMember(Value = "MARKET_PARTICIPANT")] - MARKET_PARTICIPANT + MARKET_PARTICIPANT, } /// @@ -65,7 +65,10 @@ public static class EnergyIdentificationCodeExtensions /// Energy Identification Code Regular Expression /// /// https://regex101.com/r/LpyuKX/1 - internal static readonly Regex EicRegex = new Regex("(?\\d{2})(?A|T|V|W|X|Y|Z)([-A-Z\\d]{12})(?[A-Z0-9])", RegexOptions.Compiled); + internal static readonly Regex EicRegex = new Regex( + "(?\\d{2})(?A|T|V|W|X|Y|Z)([-A-Z\\d]{12})(?[A-Z0-9])", + RegexOptions.Compiled + ); /// /// Converts a object type string to a @@ -88,7 +91,9 @@ public static EicType GetEICType(string type) "X" => EicType.MARKET_PARTICIPANT, "Y" => EicType.AREA, "Z" => EicType.MEASURING_POINT, - _ => throw new ArgumentException($"The type '{type}' is not a valid EIC type character.") + _ => throw new ArgumentException( + $"The type '{type}' is not a valid EIC type character." + ), }; } @@ -145,7 +150,8 @@ public static bool IsValidBilanzierungsGebietId(this string? bilanzierungsGebiet } var eicType = GetEICType(EicRegex.Match(bilanzierungsGebietEic).Groups["typ"].Value); - return eicType == EicType.AREA && GermanControlAreas.ContainsKey(bilanzierungsGebietEic!.Substring(3, 1)); + return eicType == EicType.AREA + && GermanControlAreas.ContainsKey(bilanzierungsGebietEic!.Substring(3, 1)); } /// @@ -153,16 +159,22 @@ public static bool IsValidBilanzierungsGebietId(this string? bilanzierungsGebiet /// /// /// - public static bool IsGermanControlArea(this string? eicCode) => GermanControlAreas.Values.Contains(eicCode); + public static bool IsGermanControlArea(this string? eicCode) => + GermanControlAreas.Values.Contains(eicCode); - private static readonly Dictionary GermanControlAreas = new() - { - // they won't change in foreseeable time - { "N", "10YDE-EON------1" }, // tennet - { "R", "10YDE-RWENET---I" }, // amprion - { "V", "10YDE-VE-------2" }, // 50Hz - { "W", "10YDE-ENBW-----N" } // transnet BW - }; + private static readonly Dictionary GermanControlAreas = + new() + { + // they won't change in foreseeable time + { "N", "10YDE-EON------1" }, // tennet + { "R", "10YDE-RWENET---I" }, // amprion + { "V", "10YDE-VE-------2" }, // 50Hz + { + "W", + "10YDE-ENBW-----N" + } // transnet BW + , + }; /// /// calculates the check character according to the EIC rules (ENTSO-E) @@ -179,7 +191,10 @@ private static char GetEICCheckCharacter(string eicWithoutChecksum) if (eicWithoutChecksum.Length != 15) { - throw new ArgumentException($"The {nameof(eicWithoutChecksum)} has to be exactly 15 characters long.", nameof(eicWithoutChecksum)); + throw new ArgumentException( + $"The {nameof(eicWithoutChecksum)} has to be exactly 15 characters long.", + nameof(eicWithoutChecksum) + ); } List numericValues; @@ -212,7 +227,8 @@ private static char GetEICCheckCharacter(string eicWithoutChecksum) if (checkCharacter == '-') { throw new ArgumentException( - $"The check character must not be {checkCharacter}. Please choose other 15 characters to start with than '{eicWithoutChecksum}'"); + $"The check character must not be {checkCharacter}. Please choose other 15 characters to start with than '{eicWithoutChecksum}'" + ); // https://eepublicdownloads.entsoe.eu/clean-documents/EDI/Library/cim_based/02%20EIC%20Code%20implementation%20guide_final.pdf line 509 } } @@ -245,7 +261,9 @@ private static int CharacterToNumberEic(char character) '7' => 7, '8' => 8, '9' => 9, - _ => character - 55 // in ASCII 65=A but in ENTSO 10=A + _ => character + - 55 // in ASCII 65=A but in ENTSO 10=A + , }; } @@ -259,9 +277,12 @@ private static char NumberToEicCharacter(int number) { return number switch { - < 10 or > 36 => throw new ArgumentOutOfRangeException(nameof(number), "Only the range [10,36] is supported."), + < 10 or > 36 => throw new ArgumentOutOfRangeException( + nameof(number), + "Only the range [10,36] is supported." + ), 36 => '-', - _ => (char)(number + 55) + _ => (char)(number + 55), }; } -} \ No newline at end of file +} diff --git a/BO4E/UserPropertiesDataContractResolver.cs b/BO4E/UserPropertiesDataContractResolver.cs index 2b2fb7c4..24a16775 100644 --- a/BO4E/UserPropertiesDataContractResolver.cs +++ b/BO4E/UserPropertiesDataContractResolver.cs @@ -52,4 +52,4 @@ public override JsonContract ResolveContract(Type type) }; return contract; } -} \ No newline at end of file +} diff --git a/BO4E/UserPropertiesExtensions.cs b/BO4E/UserPropertiesExtensions.cs index 23bc78cc..543453f5 100644 --- a/BO4E/UserPropertiesExtensions.cs +++ b/BO4E/UserPropertiesExtensions.cs @@ -1,10 +1,8 @@ -using BO4E.meta; - -using Newtonsoft.Json.Linq; - using System; using System.Collections.Generic; using System.Text.Json; +using BO4E.meta; +using Newtonsoft.Json.Linq; namespace BO4E; @@ -30,8 +28,12 @@ public static class UserPropertiesExtensions /// default if false is returned, the stored value otherwise /// true if found /// iff is null or whitespace - public static bool TryGetUserProperty(this TParent parent, string userPropertyKey, - out TUserProperty value) where TParent : IUserProperties + public static bool TryGetUserProperty( + this TParent parent, + string userPropertyKey, + out TUserProperty value + ) + where TParent : IUserProperties { var up = parent.UserProperties; if (string.IsNullOrWhiteSpace(userPropertyKey)) @@ -70,13 +72,16 @@ public static bool TryGetUserProperty(this TParent paren default: try { - value = JsonSerializer.Deserialize(((JsonElement)upToken).GetRawText(), - Defaults.JsonSerializerDefaultOptions); + value = JsonSerializer.Deserialize( + ((JsonElement)upToken).GetRawText(), + Defaults.JsonSerializerDefaultOptions + ); } catch (JsonException) { throw new FormatException( - $"Could not convert {((JsonElement)upToken).GetRawText()} to {typeof(TUserProperty).Name}"); + $"Could not convert {((JsonElement)upToken).GetRawText()} to {typeof(TUserProperty).Name}" + ); } break; @@ -106,10 +111,17 @@ public static bool TryGetUserProperty(this TParent paren /// /// the value stored in the userproperty or the default /// iff is null or whitespace - public static TUserProperty GetUserProperty(this TParent parent, string userPropertyKey, - TUserProperty defaultValue) where TParent : IUserProperties + public static TUserProperty GetUserProperty( + this TParent parent, + string userPropertyKey, + TUserProperty defaultValue + ) + where TParent : IUserProperties { - if (parent != null && parent.TryGetUserProperty(userPropertyKey, out TUserProperty actualValue)) + if ( + parent != null + && parent.TryGetUserProperty(userPropertyKey, out TUserProperty actualValue) + ) { return actualValue; } @@ -130,8 +142,12 @@ public static TUserProperty GetUserProperty(this TParent /// object implementing /// Value of the property /// - public static void SetUserProperty(this TParent parent, string userPropertyKey, - TUserProperty value) where TParent : IUserProperties + public static void SetUserProperty( + this TParent parent, + string userPropertyKey, + TUserProperty value + ) + where TParent : IUserProperties { // if user properties don't exist already, create them if (parent.UserProperties == null) @@ -193,8 +209,13 @@ public static void RemoveUserProperty(this TParent parent, string userP /// == /// /// iff is null or whitespace - public static bool UserPropertyEquals(this TParent parent, string userPropertyKey, - TUserProperty other, bool ignoreWrongType = true) where TParent : IUserProperties + public static bool UserPropertyEquals( + this TParent parent, + string userPropertyKey, + TUserProperty other, + bool ignoreWrongType = true + ) + where TParent : IUserProperties { if (parent.UserProperties == null) { @@ -203,7 +224,9 @@ public static bool UserPropertyEquals(this TParent paren try { - return parent.EvaluateUserProperty(userPropertyKey, value => + return parent.EvaluateUserProperty( + userPropertyKey, + value => { if (value == null && other != null) { @@ -232,7 +255,10 @@ public static bool UserPropertyEquals(this TParent paren /// result of if the key exists, default otherwise /// iff is null or whitespace public static TEvaluationResult EvaluateUserProperty( - this TParent parent, string userPropertyKey, Func evaluation) + this TParent parent, + string userPropertyKey, + Func evaluation + ) where TParent : IUserProperties { var up = parent.UserProperties; @@ -295,7 +321,10 @@ public static bool SetFlag(this TParent parent, string flagKey, bool? f try { - if (parent.TryGetUserProperty(flagKey, out var existingValue) && existingValue == flagValue.Value) + if ( + parent.TryGetUserProperty(flagKey, out var existingValue) + && existingValue == flagValue.Value + ) { return false; } diff --git a/BO4E/meta/Bo4eUri.cs b/BO4E/meta/Bo4eUri.cs index f373f714..1007ed37 100644 --- a/BO4E/meta/Bo4eUri.cs +++ b/BO4E/meta/Bo4eUri.cs @@ -22,17 +22,18 @@ public class Bo4eUri : Uri private const string Bo4EScheme = "bo4e://"; private const string NullKeyPlaceholder = "~"; // an allowed character in URLs that is not escaped - private static readonly Regex FilterAndPattern = - new Regex(@"\s*(?\w+)\s*(?:=|eq)\s*(['""]|)(?\w+)\1\s*(?:and)?\s*", - RegexOptions.IgnoreCase | - RegexOptions.Compiled); // \1 backreferences the '" group (in c#, would be \2 in other parsers) + private static readonly Regex FilterAndPattern = new Regex( + @"\s*(?\w+)\s*(?:=|eq)\s*(['""]|)(?\w+)\1\s*(?:and)?\s*", + RegexOptions.IgnoreCase | RegexOptions.Compiled + ); // \1 backreferences the '" group (in c#, would be \2 in other parsers) /// /// Instantiates a Bo4eUri object. Throws Argument(Null)Exception if URI is null, not well formed ( /// or doesn't match the bo4e uri regex. /// /// URI string to be processed - public Bo4eUri(string uri) : base(uri) + public Bo4eUri(string uri) + : base(uri) { if (uri == null) { @@ -45,7 +46,9 @@ public Bo4eUri(string uri) : base(uri) }*/ if (Scheme + "://" != Bo4EScheme) { - throw new ArgumentException($"The scheme '{Scheme}' in {uri} is not valid. Expected '{Bo4EScheme}://'"); + throw new ArgumentException( + $"The scheme '{Scheme}' in {uri} is not valid. Expected '{Bo4EScheme}://'" + ); } if (GetBoName() == null) @@ -70,7 +73,9 @@ public static implicit operator Bo4eUri(string input) public string GetBoName() { #pragma warning disable CS0618 // Type or member is obsolete - return BoMapper.GetValidBoNames().FirstOrDefault(boName => boName.ToUpper().Equals(Host.ToUpper())); + return BoMapper + .GetValidBoNames() + .FirstOrDefault(boName => boName.ToUpper().Equals(Host.ToUpper())); #pragma warning restore CS0618 // Type or member is obsolete } @@ -96,7 +101,8 @@ public static string FullyUnescapeDataString(string stringToUnescape) // https://stackoverflow.com/a/3847593/10009545 // But why? string result; - while ((result = UnescapeDataString(stringToUnescape)) != stringToUnescape) stringToUnescape = result; + while ((result = UnescapeDataString(stringToUnescape)) != stringToUnescape) + stringToUnescape = result; return result; } @@ -169,13 +175,15 @@ public static Bo4eUri GetUri(BusinessObject bo, bool includeUserProperties = fal else if (keyProp.GetValue(bo).GetType().IsSubclassOf(typeof(BusinessObject))) { var innerBo = (BusinessObject)keyProp.GetValue(bo); - relativeUriBuilder.Append(GetUri(innerBo) - .GetComponents(UriComponents.Path, UriFormat.UriEscaped)); + relativeUriBuilder.Append( + GetUri(innerBo).GetComponents(UriComponents.Path, UriFormat.UriEscaped) + ); } else { throw new NotImplementedException( - $"Using {keyProp.GetValue(bo).GetType()} as [BoKey] is not supported yet."); + $"Using {keyProp.GetValue(bo).GetType()} as [BoKey] is not supported yet." + ); } } else @@ -201,7 +209,9 @@ public static Bo4eUri GetUri(BusinessObject bo, bool includeUserProperties = fal #pragma warning disable SYSLIB0013 var relativeUri = new Uri(EscapeUriString(relativeUriBuilder.ToString()), UriKind.Relative); #pragma warning restore SYSLIB0013 - return TryCreate(baseUri, relativeUri, out var resultUri) ? new Bo4eUri(resultUri.AbsoluteUri) : null; + return TryCreate(baseUri, relativeUri, out var resultUri) + ? new Bo4eUri(resultUri.AbsoluteUri) + : null; } private static IList GetKeyFields(BusinessObject bo) @@ -216,21 +226,25 @@ private static IList GetKeyFields(BusinessObject bo) private static IList GetKeyProperties(Type boType) { - var allKeyProperties = boType.GetProperties() + var allKeyProperties = boType + .GetProperties() .Where(p => p.GetCustomAttributes(typeof(BoKey), false).Length > 0) .OrderBy(af => af.GetCustomAttribute()?.Order) .ToArray(); if (allKeyProperties.Length == 0) { throw new NotImplementedException( - $"Business Object {boType.Name} has no [BoKey] defined => can't create URI."); + $"Business Object {boType.Name} has no [BoKey] defined => can't create URI." + ); } IList ownKeyProps = new List(); var ignoreInheritedFields = false; // default foreach (var keyProp in allKeyProperties) - if (keyProp.DeclaringType == boType - && keyProp.GetCustomAttribute().IgnoreInheritedKeys) + if ( + keyProp.DeclaringType == boType + && keyProp.GetCustomAttribute().IgnoreInheritedKeys + ) { ignoreInheritedFields = true; ownKeyProps.Add(keyProp); @@ -317,7 +331,8 @@ public JObject GetQueryObject(Type boType = null, int i = 0) else { throw new ArgumentException( - $"Key segment {keyPropName} could not be parsed as int although an integer type was expected!"); + $"Key segment {keyPropName} could not be parsed as int although an integer type was expected!" + ); } } else if (keyProp.PropertyType.IsSubclassOf(typeof(BusinessObject))) @@ -327,15 +342,15 @@ public JObject GetQueryObject(Type boType = null, int i = 0) } else { - throw new NotImplementedException($"Using {keyProp.PropertyType} as [BoKey] is not supported yet."); + throw new NotImplementedException( + $"Using {keyProp.PropertyType} as [BoKey] is not supported yet." + ); } } var query = HttpUtility.ParseQueryString(Query); var boProps = GetBoType().GetProperties().Select(p => p.Name); - if ( - query.AllKeys - .Contains("filter")) // currently this pattern only supports AND concatenation, not OR. result should contain multiple JObjects + if (query.AllKeys.Contains("filter")) // currently this pattern only supports AND concatenation, not OR. result should contain multiple JObjects { var filter = query.Get("filter"); foreach (Match match in FilterAndPattern.Matches(filter)) @@ -359,18 +374,20 @@ public Bo4eUri AddFilter(IDictionary filterObject) var boFields = GetBoType().GetProperties().Select(p => p.Name); const string andString = " and "; filterString = filterObject - .Where(kvp => kvp.Value != null && boFields.Contains(kvp.Key, StringComparer.OrdinalIgnoreCase)) - .Aggregate(filterString, (current, kvp) => current + $"{andString}{kvp.Key} eq '{kvp.Value}'"); + .Where(kvp => + kvp.Value != null && boFields.Contains(kvp.Key, StringComparer.OrdinalIgnoreCase) + ) + .Aggregate( + filterString, + (current, kvp) => current + $"{andString}{kvp.Key} eq '{kvp.Value}'" + ); if (filterString.StartsWith(andString)) { filterString = filterString.Substring(andString.Length); } query.Add("filter", filterString); - var ub = new UriBuilder(this) - { - Query = query.ToString() - }; + var ub = new UriBuilder(this) { Query = query.ToString() }; return new Bo4eUri(ub.Uri.ToString()); } } @@ -388,7 +405,11 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT } /// - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom( + ITypeDescriptorContext context, + CultureInfo culture, + object value + ) { if (value is string @string) { diff --git a/BO4E/meta/BoKey.cs b/BO4E/meta/BoKey.cs index 419a504d..a4a86671 100644 --- a/BO4E/meta/BoKey.cs +++ b/BO4E/meta/BoKey.cs @@ -30,4 +30,4 @@ public BoKey(bool ignoreInheritedKeys = false) /// /// public bool IgnoreInheritedKeys { get; } -} \ No newline at end of file +} diff --git a/BO4E/meta/BusinessObjectSerializationBinder.cs b/BO4E/meta/BusinessObjectSerializationBinder.cs index 22a81a61..fc0d898f 100644 --- a/BO4E/meta/BusinessObjectSerializationBinder.cs +++ b/BO4E/meta/BusinessObjectSerializationBinder.cs @@ -13,9 +13,17 @@ public class BusinessObjectSerializationBinder : ISerializationBinder { static BusinessObjectSerializationBinder() { - BusinessObjectAndCOMTypes = typeof(BusinessObject).Assembly.GetTypes().Where(t => - t.IsClass && !t.IsAbstract && - (typeof(BusinessObject).IsAssignableFrom(t) || typeof(COM.COM).IsAssignableFrom(t))).ToList(); + BusinessObjectAndCOMTypes = typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => + t.IsClass + && !t.IsAbstract + && ( + typeof(BusinessObject).IsAssignableFrom(t) + || typeof(COM.COM).IsAssignableFrom(t) + ) + ) + .ToList(); } // implementation is similar to the JSON.net example implementation in the docs: https://www.newtonsoft.com/json/help/html/SerializeSerializationBinder.htm diff --git a/BO4E/meta/CentralEuropeStandardTime.cs b/BO4E/meta/CentralEuropeStandardTime.cs index 1004693c..26cda6a5 100644 --- a/BO4E/meta/CentralEuropeStandardTime.cs +++ b/BO4E/meta/CentralEuropeStandardTime.cs @@ -34,7 +34,9 @@ static CentralEuropeStandardTime() using var jsonReader = new StreamReader(stream); var jsonString = jsonReader.ReadToEnd(); //Console.WriteLine(jsonString); - _CentralEuropeStandardTimezoneInfo = JsonConvert.DeserializeObject(jsonString); + _CentralEuropeStandardTimezoneInfo = JsonConvert.DeserializeObject( + jsonString + ); } /// @@ -43,4 +45,4 @@ static CentralEuropeStandardTime() [Obsolete("Use " + nameof(CentralEuropeStandardTimezoneInfo) + " instead.")] // ReSharper disable once InconsistentNaming public static TimeZoneInfo CENTRAL_EUROPE_STANDARD_TIME => CentralEuropeStandardTimezoneInfo; -} \ No newline at end of file +} diff --git a/BO4E/meta/DataCategoryAttribute.cs b/BO4E/meta/DataCategoryAttribute.cs index b9f88cfb..e732680a 100644 --- a/BO4E/meta/DataCategoryAttribute.cs +++ b/BO4E/meta/DataCategoryAttribute.cs @@ -36,7 +36,8 @@ public DataCategoryAttribute(params object[] enums) } Mapping = new HashSet(); - foreach (Enum e in enums) Mapping.Add(e); + foreach (Enum e in enums) + Mapping.Add(e); } /// diff --git a/BO4E/meta/Defaults.cs b/BO4E/meta/Defaults.cs index 409f161b..3b2eaa8d 100644 --- a/BO4E/meta/Defaults.cs +++ b/BO4E/meta/Defaults.cs @@ -14,6 +14,6 @@ public static class Defaults public static JsonSerializerOptions JsonSerializerDefaultOptions => new JsonSerializerOptions(JsonSerializerDefaults.Web) { - NumberHandling = JsonNumberHandling.AllowReadingFromString + NumberHandling = JsonNumberHandling.AllowReadingFromString, }; -} \ No newline at end of file +} diff --git a/BO4E/meta/FieldName.cs b/BO4E/meta/FieldName.cs index ba8e932e..7ca2ac85 100644 --- a/BO4E/meta/FieldName.cs +++ b/BO4E/meta/FieldName.cs @@ -5,8 +5,14 @@ namespace BO4E.meta; /// /// A Custom attribute for make fields and properties multilingual /// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Field | - AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] +[AttributeUsage( + AttributeTargets.Class + | AttributeTargets.Constructor + | AttributeTargets.Field + | AttributeTargets.Method + | AttributeTargets.Property, + AllowMultiple = true +)] public class FieldName : Attribute { /// diff --git a/BO4E/meta/IOptionalGuid.cs b/BO4E/meta/IOptionalGuid.cs index 7e3231d0..19e1c052 100644 --- a/BO4E/meta/IOptionalGuid.cs +++ b/BO4E/meta/IOptionalGuid.cs @@ -12,4 +12,4 @@ public interface IOptionalGuid /// a nullable Guid that may be used as key in database tables. /// Guid? Guid { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/meta/IUserProperties.cs b/BO4E/meta/IUserProperties.cs index 9f557cf2..81d89d77 100644 --- a/BO4E/meta/IUserProperties.cs +++ b/BO4E/meta/IUserProperties.cs @@ -14,4 +14,4 @@ public interface IUserProperties /// , /// IDictionary? UserProperties { get; set; } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/AutoNumberToStringConverter.cs b/BO4E/meta/LenientConverters/AutoNumberToStringConverter.cs index c507e349..c0474587 100644 --- a/BO4E/meta/LenientConverters/AutoNumberToStringConverter.cs +++ b/BO4E/meta/LenientConverters/AutoNumberToStringConverter.cs @@ -17,10 +17,15 @@ public override bool CanConvert(Type typeToConvert) { return typeof(string) == typeToConvert; } + /// /// /// - public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override string Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TokenType == JsonTokenType.Number) { @@ -43,6 +48,7 @@ public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS using var document = JsonDocument.ParseValue(ref reader); return document.RootElement.Clone().ToString(); } + /// /// /// @@ -50,4 +56,4 @@ public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOp { writer.WriteStringValue(value); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/GasqualitaetStringEnumConverter.cs b/BO4E/meta/LenientConverters/GasqualitaetStringEnumConverter.cs index decd071b..aea2500b 100644 --- a/BO4E/meta/LenientConverters/GasqualitaetStringEnumConverter.cs +++ b/BO4E/meta/LenientConverters/GasqualitaetStringEnumConverter.cs @@ -6,10 +6,15 @@ namespace BO4E.meta.LenientConverters; /// /// converts 'HGAS' to Enum Member Gasqualitaet.H_GAS (and 'LGAS' to Gasqualitaet.L_GAS) /// -public class SystemTextGasqualitaetStringEnumConverter : System.Text.Json.Serialization.JsonConverter +public class SystemTextGasqualitaetStringEnumConverter + : System.Text.Json.Serialization.JsonConverter { /// - public override Gasqualitaet? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + public override Gasqualitaet? Read( + ref System.Text.Json.Utf8JsonReader reader, + Type typeToConvert, + System.Text.Json.JsonSerializerOptions options + ) { if (reader.TokenType == System.Text.Json.JsonTokenType.Null) { @@ -26,12 +31,20 @@ public class SystemTextGasqualitaetStringEnumConverter : System.Text.Json.Serial { "HGAS" => Gasqualitaet.H_GAS, "LGAS" => Gasqualitaet.L_GAS, - _ => Enum.TryParse(enumString, out Gasqualitaet result) ? result : throw new System.Text.Json.JsonException($"Invalid value for {typeToConvert}: {enumString}") + _ => Enum.TryParse(enumString, out Gasqualitaet result) + ? result + : throw new System.Text.Json.JsonException( + $"Invalid value for {typeToConvert}: {enumString}" + ), }; } /// - public override void Write(System.Text.Json.Utf8JsonWriter writer, Gasqualitaet? value, System.Text.Json.JsonSerializerOptions options) + public override void Write( + System.Text.Json.Utf8JsonWriter writer, + Gasqualitaet? value, + System.Text.Json.JsonSerializerOptions options + ) { if (value is null) { @@ -58,10 +71,17 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Gasqualitaet? /// /// /// -public class NewtonsoftGasqualitaetStringEnumConverter : Newtonsoft.Json.JsonConverter +public class NewtonsoftGasqualitaetStringEnumConverter + : Newtonsoft.Json.JsonConverter { /// > - public override Gasqualitaet? ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, Gasqualitaet? existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer) + public override Gasqualitaet? ReadJson( + Newtonsoft.Json.JsonReader reader, + Type objectType, + Gasqualitaet? existingValue, + bool hasExistingValue, + Newtonsoft.Json.JsonSerializer serializer + ) { if (reader.TokenType == Newtonsoft.Json.JsonToken.Null) { @@ -80,14 +100,23 @@ public class NewtonsoftGasqualitaetStringEnumConverter : Newtonsoft.Json.JsonCon { "HGAS" => Gasqualitaet.H_GAS, "LGAS" => Gasqualitaet.L_GAS, - _ => Enum.TryParse(enumString, out Gasqualitaet result) ? result : throw new Newtonsoft.Json.JsonSerializationException($"Invalid value for {objectType}: {enumString}") + _ => Enum.TryParse(enumString, out Gasqualitaet result) + ? result + : throw new Newtonsoft.Json.JsonSerializationException( + $"Invalid value for {objectType}: {enumString}" + ), }; } throw new Newtonsoft.Json.JsonSerializationException("Expected string value."); } + /// - public override void WriteJson(Newtonsoft.Json.JsonWriter writer, Gasqualitaet? value, Newtonsoft.Json.JsonSerializer serializer) + public override void WriteJson( + Newtonsoft.Json.JsonWriter writer, + Gasqualitaet? value, + Newtonsoft.Json.JsonSerializer serializer + ) { if (value is null) { diff --git a/BO4E/meta/LenientConverters/LenientBo4eUriConverter.cs b/BO4E/meta/LenientConverters/LenientBo4eUriConverter.cs index bd569d53..160b628a 100644 --- a/BO4E/meta/LenientConverters/LenientBo4eUriConverter.cs +++ b/BO4E/meta/LenientConverters/LenientBo4eUriConverter.cs @@ -19,8 +19,12 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) { if (reader.Value == null) { diff --git a/BO4E/meta/LenientConverters/LenientDateTimeConverter.cs b/BO4E/meta/LenientConverters/LenientDateTimeConverter.cs index 03c3b2ab..a852cff3 100644 --- a/BO4E/meta/LenientConverters/LenientDateTimeConverter.cs +++ b/BO4E/meta/LenientConverters/LenientDateTimeConverter.cs @@ -15,8 +15,9 @@ public class LenientDateTimeConverter : IsoDateTimeConverter { private readonly List<(string, bool)> _allowedDatetimeFormats = [ - ("yyyy-MM-ddTHH:mm:sszzzz", true) + ("yyyy-MM-ddTHH:mm:sszzzz", true), ]; + // basic structure copied from https://stackoverflow.com/a/33172735/10009545 private readonly DateTimeOffset? _defaultDateTime; @@ -33,9 +34,8 @@ public LenientDateTimeConverter(DateTimeOffset? defaultDateTime = null) /// /// initialize using no default datetime /// - public LenientDateTimeConverter() : this(null) - { - } + public LenientDateTimeConverter() + : this(null) { } /// public override bool CanWrite => false; @@ -44,14 +44,18 @@ public LenientDateTimeConverter() : this(null) public override bool CanConvert(Type objectType) { return objectType == typeof(DateTimeOffset) - || objectType == typeof(DateTimeOffset?) - || objectType == typeof(DateTime) - || objectType == typeof(DateTime?); + || objectType == typeof(DateTimeOffset?) + || objectType == typeof(DateTime) + || objectType == typeof(DateTime?); } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) { string rawDate; switch (reader.Value) @@ -73,14 +77,28 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist // First try to parse the date string as is (in case it is correctly formatted) if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?)) { - if (DateTimeOffset.TryParse(rawDate, CultureInfo.CurrentCulture, DateTimeStyles.AssumeUniversal, out var dateTimeOffset)) + if ( + DateTimeOffset.TryParse( + rawDate, + CultureInfo.CurrentCulture, + DateTimeStyles.AssumeUniversal, + out var dateTimeOffset + ) + ) { return dateTimeOffset; } foreach (var (dtf, asUniversal) in _allowedDatetimeFormats) - if (DateTimeOffset.TryParseExact(rawDate, dtf, CultureInfo.InvariantCulture, - asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, out dateTimeOffset)) + if ( + DateTimeOffset.TryParseExact( + rawDate, + dtf, + CultureInfo.InvariantCulture, + asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, + out dateTimeOffset + ) + ) { return dateTimeOffset; } @@ -92,8 +110,17 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return dateTime; } - if (_allowedDatetimeFormats.Any(dtf => DateTime.TryParseExact(rawDate, dtf.Item1, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))) + if ( + _allowedDatetimeFormats.Any(dtf => + DateTime.TryParseExact( + rawDate, + dtf.Item1, + CultureInfo.InvariantCulture, + DateTimeStyles.None, + out dateTime + ) + ) + ) { return dateTime; } @@ -114,8 +141,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { return base.ReadJson(reader, objectType, existingValue, serializer); } - catch (FormatException fe) when (fe.Message == - "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999.") + catch (FormatException fe) + when (fe.Message + == "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999." + ) { if (objectType == typeof(DateTime)) { @@ -129,8 +158,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return DateTimeOffset.MinValue; } - catch (ArgumentOutOfRangeException ae) when (ae.Message == - "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')") + catch (ArgumentOutOfRangeException ae) + when (ae.Message + == "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')" + ) { if (objectType == typeof(DateTime)) { diff --git a/BO4E/meta/LenientConverters/LenientDictionaryConverter.cs b/BO4E/meta/LenientConverters/LenientDictionaryConverter.cs index 4a1f5860..16eefa32 100644 --- a/BO4E/meta/LenientConverters/LenientDictionaryConverter.cs +++ b/BO4E/meta/LenientConverters/LenientDictionaryConverter.cs @@ -28,12 +28,17 @@ public override bool CanConvert(Type typeToConvert) /// The type we want to construct /// any json serializer options /// - public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) + public override Dictionary Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TokenType != JsonTokenType.StartObject) { - throw new JsonException($"JsonTokenType was of type {reader.TokenType}, only objects are supported"); + throw new JsonException( + $"JsonTokenType was of type {reader.TokenType}, only objects are supported" + ); } var dictionary = new Dictionary(); @@ -70,12 +75,16 @@ public override Dictionary Read(ref Utf8JsonReader reader, Type /// a json writer to write to /// the value of the dictionary we want to write to /// a jsonserializeroptions object to give custom options - public override void Write(Utf8JsonWriter writer, Dictionary value, - JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + Dictionary value, + JsonSerializerOptions options + ) { writer.WriteStartObject(); - foreach (var key in value.Keys) HandleValue(writer, key, value[key]); + foreach (var key in value.Keys) + HandleValue(writer, key, value[key]); writer.WriteEndObject(); } @@ -115,12 +124,14 @@ private static void HandleValue(Utf8JsonWriter writer, string key, object object break; case Dictionary dict: writer.WriteStartObject(); - foreach (var item in dict) HandleValue(writer, item.Key, item.Value); + foreach (var item in dict) + HandleValue(writer, item.Key, item.Value); writer.WriteEndObject(); break; case object[] array: writer.WriteStartArray(); - foreach (var item in array) HandleValue(writer, item); + foreach (var item in array) + HandleValue(writer, item); writer.WriteEndArray(); break; default: diff --git a/BO4E/meta/LenientConverters/LenientEnumListConverter.cs b/BO4E/meta/LenientConverters/LenientEnumListConverter.cs index b440e9f6..db453955 100644 --- a/BO4E/meta/LenientConverters/LenientEnumListConverter.cs +++ b/BO4E/meta/LenientConverters/LenientEnumListConverter.cs @@ -33,8 +33,12 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) { var token = JToken.Load(reader); // https://stackoverflow.com/a/47864946/10009545 var rawList = token.ToObject>(); @@ -74,4 +78,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/LenientGeraetemerkmalGasConverter.cs b/BO4E/meta/LenientConverters/LenientGeraetemerkmalGasConverter.cs index 40f69092..b68b3105 100644 --- a/BO4E/meta/LenientConverters/LenientGeraetemerkmalGasConverter.cs +++ b/BO4E/meta/LenientConverters/LenientGeraetemerkmalGasConverter.cs @@ -18,7 +18,7 @@ public class LenientGeraetemerkmalGasConverter : JsonConverter public override bool CanConvert(Type objectType) { return objectType == typeof(BO4E.ENUM.Geraetemerkmal) - || objectType == typeof(BO4E.ENUM.Geraetemerkmal?); + || objectType == typeof(BO4E.ENUM.Geraetemerkmal?); } /// @@ -61,4 +61,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/LenientJsonSerializerOptionsGenerator.cs b/BO4E/meta/LenientConverters/LenientJsonSerializerOptionsGenerator.cs index 0ca46b2d..35f6e5b5 100644 --- a/BO4E/meta/LenientConverters/LenientJsonSerializerOptionsGenerator.cs +++ b/BO4E/meta/LenientConverters/LenientJsonSerializerOptionsGenerator.cs @@ -1,9 +1,9 @@ -using BO4E.BO; using System; using System.Collections.Generic; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; +using BO4E.BO; namespace BO4E.meta.LenientConverters; @@ -29,14 +29,16 @@ public static JsonSerializerOptions GetJsonSerializerOptions(this LenientParsing /// /// /// - public static JsonSerializerOptions GetJsonSerializerOptions(this LenientParsing lenient, - HashSet userPropertiesWhiteList) + public static JsonSerializerOptions GetJsonSerializerOptions( + this LenientParsing lenient, + HashSet userPropertiesWhiteList + ) { var settings = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, NumberHandling = JsonNumberHandling.AllowReadingFromString, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, }; settings.Converters.Add(new AutoNumberToStringConverter()); settings.Converters.Add(new VertragsConverter()); @@ -56,17 +58,37 @@ public static JsonSerializerOptions GetJsonSerializerOptions(this LenientParsing case LenientParsing.DATE_TIME: if (lenient.HasFlag(LenientParsing.SET_INITIAL_DATE_IF_NULL)) { - settings.Converters.Add(new LenientSystemTextJsonDateTimeConverter(new DateTimeOffset())); - settings.Converters.Add(new LenientSystemTextJsonNullableDateTimeConverter(new DateTimeOffset())); - settings.Converters.Add(new LenientSystemTextJsonDateTimeOffsetConverter(new DateTimeOffset())); - settings.Converters.Add(new LenientSystemTextJsonNullableDateTimeOffsetConverter(new DateTimeOffset())); + settings.Converters.Add( + new LenientSystemTextJsonDateTimeConverter(new DateTimeOffset()) + ); + settings.Converters.Add( + new LenientSystemTextJsonNullableDateTimeConverter( + new DateTimeOffset() + ) + ); + settings.Converters.Add( + new LenientSystemTextJsonDateTimeOffsetConverter( + new DateTimeOffset() + ) + ); + settings.Converters.Add( + new LenientSystemTextJsonNullableDateTimeOffsetConverter( + new DateTimeOffset() + ) + ); } else { settings.Converters.Add(new LenientSystemTextJsonDateTimeConverter()); - settings.Converters.Add(new LenientSystemTextJsonDateTimeOffsetConverter()); - settings.Converters.Add(new LenientSystemTextJsonNullableDateTimeConverter()); - settings.Converters.Add(new LenientSystemTextJsonNullableDateTimeOffsetConverter()); + settings.Converters.Add( + new LenientSystemTextJsonDateTimeOffsetConverter() + ); + settings.Converters.Add( + new LenientSystemTextJsonNullableDateTimeConverter() + ); + settings.Converters.Add( + new LenientSystemTextJsonNullableDateTimeOffsetConverter() + ); } break; @@ -82,11 +104,11 @@ public static JsonSerializerOptions GetJsonSerializerOptions(this LenientParsing case LenientParsing.STRING_TO_INT: settings.Converters.Add(new LenientSystemTextJsonStringToIntConverter()); break; - // case LenientParsing.EmptyLists: - // converters.Add(new LenientRequiredListConverter()); - // break; + // case LenientParsing.EmptyLists: + // converters.Add(new LenientRequiredListConverter()); + // break; - // no default case because NONE and MOST_LENIENT do not come up with more converters + // no default case because NONE and MOST_LENIENT do not come up with more converters } } //IContractResolver contractResolver; diff --git a/BO4E/meta/LenientConverters/LenientJsonSerializerSettingsGenerator.cs b/BO4E/meta/LenientConverters/LenientJsonSerializerSettingsGenerator.cs index 8f32957f..fcd97f25 100644 --- a/BO4E/meta/LenientConverters/LenientJsonSerializerSettingsGenerator.cs +++ b/BO4E/meta/LenientConverters/LenientJsonSerializerSettingsGenerator.cs @@ -28,8 +28,10 @@ public static JsonSerializerSettings GetJsonSerializerSettings(this LenientParsi /// /// /// - public static JsonSerializerSettings GetJsonSerializerSettings(this LenientParsing lenient, - HashSet userPropertiesWhiteList) + public static JsonSerializerSettings GetJsonSerializerSettings( + this LenientParsing lenient, + HashSet userPropertiesWhiteList + ) { var converters = new List(); foreach (LenientParsing lp in Enum.GetValues(typeof(LenientParsing))) @@ -39,9 +41,11 @@ public static JsonSerializerSettings GetJsonSerializerSettings(this LenientParsi switch (lp) { case LenientParsing.DATE_TIME: - converters.Add(!lenient.HasFlag(LenientParsing.SET_INITIAL_DATE_IF_NULL) - ? new LenientDateTimeConverter() - : new LenientDateTimeConverter(new DateTimeOffset())); + converters.Add( + !lenient.HasFlag(LenientParsing.SET_INITIAL_DATE_IF_NULL) + ? new LenientDateTimeConverter() + : new LenientDateTimeConverter(new DateTimeOffset()) + ); break; case LenientParsing.ENUM_LIST: @@ -55,16 +59,17 @@ public static JsonSerializerSettings GetJsonSerializerSettings(this LenientParsi case LenientParsing.STRING_TO_INT: converters.Add(new LenientStringToIntConverter()); break; - // case LenientParsing.EmptyLists: - // converters.Add(new LenientRequiredListConverter()); - // break; + // case LenientParsing.EmptyLists: + // converters.Add(new LenientRequiredListConverter()); + // break; - // no default case because NONE and MOST_LENIENT do not come up with more converters + // no default case because NONE and MOST_LENIENT do not come up with more converters } } - IContractResolver contractResolver = userPropertiesWhiteList.Count > 0 - ? new UserPropertiesDataContractResolver(userPropertiesWhiteList) - : new DefaultContractResolver(); + IContractResolver contractResolver = + userPropertiesWhiteList.Count > 0 + ? new UserPropertiesDataContractResolver(userPropertiesWhiteList) + : new DefaultContractResolver(); if (lenient.HasFlag(LenientParsing.MOST_LENIENT)) { converters.Insert(index: 0, item: new NewtonsoftGasqualitaetStringEnumConverter()); @@ -75,7 +80,7 @@ public static JsonSerializerSettings GetJsonSerializerSettings(this LenientParsi { Converters = converters, DateParseHandling = DateParseHandling.None, - ContractResolver = contractResolver + ContractResolver = contractResolver, }; return settings; } diff --git a/BO4E/meta/LenientConverters/LenientParsing.cs b/BO4E/meta/LenientConverters/LenientParsing.cs index a2fb27e5..52c7c9c0 100644 --- a/BO4E/meta/LenientConverters/LenientParsing.cs +++ b/BO4E/meta/LenientConverters/LenientParsing.cs @@ -55,5 +55,5 @@ public enum LenientParsing /// most lenient (all others) /// [EnumMember(Value = "MOST_LENIENT")] - MOST_LENIENT = ~0 -} \ No newline at end of file + MOST_LENIENT = ~0, +} diff --git a/BO4E/meta/LenientConverters/LenientStringToIntConverter.cs b/BO4E/meta/LenientConverters/LenientStringToIntConverter.cs index 6adad992..7a9b657c 100644 --- a/BO4E/meta/LenientConverters/LenientStringToIntConverter.cs +++ b/BO4E/meta/LenientConverters/LenientStringToIntConverter.cs @@ -21,8 +21,12 @@ public override bool CanConvert(Type objectType) } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object ReadJson( + JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer + ) { if (reader.Value == null) { @@ -48,4 +52,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/LenientSystemTextGeraetemerkmalGasConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextGeraetemerkmalGasConverter.cs index d879010a..0fc5a350 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextGeraetemerkmalGasConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextGeraetemerkmalGasConverter.cs @@ -1,8 +1,8 @@ using System; using System.Text.Json; +using System.Text.RegularExpressions; using BO4E.ENUM; using EnumsNET; -using System.Text.RegularExpressions; namespace BO4E.meta.LenientConverters; @@ -44,7 +44,8 @@ JsonSerializerOptions options /// /// https://regex101.com/r/dAUAHL/1 /// - private static readonly Regex GasPrefixRegex = new(@"^(?(?:GAS_)?)(?.+)$", RegexOptions.Compiled); + private static readonly Regex GasPrefixRegex = + new(@"^(?(?:GAS_)?)(?.+)$", RegexOptions.Compiled); /// /// @@ -109,7 +110,8 @@ JsonSerializerOptions options /// /// https://regex101.com/r/dAUAHL/1 /// - private static readonly Regex GasPrefixRegex = new(@"^(?(?:GAS_)?)(?.+)$", RegexOptions.Compiled); + private static readonly Regex GasPrefixRegex = + new(@"^(?(?:GAS_)?)(?.+)$", RegexOptions.Compiled); /// /// diff --git a/BO4E/meta/LenientConverters/LenientSystemTextJsonDateTimeConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextJsonDateTimeConverter.cs index 0e15ac58..66260f15 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextJsonDateTimeConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextJsonDateTimeConverter.cs @@ -19,7 +19,7 @@ public class LenientSystemTextJsonDateTimeConverter : JsonConverter ("yyyy-MM-ddTHH:mm:sszzzz", true), ("yyyyMMddHHmm", false), ("yyyyMMddHHmmss", false), - ("yyyyMMddHHmmss'--T::zzzz'", false) + ("yyyyMMddHHmmss'--T::zzzz'", false), ]; private readonly DateTimeOffset? _defaultDateTime; @@ -36,9 +36,8 @@ public LenientSystemTextJsonDateTimeConverter(DateTimeOffset? defaultDateTime = /// /// initialize using no default datetime /// - public LenientSystemTextJsonDateTimeConverter() : this(null) - { - } + public LenientSystemTextJsonDateTimeConverter() + : this(null) { } /// /// @@ -46,7 +45,11 @@ public LenientSystemTextJsonDateTimeConverter() : this(null) /// /// /// - public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override DateTime Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TryGetDateTime(out var dt)) { @@ -63,8 +66,15 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso } foreach (var (dtf, asUniversal) in _allowedDatetimeFormats) - if (DateTimeOffset.TryParseExact(rawDate, dtf, CultureInfo.InvariantCulture, - asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, out dateTimeOffset)) + if ( + DateTimeOffset.TryParseExact( + rawDate, + dtf, + CultureInfo.InvariantCulture, + asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, + out dateTimeOffset + ) + ) { return dateTimeOffset.DateTime; } @@ -76,8 +86,17 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } - if (_allowedDatetimeFormats.Any(dtf => DateTime.TryParseExact(rawDate, dtf.Item1, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))) + if ( + _allowedDatetimeFormats.Any(dtf => + DateTime.TryParseExact( + rawDate, + dtf.Item1, + CultureInfo.InvariantCulture, + DateTimeStyles.None, + out dateTime + ) + ) + ) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } @@ -92,8 +111,10 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso { return JsonSerializer.Deserialize(ref reader); } - catch (FormatException fe) when (fe.Message == - "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999.") + catch (FormatException fe) + when (fe.Message + == "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999." + ) { if (typeToConvert == typeof(DateTime)) { @@ -102,8 +123,10 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso return DateTime.MinValue; } - catch (ArgumentOutOfRangeException ae) when (ae.Message == - "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')") + catch (ArgumentOutOfRangeException ae) + when (ae.Message + == "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')" + ) { if (typeToConvert == typeof(DateTime)) { @@ -137,7 +160,11 @@ public class LenientSystemTextJsonNullableDateTimeConverter : JsonConverter /// initialize using no default datetime /// - public LenientSystemTextJsonNullableDateTimeConverter() : this(null) - { - } + public LenientSystemTextJsonNullableDateTimeConverter() + : this(null) { } /// /// @@ -164,7 +190,11 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) /// /// /// - public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override DateTime? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TryGetDateTimeOffset(out var dto)) { @@ -186,8 +216,15 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) } foreach (var (dtf, asUniversal) in _allowedDatetimeFormats) - if (DateTimeOffset.TryParseExact(rawDate, dtf, CultureInfo.InvariantCulture, - asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, out dateTimeOffset)) + if ( + DateTimeOffset.TryParseExact( + rawDate, + dtf, + CultureInfo.InvariantCulture, + asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, + out dateTimeOffset + ) + ) { return dateTimeOffset.DateTime; } @@ -199,8 +236,17 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } - if (_allowedDatetimeFormats.Any(dtf => DateTime.TryParseExact(rawDate, dtf.Item1, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))) + if ( + _allowedDatetimeFormats.Any(dtf => + DateTime.TryParseExact( + rawDate, + dtf.Item1, + CultureInfo.InvariantCulture, + DateTimeStyles.None, + out dateTime + ) + ) + ) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } @@ -215,8 +261,10 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) { return JsonSerializer.Deserialize(ref reader); } - catch (FormatException fe) when (fe.Message == - "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999.") + catch (FormatException fe) + when (fe.Message + == "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999." + ) { if (typeToConvert == typeof(DateTime)) { @@ -225,15 +273,16 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) return null; } - catch (ArgumentOutOfRangeException ae) when (ae.Message == - "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')") + catch (ArgumentOutOfRangeException ae) + when (ae.Message + == "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')" + ) { if (typeToConvert == typeof(DateTime)) { return DateTime.MinValue; } - return null; } } @@ -243,7 +292,11 @@ public LenientSystemTextJsonNullableDateTimeConverter() : this(null) /// /// /// - public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + DateTime? value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value); } @@ -261,7 +314,11 @@ public class LenientSystemTextJsonDateTimeOffsetConverter : JsonConverter /// initialize using no default datetime /// - public LenientSystemTextJsonDateTimeOffsetConverter() : this(null) - { - } - + public LenientSystemTextJsonDateTimeOffsetConverter() + : this(null) { } /// /// @@ -289,8 +344,11 @@ public LenientSystemTextJsonDateTimeOffsetConverter() : this(null) /// /// /// - public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) + public override DateTimeOffset Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TryGetDateTimeOffset(out var dto)) { @@ -312,8 +370,15 @@ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConver } foreach (var (dtf, asUniversal) in _allowedDatetimeFormats) - if (DateTimeOffset.TryParseExact(rawDate, dtf, CultureInfo.InvariantCulture, - asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, out dateTimeOffset)) + if ( + DateTimeOffset.TryParseExact( + rawDate, + dtf, + CultureInfo.InvariantCulture, + asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, + out dateTimeOffset + ) + ) { return dateTimeOffset; } @@ -325,8 +390,17 @@ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConver return dateTime; } - if (_allowedDatetimeFormats.Any(dtf => DateTime.TryParseExact(rawDate, dtf.Item1, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))) + if ( + _allowedDatetimeFormats.Any(dtf => + DateTime.TryParseExact( + rawDate, + dtf.Item1, + CultureInfo.InvariantCulture, + DateTimeStyles.None, + out dateTime + ) + ) + ) { return dateTime; } @@ -345,8 +419,10 @@ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConver { return DateTimeOffset.MinValue; } - catch (FormatException fe) when (fe.Message == - "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999.") + catch (FormatException fe) + when (fe.Message + == "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999." + ) { if (typeToConvert == typeof(DateTime)) { @@ -355,15 +431,16 @@ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConver return DateTimeOffset.MinValue; } - catch (ArgumentOutOfRangeException ae) when (ae.Message == - "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')") + catch (ArgumentOutOfRangeException ae) + when (ae.Message + == "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')" + ) { if (typeToConvert == typeof(DateTime)) { return DateTime.MinValue; } - return DateTimeOffset.MinValue; } } @@ -373,7 +450,11 @@ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConver /// /// /// - public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + DateTimeOffset value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value); } @@ -391,7 +472,11 @@ public class LenientSystemTextJsonNullableDateTimeOffsetConverter : JsonConverte ("yyyy-MM-ddTHH:mm:sszzzz", true), ("yyyyMMddHHmm", false), ("yyyyMMddHHmmss", false), - (@"yyyyMMddHHmmss'--T::zzzz'", false) // ToDo: remove again. this is just a buggy, nasty workaround + ( + @"yyyyMMddHHmmss'--T::zzzz'", + false + ) // ToDo: remove again. this is just a buggy, nasty workaround + , }; private readonly DateTimeOffset? _defaultDateTime; @@ -400,7 +485,9 @@ public class LenientSystemTextJsonNullableDateTimeOffsetConverter : JsonConverte /// initialize using a default date time /// /// - public LenientSystemTextJsonNullableDateTimeOffsetConverter(DateTimeOffset? defaultDateTime = null) + public LenientSystemTextJsonNullableDateTimeOffsetConverter( + DateTimeOffset? defaultDateTime = null + ) { _defaultDateTime = defaultDateTime; } @@ -408,10 +495,8 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter(DateTimeOffset? defa /// /// initialize using no default datetime /// - public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) - { - } - + public LenientSystemTextJsonNullableDateTimeOffsetConverter() + : this(null) { } /// /// @@ -419,15 +504,17 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) /// /// /// - public override DateTimeOffset? Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) + public override DateTimeOffset? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (reader.TryGetDateTimeOffset(out var dto)) { return dto; } - var rawDate = reader.GetString(); // First try to parse the date string as is (in case it is correctly formatted) if (typeToConvert == typeof(DateTimeOffset) || typeToConvert == typeof(DateTimeOffset?)) @@ -438,8 +525,15 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) } foreach (var (dtf, asUniversal) in _allowedDatetimeFormats) - if (DateTimeOffset.TryParseExact(rawDate, dtf, CultureInfo.InvariantCulture, - asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, out dateTimeOffset)) + if ( + DateTimeOffset.TryParseExact( + rawDate, + dtf, + CultureInfo.InvariantCulture, + asUniversal ? DateTimeStyles.AssumeUniversal : DateTimeStyles.None, + out dateTimeOffset + ) + ) { return dateTimeOffset; } @@ -451,8 +545,17 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) return dateTime; } - if (_allowedDatetimeFormats.Any(dtf => DateTime.TryParseExact(rawDate, dtf.Item1, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))) + if ( + _allowedDatetimeFormats.Any(dtf => + DateTime.TryParseExact( + rawDate, + dtf.Item1, + CultureInfo.InvariantCulture, + DateTimeStyles.None, + out dateTime + ) + ) + ) { return dateTime; } @@ -471,8 +574,10 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) { return null; } - catch (FormatException fe) when (fe.Message == - "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999.") + catch (FormatException fe) + when (fe.Message + == "The UTC representation of the date '0001-01-01T00:00:00' falls outside the year range 1-9999." + ) { if (typeToConvert == typeof(DateTime)) { @@ -481,15 +586,16 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) return DateTimeOffset.MinValue; } - catch (ArgumentOutOfRangeException ae) when (ae.Message == - "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')") + catch (ArgumentOutOfRangeException ae) + when (ae.Message + == "The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')" + ) { if (typeToConvert == typeof(DateTime)) { return DateTime.MinValue; } - return DateTimeOffset.MinValue; } } @@ -499,8 +605,12 @@ public LenientSystemTextJsonNullableDateTimeOffsetConverter() : this(null) /// /// /// - public override void Write(Utf8JsonWriter writer, DateTimeOffset? value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + DateTimeOffset? value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs index d25d70d9..4ffbfd98 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextJsonEnumListConverter.cs @@ -40,13 +40,17 @@ public override bool CanConvert(Type typeToConvert) /// public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) { - var converter = (JsonConverter)Activator.CreateInstance( - typeof(LenientSystemTextJsonEnumListConverter<,>).MakeGenericType(typeToConvert, - typeToConvert.GetGenericArguments().First()), - BindingFlags.Instance | BindingFlags.Public, - null, - null, - null); + var converter = (JsonConverter) + Activator.CreateInstance( + typeof(LenientSystemTextJsonEnumListConverter<,>).MakeGenericType( + typeToConvert, + typeToConvert.GetGenericArguments().First() + ), + BindingFlags.Instance | BindingFlags.Public, + null, + null, + null + ); return converter; } @@ -56,7 +60,8 @@ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializer /// allows to deserialize a list of enums (see tests) /// public class LenientSystemTextJsonEnumListConverter : JsonConverter - where T : List where TE : struct, Enum + where T : List + where TE : struct, Enum { /// public override bool CanConvert(Type objectType) @@ -81,7 +86,11 @@ public override bool CanConvert(Type objectType) /// /// /// - public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override T Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { var rawList = JsonSerializer.Deserialize>(ref reader); var expectedListElementType = typeToConvert.GetGenericArguments()[0]; @@ -97,23 +106,33 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial switch (rawItem) { case object _ when Enum.TryParse(rawItem.ToString(), true, out TE enumResult): - { - // default. everything is as it should be :-) + { + // default. everything is as it should be :-) - ((IList)result).Add(enumResult); - break; - } + ((IList)result).Add(enumResult); + break; + } case JsonElement element: try { - var rawDict = JsonSerializer.Deserialize>(element.GetRawText()); + var rawDict = JsonSerializer.Deserialize>( + element.GetRawText() + ); var rawObject = rawDict.Values.FirstOrDefault(); - var enumValue = Enum.Parse(expectedListElementType, rawObject.ToString(), true); + var enumValue = Enum.Parse( + expectedListElementType, + rawObject.ToString(), + true + ); ((IList)result).Add(enumValue); } catch (Exception) { - var enumValue = Enum.Parse(expectedListElementType, element.GetString(), true); + var enumValue = Enum.Parse( + expectedListElementType, + element.GetString(), + true + ); ((IList)result).Add(enumValue); } @@ -136,7 +155,8 @@ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions if (value.Any()) { writer.WriteStartArray(); - foreach (var val in value) JsonSerializer.Serialize(writer, val, typeof(TE), options); + foreach (var val in value) + JsonSerializer.Serialize(writer, val, typeof(TE), options); writer.WriteEndArray(); } @@ -145,4 +165,4 @@ public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions writer.WriteNullValue(); } } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToBoolConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToBoolConverter.cs index 6ea8d747..95e31326 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToBoolConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToBoolConverter.cs @@ -19,7 +19,11 @@ public class LenientSystemTextJsonStringToBoolConverter : JsonConverter /// /// /// - public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override bool Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { switch (reader.TokenType) { diff --git a/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToIntConverter.cs b/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToIntConverter.cs index db8f2408..ca9fa890 100644 --- a/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToIntConverter.cs +++ b/BO4E/meta/LenientConverters/LenientSystemTextJsonStringToIntConverter.cs @@ -22,22 +22,26 @@ public class LenientSystemTextJsonStringToIntConverter : JsonConverter /// /// /// - public override int? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override int? Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { switch (reader.TokenType) { case JsonTokenType.Null: return null; case JsonTokenType.String: + { + var numeric = new string(reader.GetString().Where(char.IsDigit).ToArray()); + if (int.TryParse(numeric, out var intValue)) { - var numeric = new string(reader.GetString().Where(char.IsDigit).ToArray()); - if (int.TryParse(numeric, out var intValue)) - { - return intValue; - } - - break; + return intValue; } + + break; + } case JsonTokenType.Number when reader.TryGetInt32(out var int32Value): return int32Value; case JsonTokenType.Number when reader.TryGetInt64(out var int64Value): diff --git a/BO4E/meta/LenientConverters/NullableEnumConverter.cs b/BO4E/meta/LenientConverters/NullableEnumConverter.cs index a4fb39c2..80f25f27 100644 --- a/BO4E/meta/LenientConverters/NullableEnumConverter.cs +++ b/BO4E/meta/LenientConverters/NullableEnumConverter.cs @@ -31,12 +31,14 @@ public override bool CanConvert(Type typeToConvert) /// public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) { - var converter = (JsonConverter)Activator.CreateInstance( - typeof(StringNullableEnumConverter<>).MakeGenericType(typeToConvert), - BindingFlags.Instance | BindingFlags.Public, - null, - null, - null); + var converter = (JsonConverter) + Activator.CreateInstance( + typeof(StringNullableEnumConverter<>).MakeGenericType(typeToConvert), + BindingFlags.Instance | BindingFlags.Public, + null, + null, + null + ); return converter; } @@ -54,9 +56,8 @@ public class StringNullableEnumConverter : JsonConverter /// /// constructor /// - public StringNullableEnumConverter() : this(null) - { - } + public StringNullableEnumConverter() + : this(null) { } /// /// Construct a converter (reuse if possible) @@ -101,8 +102,11 @@ public override bool CanConvert(Type typeToConvert) /// /// /// - public override T Read(ref Utf8JsonReader reader, - Type typeToConvert, JsonSerializerOptions options) + public override T Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) { if (_converter != null) { @@ -149,9 +153,8 @@ public override T Read(ref Utf8JsonReader reader, /// /// /// - public override void Write(Utf8JsonWriter writer, - T value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { writer.WriteStringValue(value?.ToString()); } -} \ No newline at end of file +} diff --git a/BO4E/meta/LenientConverters/VerwendungszweckStringEnumConverter.cs b/BO4E/meta/LenientConverters/VerwendungszweckStringEnumConverter.cs index 296dca3f..f714c716 100644 --- a/BO4E/meta/LenientConverters/VerwendungszweckStringEnumConverter.cs +++ b/BO4E/meta/LenientConverters/VerwendungszweckStringEnumConverter.cs @@ -6,11 +6,15 @@ namespace BO4E.meta.LenientConverters; /// /// Converts 'MEHRMINDERMBENGENABRECHNUNG' (with typo!) to Enum Member . /// -public class SystemTextVerwendungszweckStringEnumConverter : System.Text.Json.Serialization.JsonConverter +public class SystemTextVerwendungszweckStringEnumConverter + : System.Text.Json.Serialization.JsonConverter { /// - public override Verwendungszweck? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, - System.Text.Json.JsonSerializerOptions options) + public override Verwendungszweck? Read( + ref System.Text.Json.Utf8JsonReader reader, + Type typeToConvert, + System.Text.Json.JsonSerializerOptions options + ) { if (reader.TokenType == System.Text.Json.JsonTokenType.Null) { @@ -32,16 +36,23 @@ public class SystemTextVerwendungszweckStringEnumConverter : System.Text.Json.Se "MEHRMINDERMBENGENABRECHNUNG" => Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, _ => Enum.TryParse(enumString, true, out var result) ? result - : throw new System.Text.Json.JsonException($"Invalid value for {typeToConvert.Name}: {enumString}") + : throw new System.Text.Json.JsonException( + $"Invalid value for {typeToConvert.Name}: {enumString}" + ), }; } - throw new System.Text.Json.JsonException($"Unexpected token parsing {typeToConvert.Name}. Expected String or Number, got {reader.TokenType}."); + throw new System.Text.Json.JsonException( + $"Unexpected token parsing {typeToConvert.Name}. Expected String or Number, got {reader.TokenType}." + ); } /// - public override void Write(System.Text.Json.Utf8JsonWriter writer, Verwendungszweck? value, - System.Text.Json.JsonSerializerOptions options) + public override void Write( + System.Text.Json.Utf8JsonWriter writer, + Verwendungszweck? value, + System.Text.Json.JsonSerializerOptions options + ) { if (value is null) { @@ -68,11 +79,17 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Verwendungszw /// /// /// -public class NewtonsoftVerwendungszweckStringEnumConverter : Newtonsoft.Json.JsonConverter +public class NewtonsoftVerwendungszweckStringEnumConverter + : Newtonsoft.Json.JsonConverter { /// > - public override Verwendungszweck? ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, - Verwendungszweck? existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer) + public override Verwendungszweck? ReadJson( + Newtonsoft.Json.JsonReader reader, + Type objectType, + Verwendungszweck? existingValue, + bool hasExistingValue, + Newtonsoft.Json.JsonSerializer serializer + ) { if (reader.TokenType == Newtonsoft.Json.JsonToken.Null) { @@ -95,7 +112,8 @@ public class NewtonsoftVerwendungszweckStringEnumConverter : Newtonsoft.Json.Jso _ => Enum.TryParse(enumString, out Verwendungszweck result) ? result : throw new Newtonsoft.Json.JsonSerializationException( - $"Invalid value for {objectType}: {enumString}") + $"Invalid value for {objectType}: {enumString}" + ), }; } @@ -103,8 +121,11 @@ public class NewtonsoftVerwendungszweckStringEnumConverter : Newtonsoft.Json.Jso } /// - public override void WriteJson(Newtonsoft.Json.JsonWriter writer, Verwendungszweck? value, - Newtonsoft.Json.JsonSerializer serializer) + public override void WriteJson( + Newtonsoft.Json.JsonWriter writer, + Verwendungszweck? value, + Newtonsoft.Json.JsonSerializer serializer + ) { if (value is null) { @@ -118,4 +139,4 @@ public override void WriteJson(Newtonsoft.Json.JsonWriter writer, Verwendungszwe /// public override bool CanWrite => true; -} \ No newline at end of file +} diff --git a/BO4E/meta/MultiLangResolver.cs b/BO4E/meta/MultiLangResolver.cs index 218b6a87..a4f305d1 100644 --- a/BO4E/meta/MultiLangResolver.cs +++ b/BO4E/meta/MultiLangResolver.cs @@ -33,13 +33,17 @@ public MultiLangResolver(Language lang) /// /// /// - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + protected override JsonProperty CreateProperty( + MemberInfo member, + MemberSerialization memberSerialization + ) { var prop = base.CreateProperty(member, memberSerialization); - // See if there is a [FieldName] attribute applied to the property + // See if there is a [FieldName] attribute applied to the property // for the requested language - var att = prop.AttributeProvider?.GetAttributes(true) + var att = prop + .AttributeProvider?.GetAttributes(true) .OfType() .FirstOrDefault(a => a.Language == _language); @@ -51,4 +55,4 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ return prop; } -} \ No newline at end of file +} diff --git a/BO4E/meta/NonOfficialAttribute.cs b/BO4E/meta/NonOfficialAttribute.cs index 2fbfe74d..ca174037 100644 --- a/BO4E/meta/NonOfficialAttribute.cs +++ b/BO4E/meta/NonOfficialAttribute.cs @@ -30,14 +30,21 @@ public class NonOfficialAttribute : Attribute /// public NonOfficialAttribute(params object[] enums) { - if (enums.Any(r => r.GetType().BaseType != typeof(Enum) || r.GetType() != typeof(NonOfficialCategory))) + if ( + enums.Any(r => + r.GetType().BaseType != typeof(Enum) || r.GetType() != typeof(NonOfficialCategory) + ) + ) { - throw new ArgumentException($"You must only pass enums of type {nameof(NonOfficialCategory)}", - nameof(enums)); + throw new ArgumentException( + $"You must only pass enums of type {nameof(NonOfficialCategory)}", + nameof(enums) + ); } Mapping = new HashSet(); - foreach (Enum e in enums) Mapping.Add(e); + foreach (Enum e in enums) + Mapping.Add(e); } /// diff --git a/BO4ETestProject/CreateTimeZoneJson.cs b/BO4ETestProject/CreateTimeZoneJson.cs index b0edfbf9..e0fa4a6f 100644 --- a/BO4ETestProject/CreateTimeZoneJson.cs +++ b/BO4ETestProject/CreateTimeZoneJson.cs @@ -31,4 +31,4 @@ public void SerializeAsJson() var json = JsonSerializer.Serialize(tzi); Console.WriteLine(json); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestAbstractDeserialization.cs b/BO4ETestProject/TestAbstractDeserialization.cs index a7515b7c..ff0f9f91 100644 --- a/BO4ETestProject/TestAbstractDeserialization.cs +++ b/BO4ETestProject/TestAbstractDeserialization.cs @@ -69,10 +69,7 @@ public void TestMaLoTypeNameHandlingDeserializationNewtonsoft() json = JObject.Parse(jsonString); } - var settings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.Objects - }; + var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects }; var maloString = json["input"].ToString(); var malo = JsonConvert.DeserializeObject(maloString, settings); Assert.IsNotNull(malo); @@ -103,5 +100,5 @@ public void TestMaLoDeserializationNet5() Assert.IsInstanceOfType(bo, typeof(Marktlokation)); } - // no typename handling test in .NET as this is a JsonConvert feature -} \ No newline at end of file + // no typename handling test in .NET as this is a JsonConvert feature +} diff --git a/BO4ETestProject/TestAutoNumberConverter.cs b/BO4ETestProject/TestAutoNumberConverter.cs index 654c8c11..6c4c0f1a 100644 --- a/BO4ETestProject/TestAutoNumberConverter.cs +++ b/BO4ETestProject/TestAutoNumberConverter.cs @@ -1,8 +1,7 @@ +using System.IO; using BO4E.BO; using BO4E.meta.LenientConverters; - using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; using JsonSerializer = System.Text.Json.JsonSerializer; namespace TestBO4E; @@ -10,7 +9,6 @@ namespace TestBO4E; [TestClass] public class TestAutoNumberConverter { - [TestMethod] public void TestConverter() { @@ -18,13 +16,11 @@ public void TestConverter() using (var r = new StreamReader("testjsons/vertrag_numeric_versionstruktur.json")) { jsonString = r.ReadToEnd(); - } var options = LenientParsing.MOST_LENIENT.GetJsonSerializerOptions(); - var vertrag = JsonSerializer.Deserialize(jsonString, options); Assert.IsNotNull(vertrag); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestBOCOMDesign.cs b/BO4ETestProject/TestBOCOMDesign.cs index 7805ee82..d18646fe 100644 --- a/BO4ETestProject/TestBOCOMDesign.cs +++ b/BO4ETestProject/TestBOCOMDesign.cs @@ -1,44 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using BO4E.BO; using BO4E.COM; using BO4E.meta; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - namespace TestBO4E; [TestClass] public class TestBOCOMDesign { - private static readonly HashSet NO_KEYS_WHITELIST = new() - { - typeof(Kosten), - typeof(Wechsel) - }; + private static readonly HashSet NO_KEYS_WHITELIST = + new() { typeof(Kosten), typeof(Wechsel) }; [TestMethod] public void TestNoBOFields() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => typeof(BusinessObject).IsAssignableFrom(t))) + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => typeof(BusinessObject).IsAssignableFrom(t)) + ) { var fields = type.GetFields().Where(f => f.IsPublic && !f.IsLiteral && !f.IsStatic); - Assert.IsFalse(fields.Any(), - $"Type {type} must not contain fields but has: {string.Join(", ", fields.ToList())}"); + Assert.IsFalse( + fields.Any(), + $"Type {type} must not contain fields but has: {string.Join(", ", fields.ToList())}" + ); } } [TestMethod] public void TestBoAllPublic() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => t.BaseType == typeof(BusinessObject))) - Assert.IsTrue(type.IsPublic, - $"Type {type} is derived from {nameof(BusinessObject)} but is not public."); + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => t.BaseType == typeof(BusinessObject)) + ) + Assert.IsTrue( + type.IsPublic, + $"Type {type} is derived from {nameof(BusinessObject)} but is not public." + ); } private static void AssertConsistentIgnores(Type type) @@ -49,25 +55,63 @@ private static void AssertConsistentIgnores(Type type) } else { - var newtonSoftIgnoredProperties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance) - .Where(p => p.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute)).Any()).ToHashSet(); - var systemTextIgnoreProperties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance) - .Where(p => p.GetCustomAttributes(typeof(System.Text.Json.Serialization.JsonIgnoreAttribute)).Any()).ToHashSet(); - Assert.AreEqual(newtonSoftIgnoredProperties.Count, systemTextIgnoreProperties.Count, $"Type {type} has inconsistent JsonIgnores"); + var newtonSoftIgnoredProperties = type.GetProperties( + BindingFlags.NonPublic | BindingFlags.Instance + ) + .Where(p => + p.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute)).Any() + ) + .ToHashSet(); + var systemTextIgnoreProperties = type.GetProperties( + BindingFlags.NonPublic | BindingFlags.Instance + ) + .Where(p => + p.GetCustomAttributes( + typeof(System.Text.Json.Serialization.JsonIgnoreAttribute) + ) + .Any() + ) + .ToHashSet(); + Assert.AreEqual( + newtonSoftIgnoredProperties.Count, + systemTextIgnoreProperties.Count, + $"Type {type} has inconsistent JsonIgnores" + ); // todo: name the properties in a useful error message - var newtonSoftIgnoredFields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance) - .Where(p => p.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute)).Any()).ToHashSet(); - var systemTextIgnoreFields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance) - .Where(p => p.GetCustomAttributes(typeof(System.Text.Json.Serialization.JsonIgnoreAttribute)).Any()).ToHashSet(); - Assert.AreEqual(newtonSoftIgnoredFields.Count, systemTextIgnoreFields.Count, $"Type {type} has inconsistent JsonIgnores"); + var newtonSoftIgnoredFields = type.GetFields( + BindingFlags.NonPublic | BindingFlags.Instance + ) + .Where(p => + p.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute)).Any() + ) + .ToHashSet(); + var systemTextIgnoreFields = type.GetFields( + BindingFlags.NonPublic | BindingFlags.Instance + ) + .Where(p => + p.GetCustomAttributes( + typeof(System.Text.Json.Serialization.JsonIgnoreAttribute) + ) + .Any() + ) + .ToHashSet(); + Assert.AreEqual( + newtonSoftIgnoredFields.Count, + systemTextIgnoreFields.Count, + $"Type {type} has inconsistent JsonIgnores" + ); } } [TestMethod] public void TestConsistentIgnoresBo() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => t.BaseType == typeof(BusinessObject))) + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => t.BaseType == typeof(BusinessObject)) + ) { AssertConsistentIgnores(type); } @@ -85,59 +129,105 @@ public void TestConsistentIgnoresCom() [TestMethod] public void TestNoCOMFields() { - foreach (var type in typeof(COM).Assembly.GetTypes().Where(t => typeof(COM).IsAssignableFrom(t))) + foreach ( + var type in typeof(COM).Assembly.GetTypes().Where(t => typeof(COM).IsAssignableFrom(t)) + ) { var fields = type.GetFields().Where(f => f.IsPublic && !f.IsStatic); - Assert.IsFalse(fields.Any(), - $"Type {type} must not contain public fields but has: {string.Join(", ", fields.ToList())}"); + Assert.IsFalse( + fields.Any(), + $"Type {type} must not contain public fields but has: {string.Join(", ", fields.ToList())}" + ); } } [TestMethod] public void TestCOMAllPublic() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => t.BaseType == typeof(COM))) - Assert.IsTrue(type.IsPublic, $"Type {type} is derived from {nameof(COM)} but is not public."); + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => t.BaseType == typeof(COM)) + ) + Assert.IsTrue( + type.IsPublic, + $"Type {type} is derived from {nameof(COM)} but is not public." + ); } [TestMethod] public void TestBoInheritance() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => - t.IsClass && t.IsPublic && t.Namespace == "BO4E.BO" && !t.Name.EndsWith("Converter"))) - Assert.IsTrue(type.IsSubclassOf(typeof(BusinessObject)) || type == typeof(BusinessObject), - $"Type {type} does not inherit from {nameof(BusinessObject)}."); + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => + t.IsClass + && t.IsPublic + && t.Namespace == "BO4E.BO" + && !t.Name.EndsWith("Converter") + ) + ) + Assert.IsTrue( + type.IsSubclassOf(typeof(BusinessObject)) || type == typeof(BusinessObject), + $"Type {type} does not inherit from {nameof(BusinessObject)}." + ); } [TestMethod] public void TestCOMInheritance() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => - t.IsClass && t.IsPublic && t.Namespace == "BO4E.COM" && !t.Name.EndsWith("Converter"))) - Assert.IsTrue(type.IsSubclassOf(typeof(COM)) || type == typeof(COM), - $"Type {type} does not inherit from {nameof(COM)}."); + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => + t.IsClass + && t.IsPublic + && t.Namespace == "BO4E.COM" + && !t.Name.EndsWith("Converter") + ) + ) + Assert.IsTrue( + type.IsSubclassOf(typeof(COM)) || type == typeof(COM), + $"Type {type} does not inherit from {nameof(COM)}." + ); } [TestMethod] public void TestEnumNamespace() { - foreach (var type in - typeof(BusinessObject).Assembly.GetTypes().Where(t => t.IsPublic && t.Namespace == "BO4E.ENUM")) - Assert.IsTrue(type.IsEnum, - $"Type {type} is in namespace BO4E.ENUM but no enum! Consinder moving the definition to another namespace or adding an internal / private modifier."); + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => t.IsPublic && t.Namespace == "BO4E.ENUM") + ) + Assert.IsTrue( + type.IsEnum, + $"Type {type} is in namespace BO4E.ENUM but no enum! Consinder moving the definition to another namespace or adding an internal / private modifier." + ); } [TestMethod] public void TestBoKeys() { - foreach (var type in typeof(BusinessObject).Assembly.GetTypes().Where(t => t.BaseType == typeof(BusinessObject) && !t.IsAbstract && !NO_KEYS_WHITELIST.Contains(t))) + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => + t.BaseType == typeof(BusinessObject) + && !t.IsAbstract + && !NO_KEYS_WHITELIST.Contains(t) + ) + ) { var keyProps = type.GetProperties() .Where(p => p.GetCustomAttributes(typeof(BoKey), false).Length > 0) .OrderBy(ap => ap.GetCustomAttribute()?.Order) .ToArray(); - Assert.IsTrue(keyProps.Any(), - $"Type {type} is derived from {nameof(BusinessObject)} but has no [{nameof(BoKey)}] attribute."); + Assert.IsTrue( + keyProps.Any(), + $"Type {type} is derived from {nameof(BusinessObject)} but has no [{nameof(BoKey)}] attribute." + ); } } @@ -148,22 +238,49 @@ public void TestBoKeys() [TestMethod] public void NullableDefaultEnums() { - foreach (var boType in typeof(BusinessObject).Assembly.GetTypes().Where(t => (t.BaseType == typeof(BusinessObject) || t.BaseType == typeof(COM)) && !t.IsAbstract)) + foreach ( + var boType in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => + (t.BaseType == typeof(BusinessObject) || t.BaseType == typeof(COM)) + && !t.IsAbstract + ) + ) { - foreach (var obligDefaultField in boType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance).Where(field => field.GetCustomAttributes(typeof(JsonPropertyAttribute), true).Cast().Any(jpa => jpa.Required == Required.Default))) + foreach ( + var obligDefaultField in boType + .GetProperties( + BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance + ) + .Where(field => + field + .GetCustomAttributes(typeof(JsonPropertyAttribute), true) + .Cast() + .Any(jpa => jpa.Required == Required.Default) + ) + ) { - if (Nullable.GetUnderlyingType(obligDefaultField.PropertyType) != null || obligDefaultField.PropertyType == typeof(string)) + if ( + Nullable.GetUnderlyingType(obligDefaultField.PropertyType) != null + || obligDefaultField.PropertyType == typeof(string) + ) { - // it is already nullable. + // it is already nullable. continue; } - if (!obligDefaultField.PropertyType.IsPrimitive && !obligDefaultField.PropertyType.IsEnum) + if ( + !obligDefaultField.PropertyType.IsPrimitive + && !obligDefaultField.PropertyType.IsEnum + ) { continue; } - Assert.IsTrue(false, $"The type {obligDefaultField.PropertyType} of {boType.FullName}.{obligDefaultField.Name} is not nullable but not marked as obligatory."); + Assert.IsTrue( + false, + $"The type {obligDefaultField.PropertyType} of {boType.FullName}.{obligDefaultField.Name} is not nullable but not marked as obligatory." + ); // this is a problem because e.g. for integers you can't distinguish between no value (null) or initial value (0). Same is true for Enum values } } } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestBOCOMGuids.cs b/BO4ETestProject/TestBOCOMGuids.cs index 957c0b32..953a6397 100644 --- a/BO4ETestProject/TestBOCOMGuids.cs +++ b/BO4ETestProject/TestBOCOMGuids.cs @@ -20,20 +20,22 @@ public void TestBOGuidsNewtonsoft() LokationsId = "DE123456", LokationsTyp = Lokationstyp.MALO, Energieverbrauch = new List(), - Guid = Guid.NewGuid() + Guid = Guid.NewGuid(), }; var emJson = JsonConvert.SerializeObject(em); - Assert.AreEqual(em.Guid.Value, JsonConvert.DeserializeObject(emJson).Guid.Value); + Assert.AreEqual( + em.Guid.Value, + JsonConvert.DeserializeObject(emJson).Guid.Value + ); - var gp = new Geschaeftspartner - { - Gewerbekennzeichnung = true, - Guid = Guid.NewGuid() - }; + var gp = new Geschaeftspartner { Gewerbekennzeichnung = true, Guid = Guid.NewGuid() }; var gpJson = JsonConvert.SerializeObject(gp); - Assert.AreEqual(gp.Guid.Value, JsonConvert.DeserializeObject(gpJson).Guid.Value); + Assert.AreEqual( + gp.Guid.Value, + JsonConvert.DeserializeObject(gpJson).Guid.Value + ); } [TestMethod] @@ -44,18 +46,17 @@ public void TestBOGuids() LokationsId = "DE123456", LokationsTyp = Lokationstyp.MALO, Energieverbrauch = new List(), - Guid = Guid.NewGuid() + Guid = Guid.NewGuid(), }; var emJson = JsonSerializer.Serialize(em); Assert.AreEqual(em.Guid.Value, JsonSerializer.Deserialize(emJson).Guid.Value); - var gp = new Geschaeftspartner - { - Gewerbekennzeichnung = true, - Guid = Guid.NewGuid() - }; + var gp = new Geschaeftspartner { Gewerbekennzeichnung = true, Guid = Guid.NewGuid() }; var gpJson = JsonSerializer.Serialize(gp); - Assert.AreEqual(gp.Guid.Value, JsonSerializer.Deserialize(gpJson).Guid.Value); + Assert.AreEqual( + gp.Guid.Value, + JsonSerializer.Deserialize(gpJson).Guid.Value + ); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestBo4eUri.cs b/BO4ETestProject/TestBo4eUri.cs index 20ffa40b..04478f05 100644 --- a/BO4ETestProject/TestBo4eUri.cs +++ b/BO4ETestProject/TestBo4eUri.cs @@ -14,36 +14,50 @@ namespace TestBO4E; [TestClass] public class TestBo4eURI { - private static readonly Dictionary boNameResults = new Dictionary + private static readonly Dictionary boNameResults = new Dictionary< + string, + string + > { - {"bo4e://Marktlokation/987654321098", "Marktlokation"}, - {"bo4e://hurzelasdanoafi/123456", null}, - {"bo4e://Energiemenge/123456", "Energiemenge"}, - {"bo4e://Ansprechpartner/123467/adsadad/aafe4rq3rqr/", "Ansprechpartner"}, - {"bo4e://ansprechpartner/mitlowercase/", "Ansprechpartner"}, - {"bo4e://MaRkTLoKaTiOn/mitlowercase/", "Marktlokation"}, - {"bo4e://Marktlokation/?backendId=10000001308", "Marktlokation"} + { "bo4e://Marktlokation/987654321098", "Marktlokation" }, + { "bo4e://hurzelasdanoafi/123456", null }, + { "bo4e://Energiemenge/123456", "Energiemenge" }, + { "bo4e://Ansprechpartner/123467/adsadad/aafe4rq3rqr/", "Ansprechpartner" }, + { "bo4e://ansprechpartner/mitlowercase/", "Ansprechpartner" }, + { "bo4e://MaRkTLoKaTiOn/mitlowercase/", "Marktlokation" }, + { "bo4e://Marktlokation/?backendId=10000001308", "Marktlokation" }, }; - private static readonly Dictionary> boKeyNamesResults = new Dictionary> + private static readonly Dictionary> boKeyNamesResults = new Dictionary< + Type, + List + > { - {typeof(Marktlokation), new List {"marktlokationsId"}}, { - typeof(Messlokation), new List {"messlokationsId"} - } //<-- should be the json property name if annotated + typeof(Marktlokation), + new List { "marktlokationsId" } + }, + { + typeof(Messlokation), + new List { "messlokationsId" } + } //<-- should be the json property name if annotated + , }; - private static readonly Dictionary validationResults = new Dictionary + private static readonly Dictionary validationResults = new Dictionary< + string, + bool + > { - {"bo4e://Marktlokation/987654321098", true}, + { "bo4e://Marktlokation/987654321098", true }, // {" bo4e://Leerzeichen/987654321098", false }, - {"keinProtokoll/123456", false}, - {"falschesProtokoll://asdadadl/123456", false}, - {"bo4e://Marktlokation/123467/adsadad/aafe4rq3rqr/", true}, - {"bo4e://kf56@Marktlokation:100/adadsadad", true}, - {"bo4e://kf56:pw@Marktlokation:100/adadsadad?dasd=asd", true}, - {"bo4e://Marktlokation/123467/adsadad/aafe4rq3rqr?asdasda=3r343&adasdas=2334#341", true}, - {"bo4e://Marktteilnehmer/?backendId=1234", true} + { "keinProtokoll/123456", false }, + { "falschesProtokoll://asdadadl/123456", false }, + { "bo4e://Marktlokation/123467/adsadad/aafe4rq3rqr/", true }, + { "bo4e://kf56@Marktlokation:100/adadsadad", true }, + { "bo4e://kf56:pw@Marktlokation:100/adadsadad?dasd=asd", true }, + { "bo4e://Marktlokation/123467/adsadad/aafe4rq3rqr?asdasda=3r343&adasdas=2334#341", true }, + { "bo4e://Marktteilnehmer/?backendId=1234", true }, }; [TestMethod] @@ -60,9 +74,14 @@ public void TestUriConstructionAndKeyDeconstruction() } Assert.IsNotNull(json, $"The content of file {file} seems to be no valid JSON."); - Assert.IsNotNull(json["input"], $"The file {file} does not contain the mandatory 'input' key."); - Assert.IsNotNull(json["expectedUri"], - $"The file {file} does not contain the mandatory 'expectedUri' key."); + Assert.IsNotNull( + json["input"], + $"The file {file} does not contain the mandatory 'input' key." + ); + Assert.IsNotNull( + json["expectedUri"], + $"The file {file} does not contain the mandatory 'expectedUri' key." + ); //string boType = (string)json["input"]["boTyp"]; //Assert.IsNotNull(boType, $"The JSON content of file {file} is missing the obligatory 'boTyp' attribute."); var bo = JsonConvert.DeserializeObject(json["input"].ToString()); @@ -70,10 +89,16 @@ public void TestUriConstructionAndKeyDeconstruction() var uri = Bo4eUri.GetUri(bo); var uriString = uri.AbsoluteUri; - Assert.AreEqual(json["expectedUri"], uriString, "The URI doesn't match the expectations."); + Assert.AreEqual( + json["expectedUri"], + uriString, + "The URI doesn't match the expectations." + ); - Assert.IsNotNull(json["expectedQueryObject"], - $"Please specify the query object result in file {file}, key 'expectedQueryObject'."); + Assert.IsNotNull( + json["expectedQueryObject"], + $"Please specify the query object result in file {file}, key 'expectedQueryObject'." + ); var queryObject = uri.GetQueryObject(); var jdp = new JsonDiffPatch(); var left = json["expectedQueryObject"]; @@ -81,10 +106,10 @@ public void TestUriConstructionAndKeyDeconstruction() var patch = jdp.Diff(left, right); if (patch != null) { - if (patch.ToString() - .Replace("\n", "") - .Replace("\r", "") - .Replace(" ", "") == "{\"vorname\":[null,null]}") + if ( + patch.ToString().Replace("\n", "").Replace("\r", "").Replace(" ", "") + == "{\"vorname\":[null,null]}" + ) { continue; } @@ -122,7 +147,8 @@ public void TestEmptyUriQueryObject() public void TestWellformedKannmichmal() { var uri = new Bo4eUri( - "bo4e://messlokation/?filter=bilanzierungsmethode eq 'RLM'or bilanzierungsmethode eq 'IMS'"); + "bo4e://messlokation/?filter=bilanzierungsmethode eq 'RLM'or bilanzierungsmethode eq 'IMS'" + ); Assert.IsNotNull(uri); } @@ -133,8 +159,11 @@ public void TestBoNamesAndTypes() try { var uri = new Bo4eUri(testString); - Assert.AreEqual(boNameResults[testString], uri.GetBoName(), - $"boName validation failed for {testString}."); + Assert.AreEqual( + boNameResults[testString], + uri.GetBoName(), + $"boName validation failed for {testString}." + ); Assert.IsTrue(uri.GetBoType().ToString().EndsWith(boNameResults[testString])); } catch (ArgumentException) @@ -150,8 +179,10 @@ public void TestBoKeyNames() { var expectedList = boKeyNamesResults[boType]; var actualList = BusinessObject.GetBoKeyNames(boType); - Assert.IsTrue(expectedList.SequenceEqual(actualList), - $"{boType}: expected: [{string.Join(",", expectedList)}] actual: [{string.Join(",", actualList)}] "); + Assert.IsTrue( + expectedList.SequenceEqual(actualList), + $"{boType}: expected: [{string.Join(",", expectedList)}] actual: [{string.Join(",", actualList)}] " + ); } } @@ -159,8 +190,11 @@ public void TestBoKeyNames() public void TestValidity() { foreach (var testString in validationResults.Keys) - Assert.AreEqual(validationResults[testString], Bo4eUri.IsValid(testString), - $"URI validation failed for {testString} ."); + Assert.AreEqual( + validationResults[testString], + Bo4eUri.IsValid(testString), + $"URI validation failed for {testString} ." + ); } [TestMethod] @@ -180,13 +214,16 @@ public void TestUPInclusion() public void TestRoundTripUriFilterQueryObject() { var qo = JObject.Parse( - "{'marktlokationsId':'543212345', 'messlokationsId':'DE123', 'bilanzierungsmethode':'SLP'}"); + "{'marktlokationsId':'543212345', 'messlokationsId':'DE123', 'bilanzierungsmethode':'SLP'}" + ); var uri = new Bo4eUri("bo4e://marktlokation?search=something").AddFilter( - JsonConvert.DeserializeObject>(qo.ToString())); + JsonConvert.DeserializeObject>(qo.ToString()) + ); Assert.IsNotNull(uri); Assert.AreEqual( "bo4e://marktlokation/?search=something&filter=marktlokationsId+eq+%27543212345%27+and+bilanzierungsmethode+eq+%27SLP%27", - uri.ToString()); + uri.ToString() + ); var qo2 = uri.GetQueryObject(); Assert.IsTrue(qo2.ContainsKey("marktlokationsId")); Assert.IsTrue(qo2.ContainsKey("bilanzierungsmethode")); @@ -231,4 +268,4 @@ private bool ThisMethodOnlyAcceptsBo4eUri(Bo4eUri uri) { return true; } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestBoExpansion.cs b/BO4ETestProject/TestBoExpansion.cs index ce0faa01..26c1b352 100644 --- a/BO4ETestProject/TestBoExpansion.cs +++ b/BO4ETestProject/TestBoExpansion.cs @@ -11,18 +11,26 @@ public class TestBoExpansion [TestMethod] public void TestBoExpansionMaLo() { - var result = new HashSet(BusinessObject.GetExpandablePropertyNames(typeof(Marktlokation)).Keys); + var result = new HashSet( + BusinessObject.GetExpandablePropertyNames(typeof(Marktlokation)).Keys + ); Assert.IsTrue(result.Contains("zugehoerigeMesslokationen")); - var result2 = new HashSet(BusinessObject.GetExpandableFieldNames("Marktlokation").Keys); + var result2 = new HashSet( + BusinessObject.GetExpandableFieldNames("Marktlokation").Keys + ); Assert.IsTrue(result.SetEquals(result2)); - Assert.ThrowsException(() => BusinessObject.GetExpandableFieldNames("kein gültiges bo")); + Assert.ThrowsException( + () => BusinessObject.GetExpandableFieldNames("kein gültiges bo") + ); } [TestMethod] public void TestBoExpansionMeLo() { - var result = new HashSet(BusinessObject.GetExpandablePropertyNames(typeof(Messlokation)).Keys); + var result = new HashSet( + BusinessObject.GetExpandablePropertyNames(typeof(Messlokation)).Keys + ); Assert.IsTrue(result.Contains("messadresse")); Assert.IsTrue(result.Contains("messlokationszaehler")); Assert.IsTrue(result.Contains("messlokationszaehler.zaehlwerke")); @@ -37,4 +45,4 @@ public void TestTypesEnergiemenge() Assert.IsTrue(verbrauchsType.IsGenericType); Assert.IsTrue(verbrauchsType.GetGenericTypeDefinition() == typeof(List<>)); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestBoMapperSystemText.cs b/BO4ETestProject/TestBoMapperSystemText.cs index 41e818cc..be1ccfd9 100644 --- a/BO4ETestProject/TestBoMapperSystemText.cs +++ b/BO4ETestProject/TestBoMapperSystemText.cs @@ -4,13 +4,11 @@ using System.IO; using System.Text.Json; using System.Threading.Tasks; - using BO4E; using BO4E.BO; using BO4E.COM; using BO4E.ENUM; using BO4E.meta.LenientConverters; - using Microsoft.VisualStudio.TestTools.UnitTesting; //using BO4E.Extensions; namespace TestBO4E; @@ -33,26 +31,39 @@ public void TestBoMapping() json = JsonSerializer.Deserialize(jsonString); } - Assert.IsNotNull(json.RootElement.GetProperty("objectName"), - $"You have to specify the object name in test file {file}"); + Assert.IsNotNull( + json.RootElement.GetProperty("objectName"), + $"You have to specify the object name in test file {file}" + ); var lenients = LenientParsing.STRICT; // default - if (json.RootElement.TryGetProperty("lenientDateTime", out var boolElement) && boolElement.GetBoolean()) + if ( + json.RootElement.TryGetProperty("lenientDateTime", out var boolElement) + && boolElement.GetBoolean() + ) { lenients |= LenientParsing.DATE_TIME; } - if (json.RootElement.TryGetProperty("lenientEnumList", out var listElement) && listElement.GetBoolean()) + if ( + json.RootElement.TryGetProperty("lenientEnumList", out var listElement) + && listElement.GetBoolean() + ) { lenients |= LenientParsing.ENUM_LIST; } - if (json.RootElement.TryGetProperty("lenientBo4eUri", out var urlElement) && urlElement.GetBoolean()) + if ( + json.RootElement.TryGetProperty("lenientBo4eUri", out var urlElement) + && urlElement.GetBoolean() + ) { lenients |= LenientParsing.BO4_E_URI; } - if (json.RootElement.TryGetProperty("lenientStringToInt", out var intElement) && - intElement.GetBoolean()) + if ( + json.RootElement.TryGetProperty("lenientStringToInt", out var intElement) + && intElement.GetBoolean() + ) { lenients |= LenientParsing.STRING_TO_INT; } @@ -60,14 +71,21 @@ public void TestBoMapping() BusinessObject bo = null; try { - bo = JsonSerializer.Deserialize(json.RootElement.GetProperty("input").GetRawText(), - lenients.GetJsonSerializerOptions()); + bo = JsonSerializer.Deserialize( + json.RootElement.GetProperty("input").GetRawText(), + lenients.GetJsonSerializerOptions() + ); } catch (Exception) { - bo = JsonSerializer.Deserialize(json.RootElement.GetProperty("input").GetRawText(), - BoMapper.GetTypeForBoName(json.RootElement.GetProperty("objectName").GetString()), - LenientParsing.MOST_LENIENT.GetJsonSerializerOptions()) as BusinessObject; + bo = + JsonSerializer.Deserialize( + json.RootElement.GetProperty("input").GetRawText(), + BoMapper.GetTypeForBoName( + json.RootElement.GetProperty("objectName").GetString() + ), + LenientParsing.MOST_LENIENT.GetJsonSerializerOptions() + ) as BusinessObject; } var regularOutputString = JsonSerializer.Serialize(bo, bo.GetType()); @@ -98,7 +116,9 @@ public void TestBoMapping() HashSet whitelist; if (json.RootElement.TryGetProperty("userPropWhiteList", out var whiteList)) { - whitelist = new HashSet(JsonSerializer.Deserialize>(whiteList.GetRawText())); + whitelist = new HashSet( + JsonSerializer.Deserialize>(whiteList.GetRawText()) + ); } else { @@ -114,13 +134,20 @@ public void TestBoMapping() try { boLenient = JsonSerializer.Deserialize( - json.RootElement.GetProperty("input").GetRawText(), lenient.GetJsonSerializerOptions()); + json.RootElement.GetProperty("input").GetRawText(), + lenient.GetJsonSerializerOptions() + ); } catch (Exception) { - _ = JsonSerializer.Deserialize(json.RootElement.GetProperty("input").GetRawText(), - BoMapper.GetTypeForBoName(json.RootElement.GetProperty("objectName").GetString()), - lenients.GetJsonSerializerOptions()) as BusinessObject; + _ = + JsonSerializer.Deserialize( + json.RootElement.GetProperty("input").GetRawText(), + BoMapper.GetTypeForBoName( + json.RootElement.GetProperty("objectName").GetString() + ), + lenients.GetJsonSerializerOptions() + ) as BusinessObject; } //string dateLenietOutputString = JsonConvert.SerializeObject(boLenient, new StringEnumConverter()); @@ -140,8 +167,10 @@ public void TestBoMapping() public void TestMesslokation() { var jsonInput = GetInputNodeAsJson("BoMapperTests/messlokation_userProps.json"); - var melo = JsonSerializer.Deserialize(jsonInput, - LenientParsing.MOST_LENIENT.GetJsonSerializerOptions()); + var melo = JsonSerializer.Deserialize( + jsonInput, + LenientParsing.MOST_LENIENT.GetJsonSerializerOptions() + ); Assert.IsNotNull(melo); Assert.AreEqual(true, melo.Abrechnungmessstellenbetriebnna); } @@ -150,8 +179,10 @@ public void TestMesslokation() public void TestMarktlokation() { var jsonInput = GetInputNodeAsJson("BoMapperTests/marktlokation_simple.json"); - var malo = JsonSerializer.Deserialize(jsonInput, - LenientParsing.MOST_LENIENT.GetJsonSerializerOptions()); + var malo = JsonSerializer.Deserialize( + jsonInput, + LenientParsing.MOST_LENIENT.GetJsonSerializerOptions() + ); Assert.IsNotNull(malo); Assert.AreEqual(Gebiettyp.VERTEILNETZ, malo.GebietTyp); } @@ -161,8 +192,10 @@ public void TestZählerHerstellerKontaktweg() { using var r = new StreamReader("testjsons/zähler.json"); var jsonString = r.ReadToEnd(); - var zaehler = - JsonSerializer.Deserialize(jsonString, LenientParsing.MOST_LENIENT.GetJsonSerializerOptions()); + var zaehler = JsonSerializer.Deserialize( + jsonString, + LenientParsing.MOST_LENIENT.GetJsonSerializerOptions() + ); Assert.IsNotNull(zaehler); Assert.IsNotNull(zaehler.Zaehlerhersteller); } @@ -200,10 +233,12 @@ public async Task TestVertragSerializerParallel() var taskList = new List(); for (int i = 0; i < 10; i++) { - taskList.Add(Task.Run(() => - { - JsonSerializer.Serialize(v, serializeOptions); - })); + taskList.Add( + Task.Run(() => + { + JsonSerializer.Serialize(v, serializeOptions); + }) + ); } await Task.WhenAll(taskList); } @@ -215,8 +250,10 @@ public void TestBoNameTyping() Assert.AreEqual(typeof(Benachrichtigung), BoMapper.GetTypeForBoName("Benachrichtigung")); Assert.AreEqual(typeof(Benachrichtigung), BoMapper.GetTypeForBoName("bEnAcHriCHTIGuNg")); - Assert.ThrowsException(() => BoMapper.GetTypeForBoName(null), - "null as argument must result in a ArgumentNullException"); + Assert.ThrowsException( + () => BoMapper.GetTypeForBoName(null), + "null as argument must result in a ArgumentNullException" + ); /* bool argumentExceptionThrown = false; try @@ -229,8 +266,10 @@ public void TestBoNameTyping() } Assert.IsTrue(argumentExceptionThrown, "invalid argument must result in a ArgumentException"); */ - Assert.IsNull(BoMapper.GetTypeForBoName("dei mudder ihr business object"), - "invalid business object names must result in null"); + Assert.IsNull( + BoMapper.GetTypeForBoName("dei mudder ihr business object"), + "invalid business object names must result in null" + ); } [TestMethod] @@ -238,18 +277,19 @@ public void TestNullableDateTimeDeserialization() { var a = JsonSerializer.Deserialize( "{\"ccat\":\"ZE01\",\"casenr\":\"470272\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"REIMPORT\",\"ausgefuehrt\":\"false\",\"ausfuehrender\":\"\",\"ausfuehrungszeitpunkt\":\"0000-00-00T00:00:00Z\"}", - LenientParsing.DATE_TIME.GetJsonSerializerOptions()); + LenientParsing.DATE_TIME.GetJsonSerializerOptions() + ); Assert.IsNotNull(a); Assert.IsFalse(a.Ausfuehrungszeitpunkt.HasValue); var b = JsonSerializer.Deserialize( "{\"ccat\":\"ZE01\",\"casenr\":\"470272\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"REIMPORT\",\"ausgefuehrt\":\"false\",\"ausfuehrender\":\"\",\"ausfuehrungszeitpunkt\":\"2019-07-10T11:52:59Z\"}", - LenientParsing.DATE_TIME.GetJsonSerializerOptions()); + LenientParsing.DATE_TIME.GetJsonSerializerOptions() + ); Assert.IsNotNull(b); Assert.IsTrue(b.Ausfuehrungszeitpunkt.HasValue); } - /// /// Parses the file at as json object, extracts the "input" node. /// diff --git a/BO4ETestProject/TestCOMValidity.cs b/BO4ETestProject/TestCOMValidity.cs index 9841c9cb..b7ea4b7c 100644 --- a/BO4ETestProject/TestCOMValidity.cs +++ b/BO4ETestProject/TestCOMValidity.cs @@ -19,8 +19,8 @@ public void TestVerbrauch() Enddatum = new DateTimeOffset(), Einheit = Mengeneinheit.ANZAHL, Wert = (decimal)123.456, - Obiskennzahl = "asd" + Obiskennzahl = "asd", }; Assert.IsTrue(v2.IsValid()); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestEnergiemengeAdding.cs b/BO4ETestProject/TestEnergiemengeAdding.cs index c20474e8..0f64f567 100644 --- a/BO4ETestProject/TestEnergiemengeAdding.cs +++ b/BO4ETestProject/TestEnergiemengeAdding.cs @@ -25,10 +25,10 @@ public void TestSimpleAdd() Obiskennzahl = "1-2-3", Enddatum = new DateTimeOffset(), Startdatum = new DateTimeOffset(), - Wert = (decimal) 123.456, - Wertermittlungsverfahren = Wertermittlungsverfahren.PROGNOSE - } - } + Wert = (decimal)123.456, + Wertermittlungsverfahren = Wertermittlungsverfahren.PROGNOSE, + }, + }, }; var em2 = new Energiemenge { @@ -42,10 +42,10 @@ public void TestSimpleAdd() Obiskennzahl = "4-5-6", Enddatum = new DateTimeOffset(), Startdatum = new DateTimeOffset(), - Wert = (decimal) 123.456, - Wertermittlungsverfahren = Wertermittlungsverfahren.PROGNOSE - } - } + Wert = (decimal)123.456, + Wertermittlungsverfahren = Wertermittlungsverfahren.PROGNOSE, + }, + }, }; var result = em1 + em2; Assert.IsNotNull(result); @@ -55,16 +55,8 @@ public void TestSimpleAdd() [TestMethod] public void TestIllegalAdd() { - var em1 = new Energiemenge - { - LokationsId = "DE456", - LokationsTyp = Lokationstyp.MELO - }; - var em2 = new Energiemenge - { - LokationsId = "DE789", - LokationsTyp = Lokationstyp.MELO - }; + var em1 = new Energiemenge { LokationsId = "DE456", LokationsTyp = Lokationstyp.MELO }; + var em2 = new Energiemenge { LokationsId = "DE789", LokationsTyp = Lokationstyp.MELO }; Assert.ThrowsException(() => em1 + em2); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestEnergyIdentificationCodeExtensions.cs b/BO4ETestProject/TestEnergyIdentificationCodeExtensions.cs index c084689a..5b3627cc 100644 --- a/BO4ETestProject/TestEnergyIdentificationCodeExtensions.cs +++ b/BO4ETestProject/TestEnergyIdentificationCodeExtensions.cs @@ -18,10 +18,8 @@ public class TestEnergyIdentificationCodeExtensions [DataRow("", false)] [DataRow(null, false)] [DataRow("soooasdasdmk", false)] - [DataRow("11XRWENET12345-2", - true)] // example from section 7 https://eepublicdownloads.entsoe.eu/clean-documents/EDI/Library/cim_based/02%20EIC%20Code%20implementation%20guide_final.pdf - [DataRow("11XRWENET12345-3", - false)] // example from section 7 https://eepublicdownloads.entsoe.eu/clean-documents/EDI/Library/cim_based/02%20EIC%20Code%20implementation%20guide_final.pdf + [DataRow("11XRWENET12345-2", true)] // example from section 7 https://eepublicdownloads.entsoe.eu/clean-documents/EDI/Library/cim_based/02%20EIC%20Code%20implementation%20guide_final.pdf + [DataRow("11XRWENET12345-3", false)] // example from section 7 https://eepublicdownloads.entsoe.eu/clean-documents/EDI/Library/cim_based/02%20EIC%20Code%20implementation%20guide_final.pdf // other examples taken from https://www.entsoe.eu/data/energy-identification-codes-eic/eic-approved-codes/ [DataRow("10X1001A1001A361", true)] // TENNET_TSO [DataRow("10X1001A1001A360", false)] // TENNET_TSO with wrong check sum @@ -83,4 +81,4 @@ public void TestGermanRegelZone(string eicCode, bool expectedValidity) { Assert.AreEqual(expectedValidity, eicCode.IsGermanControlArea()); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestEnumMembers.cs b/BO4ETestProject/TestEnumMembers.cs index 554d8c85..234ee8a5 100644 --- a/BO4ETestProject/TestEnumMembers.cs +++ b/BO4ETestProject/TestEnumMembers.cs @@ -20,12 +20,17 @@ public class TestEnumMembers [TestMethod] public void TestEnumMemberConsistency() { - var enumTypes = typeof(AbgabeArt).Assembly.GetTypes() - .Where(t => t.IsEnum && t.Namespace.StartsWith("BO4E.ENUM") && - !t.Namespace.StartsWith("BO4E.ENUM.EDI")); + var enumTypes = typeof(AbgabeArt) + .Assembly.GetTypes() + .Where(t => + t.IsEnum + && t.Namespace.StartsWith("BO4E.ENUM") + && !t.Namespace.StartsWith("BO4E.ENUM.EDI") + ); foreach (var enumType in enumTypes) { - var enumFields = enumType.GetFields() + var enumFields = enumType + .GetFields() .Where(f => f.IsPublic) .Where(f => f.Name != "value__") .ToList(); @@ -34,7 +39,10 @@ public void TestEnumMemberConsistency() .Select(f => new Tuple(enumType, f.Name)); fieldsWithoutEnumMemberAttributes.Should().BeEmpty(); var enumMemberAttributeDiffersFromEnumMemberName = enumFields - .Select(f => new Tuple(f.GetCustomAttribute().Value, f.Name)) + .Select(f => new Tuple( + f.GetCustomAttribute().Value, + f.Name + )) .Where(nameTuple => nameTuple.Item1 != nameTuple.Item2); enumMemberAttributeDiffersFromEnumMemberName.Should().BeEmpty(); } @@ -49,23 +57,34 @@ internal class MyClass public void Test_Mehrmindermengenabrechnung_System_Text() { var options = LenientParsing.MOST_LENIENT.GetJsonSerializerOptions(); - var myLegacyInstance = new MyClass() { Verwendungszweck = Verwendungszweck.MEHRMINDERMENGENABRECHNUNG }; + var myLegacyInstance = new MyClass() + { + Verwendungszweck = Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, + }; var myLegacyJson = System.Text.Json.JsonSerializer.Serialize(myLegacyInstance, options); myLegacyJson.Should().Contain("MEHRMINDERMENGENABRECHNUNG"); - var myNewInstance = System.Text.Json.JsonSerializer.Deserialize(myLegacyJson, options); + var myNewInstance = System.Text.Json.JsonSerializer.Deserialize( + myLegacyJson, + options + ); myNewInstance.Verwendungszweck.Should().Be(Verwendungszweck.MEHRMINDERMENGENABRECHNUNG); } - [TestMethod] public void Test_Mehrmindermengenabrechnung_Newtonsoft() { var options = LenientParsing.MOST_LENIENT.GetJsonSerializerSettings(); options.Converters.Add(new StringEnumConverter()); - var myLegacyInstance = new MyClass() { Verwendungszweck = Verwendungszweck.MEHRMINDERMENGENABRECHNUNG }; + var myLegacyInstance = new MyClass() + { + Verwendungszweck = Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, + }; var myLegacyJson = Newtonsoft.Json.JsonConvert.SerializeObject(myLegacyInstance, options); myLegacyJson.Should().Contain("MEHRMINDERMENGENABRECHNUNG"); - var myNewInstance = Newtonsoft.Json.JsonConvert.DeserializeObject(myLegacyJson, options); + var myNewInstance = Newtonsoft.Json.JsonConvert.DeserializeObject( + myLegacyJson, + options + ); myNewInstance.Verwendungszweck.Should().Be(Verwendungszweck.MEHRMINDERMENGENABRECHNUNG); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestEnums.cs b/BO4ETestProject/TestEnums.cs index 9f1bf94c..72920cb6 100644 --- a/BO4ETestProject/TestEnums.cs +++ b/BO4ETestProject/TestEnums.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestBO4E; + [TestClass] public class TestEnums { @@ -14,7 +15,8 @@ public void No_Two_Enum_Members_Share_The_Same_Integer_Value() var arbitraryEnumType = typeof(BO4E.ENUM.Abweichungsgrund); var enumAssembly = Assembly.GetAssembly(arbitraryEnumType); enumAssembly.Should().NotBeNull(); - var enumTypesWithDuplicateValues = enumAssembly!.GetTypes() + var enumTypesWithDuplicateValues = enumAssembly! + .GetTypes() .Where(t => t.IsEnum) .Where(t => { @@ -26,4 +28,4 @@ public void No_Two_Enum_Members_Share_The_Same_Integer_Value() enumTypesWithDuplicateValues.Should().BeEmpty("this may cause undefined behaviour"); // https://github.com/dotnet/runtime/issues/107296#issuecomment-2327881647 } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestExterneReferenzen.cs b/BO4ETestProject/TestExterneReferenzen.cs index f07b5167..d3092aa3 100644 --- a/BO4ETestProject/TestExterneReferenzen.cs +++ b/BO4ETestProject/TestExterneReferenzen.cs @@ -12,39 +12,57 @@ public class TestExterneReferenzen [TestMethod] public void TestGettingAndSetting() { - var marktlokation = new Marktlokation - { - MarktlokationsId = "54321012345" - }; + var marktlokation = new Marktlokation { MarktlokationsId = "54321012345" }; Assert.IsFalse(marktlokation.TryGetExterneReferenz("foo", out var _)); marktlokation.ExterneReferenzen = new List(); Assert.IsFalse(marktlokation.TryGetExterneReferenz("foo", out var _)); - marktlokation.ExterneReferenzen.Add(new ExterneReferenz { ExRefName = "foo", ExRefWert = "bar" }); + marktlokation.ExterneReferenzen.Add( + new ExterneReferenz { ExRefName = "foo", ExRefWert = "bar" } + ); Assert.IsTrue(marktlokation.TryGetExterneReferenz("foo", out var actualBar)); Assert.AreEqual("bar", actualBar); Assert.ThrowsException( - () => marktlokation.SetExterneReferenz(new ExterneReferenz { ExRefName = null, ExRefWert = "nicht bar" }), - "must not add invalid values"); + () => + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = null, ExRefWert = "nicht bar" } + ), + "must not add invalid values" + ); Assert.ThrowsException( - () => marktlokation.SetExterneReferenz(new ExterneReferenz { ExRefName = "foo", ExRefWert = null }), - "must not add invalid values"); - Assert.ThrowsException(() => marktlokation.SetExterneReferenz(null), - "must not add null"); + () => + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = "foo", ExRefWert = null } + ), + "must not add invalid values" + ); + Assert.ThrowsException( + () => marktlokation.SetExterneReferenz(null), + "must not add null" + ); Assert.ThrowsException( - () => marktlokation.SetExterneReferenz(new ExterneReferenz - { ExRefName = "foo", ExRefWert = "nicht bar" }), "By default conflicting values are rejected"); - marktlokation.SetExterneReferenz(new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" }, true); + () => + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" } + ), + "By default conflicting values are rejected" + ); + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = "foo", ExRefWert = "nicht bar" }, + true + ); Assert.IsTrue(marktlokation.TryGetExterneReferenz("foo", out actualBar)); Assert.AreNotEqual("bar", actualBar); marktlokation.ExterneReferenzen = null; - marktlokation.SetExterneReferenz(new ExterneReferenz - { ExRefName = "foo", ExRefWert = "bar" }); // if null, list is automatically created - marktlokation.SetExterneReferenz(new ExterneReferenz - { ExRefName = "foo", ExRefWert = "bar" }); // setting a non-conflicting value twice doesn't hurt + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = "foo", ExRefWert = "bar" } + ); // if null, list is automatically created + marktlokation.SetExterneReferenz( + new ExterneReferenz { ExRefName = "foo", ExRefWert = "bar" } + ); // setting a non-conflicting value twice doesn't hurt Assert.IsTrue(marktlokation.TryGetExterneReferenz("foo", out actualBar)); Assert.AreEqual("bar", actualBar); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestGeraetemerkmalConverter.cs b/BO4ETestProject/TestGeraetemerkmalConverter.cs index dfaa912c..a6d95628 100644 --- a/BO4ETestProject/TestGeraetemerkmalConverter.cs +++ b/BO4ETestProject/TestGeraetemerkmalConverter.cs @@ -14,6 +14,7 @@ public class TestGeraeteerkmalDeserialization private const string JsonString = "{\"merkmal\":\"G4\"}"; private const string JsonStringWithPeriod = "{\"merkmal\":\"G2Period5\"}"; private const string JsonStringWasser = "{\"merkmal\":\"WASSER_MWZW\"}"; + internal class SomethingWithAGeraetemerkmal { [JsonProperty(PropertyName = "merkmal")] // system.text @@ -31,49 +32,77 @@ internal class SomethingWithANullableGeraetemerkmal [TestMethod] public void TestNewtonsoft_Error() { - var errorAction = () => Newtonsoft.Json.JsonConvert.DeserializeObject(JsonString); - errorAction.Should().Throw().Which.Message.StartsWith("Error converting value \"G4\" to type"); + var errorAction = () => + Newtonsoft.Json.JsonConvert.DeserializeObject(JsonString); + errorAction + .Should() + .Throw() + .Which.Message.StartsWith("Error converting value \"G4\" to type"); } [TestMethod] public void TestSystemText_Error() { - var errorAction = () => System.Text.Json.JsonSerializer.Deserialize(JsonString); - errorAction.Should().Throw().Which.Message.StartsWith("The JSON value could not be converted to BO4E.ENUM.Geraetemerkmal"); + var errorAction = () => + System.Text.Json.JsonSerializer.Deserialize(JsonString); + errorAction + .Should() + .Throw() + .Which.Message.StartsWith( + "The JSON value could not be converted to BO4E.ENUM.Geraetemerkmal" + ); } [TestMethod] public void TestNewtonsoft_Success_NonNullable() { - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(JsonString, new LenientGeraetemerkmalGasConverter()); + var result = Newtonsoft.Json.JsonConvert.DeserializeObject( + JsonString, + new LenientGeraetemerkmalGasConverter() + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4); } [TestMethod] public void TestNewtonsoft_Success_NonNullable_GPointSomething() { - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(JsonStringWithPeriod, new LenientGeraetemerkmalGasConverter()); + var result = Newtonsoft.Json.JsonConvert.DeserializeObject( + JsonStringWithPeriod, + new LenientGeraetemerkmalGasConverter() + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G2P5); } [TestMethod] public void TestNewtonsoft_Success_Nullable() { - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(JsonString, new LenientGeraetemerkmalGasConverter()); + var result = + Newtonsoft.Json.JsonConvert.DeserializeObject( + JsonString, + new LenientGeraetemerkmalGasConverter() + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4); } [TestMethod] public void TestNewtonsoft_Success_Nullable_WASSER_MWZW() { - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(JsonString, new LenientGeraetemerkmalGasConverter()); + var result = + Newtonsoft.Json.JsonConvert.DeserializeObject( + JsonString, + new LenientGeraetemerkmalGasConverter() + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4); } [TestMethod] public void TestNewtonsoft_Success_Nullable_GPointSomething() { - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(JsonStringWasser, new LenientGeraetemerkmalGasConverter()); + var result = + Newtonsoft.Json.JsonConvert.DeserializeObject( + JsonStringWasser, + new LenientGeraetemerkmalGasConverter() + ); result.Merkmal.Should().Be(Geraetemerkmal.WASSER_MWZW); } @@ -82,9 +111,12 @@ public void TestSystemText_Success_NonNullable() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextGeraetemerkmalGasConverter() }, }; - var result = System.Text.Json.JsonSerializer.Deserialize(JsonString, settings); + var result = System.Text.Json.JsonSerializer.Deserialize( + JsonString, + settings + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4); } @@ -93,9 +125,12 @@ public void TestSystemText_Success_NonNullable_WASSER_MWZW() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextGeraetemerkmalGasConverter() }, }; - var result = System.Text.Json.JsonSerializer.Deserialize(JsonStringWasser, settings); + var result = System.Text.Json.JsonSerializer.Deserialize( + JsonStringWasser, + settings + ); result.Merkmal.Should().Be(Geraetemerkmal.WASSER_MWZW); } @@ -104,9 +139,12 @@ public void TestSystemText_Success_GPointSomething() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextGeraetemerkmalGasConverter() }, }; - var result = System.Text.Json.JsonSerializer.Deserialize(JsonStringWithPeriod, settings); + var result = System.Text.Json.JsonSerializer.Deserialize( + JsonStringWithPeriod, + settings + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G2P5); } @@ -115,19 +153,22 @@ public void TestSystemText_Nullable_Success_GPointSomething() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() }, }; - var result = System.Text.Json.JsonSerializer.Deserialize(JsonStringWithPeriod, settings); + var result = + System.Text.Json.JsonSerializer.Deserialize( + JsonStringWithPeriod, + settings + ); result.Merkmal.Should().Be(Geraetemerkmal.GAS_G2P5); } - [TestMethod] public void TestSystemText_Write_NonNullable() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextGeraetemerkmalGasConverter() }, }; var instance = new SomethingWithAGeraetemerkmal { Merkmal = Geraetemerkmal.GAS_G4 }; var json = System.Text.Json.JsonSerializer.Serialize(instance, settings); @@ -139,9 +180,12 @@ public void TestSystemText_Write_Nullable() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() }, + }; + var instance = new SomethingWithANullableGeraetemerkmal + { + Merkmal = Geraetemerkmal.GAS_G2P5, }; - var instance = new SomethingWithANullableGeraetemerkmal { Merkmal = Geraetemerkmal.GAS_G2P5 }; var json = System.Text.Json.JsonSerializer.Serialize(instance, settings); json.Should().Be("{\"merkmal\":\"G2P5\"}"); } @@ -151,10 +195,10 @@ public void TestSystemText_Write_Nullable_Null() { var settings = new System.Text.Json.JsonSerializerOptions() { - Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() } + Converters = { new LenientSystemTextNullableGeraetemerkmalGasConverter() }, }; var instance = new SomethingWithANullableGeraetemerkmal { Merkmal = null }; var json = System.Text.Json.JsonSerializer.Serialize(instance, settings); json.Should().Be("{\"merkmal\":null}"); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestHelper/JsonHelper.cs b/BO4ETestProject/TestHelper/JsonHelper.cs index 0d87a605..294e868f 100644 --- a/BO4ETestProject/TestHelper/JsonHelper.cs +++ b/BO4ETestProject/TestHelper/JsonHelper.cs @@ -8,43 +8,43 @@ public static JToken RemoveEmptyChildren(JToken token) switch (token.Type) { case JTokenType.Object: + { + var copy = new JObject(); + foreach (var prop in token.Children()) { - var copy = new JObject(); - foreach (var prop in token.Children()) + var child = prop.Value; + if (child.HasValues) { - var child = prop.Value; - if (child.HasValues) - { - child = RemoveEmptyChildren(child); - } - - if (!IsEmpty(child)) - { - copy.Add(prop.Name, child); - } + child = RemoveEmptyChildren(child); } - return copy; + if (!IsEmpty(child)) + { + copy.Add(prop.Name, child); + } } + + return copy; + } case JTokenType.Array: + { + var copy = new JArray(); + foreach (var item in token.Children()) { - var copy = new JArray(); - foreach (var item in token.Children()) + var child = item; + if (child.HasValues) { - var child = item; - if (child.HasValues) - { - child = RemoveEmptyChildren(child); - } - - if (!IsEmpty(child)) - { - copy.Add(child); - } + child = RemoveEmptyChildren(child); } - return copy; + if (!IsEmpty(child)) + { + copy.Add(child); + } } + + return copy; + } default: return token; } @@ -54,4 +54,4 @@ public static bool IsEmpty(JToken token) { return token.Type == JTokenType.Null; } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestJsonOrder.cs b/BO4ETestProject/TestJsonOrder.cs index 69cee45e..605c582a 100644 --- a/BO4ETestProject/TestJsonOrder.cs +++ b/BO4ETestProject/TestJsonOrder.cs @@ -1,18 +1,13 @@ -using BO4E.BO; -using BO4E.COM; - -using FluentAssertions; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Newtonsoft.Json; - using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text.Json.Serialization; - +using BO4E.BO; +using BO4E.COM; +using FluentAssertions; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute; namespace TestBO4E; @@ -35,132 +30,165 @@ public void TestJsonOrderAttributesOfBO() /// /// contains those types where the order of the json elements/properties should _not_ be enforced for now /// - static readonly HashSet IgnoreOrderTypes = new() - { - // todo: make this list smaller, step by step. - // we could for example assign these as "Strafarbeiten" for commits on dev/main that broke the tests - - // DON'T ADD NEW ENTRIES TO THE LIST - - // BusinessObjects - typeof(Auftrag), - typeof(AuftragsStorno), - typeof(Avis), - typeof(Benachrichtigung), - typeof(Berechnungsformel), - typeof(Energiemenge), - typeof(Entsperrauftrag), - typeof(Marktteilnehmer), - typeof(Kosten), - typeof(PreisblattDienstleistung), - typeof(PreisblattKonzessionsabgabe), - typeof(PreisblattMessung), - typeof(PreisblattNetznutzung), - typeof(PreisblattUmlagen), - typeof(Region), - typeof(Sperrauftrag), - typeof(SperrauftragsStorno), - - // COMponents - typeof(Abweichung), - typeof(AufAbschlag), - typeof(Aufgabe), - typeof(Ausschreibungsdetail), - typeof(Ausschreibungslos), - typeof(Avisposition), - typeof(Betrag), - typeof(COM), - typeof(Dienstleistung), - typeof(Energieherkunft), - typeof(Energiemix), - typeof(ExterneReferenz), - typeof(Fehler), - typeof(FehlerUrsache), - typeof(GenericStringStringInfo), - typeof(Geokoordinaten), - typeof(Handelsunstimmigkeitsbegruendung), - typeof(Hardware), - typeof(Katasteradresse), - typeof(Konzessionsabgabe), - typeof(Kostenblock), - typeof(Kostenposition), - typeof(KriteriumsWert), - typeof(Lastprofil), - //#pragma warning disable CS0619 - // typeof(BO4E.COM.Marktrolle), - //#pragma warning disable CS0619 - typeof(MarktpartnerDetails), - typeof(Messlokationszuordnung), - typeof(Notiz), - typeof(PhysikalischerWert), - typeof(PositionsAufAbschlag), - typeof(Preis), - typeof(Preisgarantie), - typeof(Preisstaffel), - typeof(Rechenschritt), - typeof(RechnungspositionFlat), - typeof(RegionaleGueltigkeit), - typeof(RegionalePreisgarantie), - typeof(RegionalePreisstaffel), - typeof(RegionalerAufAbschlag), - typeof(RegionaleTarifpreisposition), - typeof(Regionskriterium), - typeof(Rufnummer), - typeof(Sigmoidparameter), - typeof(StatusZusatzInformation), - typeof(Steuerbetrag), - typeof(Tagesparameter), - typeof(Tarifberechnungsparameter), - typeof(Tarifeinschraenkung), - typeof(Tarifpreisposition), - typeof(Unterschrift), - typeof(Verbrauch), - typeof(Verwendungszweck), - typeof(Vertragsteil), - typeof(Konfigurationsprodukt), - typeof(Zeitraum), - typeof(Zustaendigkeit) - }; + static readonly HashSet IgnoreOrderTypes = + new() + { + // todo: make this list smaller, step by step. + // we could for example assign these as "Strafarbeiten" for commits on dev/main that broke the tests + + // DON'T ADD NEW ENTRIES TO THE LIST + + // BusinessObjects + typeof(Auftrag), + typeof(AuftragsStorno), + typeof(Avis), + typeof(Benachrichtigung), + typeof(Berechnungsformel), + typeof(Energiemenge), + typeof(Entsperrauftrag), + typeof(Marktteilnehmer), + typeof(Kosten), + typeof(PreisblattDienstleistung), + typeof(PreisblattKonzessionsabgabe), + typeof(PreisblattMessung), + typeof(PreisblattNetznutzung), + typeof(PreisblattUmlagen), + typeof(Region), + typeof(Sperrauftrag), + typeof(SperrauftragsStorno), + // COMponents + typeof(Abweichung), + typeof(AufAbschlag), + typeof(Aufgabe), + typeof(Ausschreibungsdetail), + typeof(Ausschreibungslos), + typeof(Avisposition), + typeof(Betrag), + typeof(COM), + typeof(Dienstleistung), + typeof(Energieherkunft), + typeof(Energiemix), + typeof(ExterneReferenz), + typeof(Fehler), + typeof(FehlerUrsache), + typeof(GenericStringStringInfo), + typeof(Geokoordinaten), + typeof(Handelsunstimmigkeitsbegruendung), + typeof(Hardware), + typeof(Katasteradresse), + typeof(Konzessionsabgabe), + typeof(Kostenblock), + typeof(Kostenposition), + typeof(KriteriumsWert), + typeof(Lastprofil), + //#pragma warning disable CS0619 + // typeof(BO4E.COM.Marktrolle), + //#pragma warning disable CS0619 + typeof(MarktpartnerDetails), + typeof(Messlokationszuordnung), + typeof(Notiz), + typeof(PhysikalischerWert), + typeof(PositionsAufAbschlag), + typeof(Preis), + typeof(Preisgarantie), + typeof(Preisstaffel), + typeof(Rechenschritt), + typeof(RechnungspositionFlat), + typeof(RegionaleGueltigkeit), + typeof(RegionalePreisgarantie), + typeof(RegionalePreisstaffel), + typeof(RegionalerAufAbschlag), + typeof(RegionaleTarifpreisposition), + typeof(Regionskriterium), + typeof(Rufnummer), + typeof(Sigmoidparameter), + typeof(StatusZusatzInformation), + typeof(Steuerbetrag), + typeof(Tagesparameter), + typeof(Tarifberechnungsparameter), + typeof(Tarifeinschraenkung), + typeof(Tarifpreisposition), + typeof(Unterschrift), + typeof(Verbrauch), + typeof(Verwendungszweck), + typeof(Vertragsteil), + typeof(Konfigurationsprodukt), + typeof(Zeitraum), + typeof(Zustaendigkeit), + }; protected static void TestOrderFromAbstract(Type abstractBaseType) { if (!abstractBaseType.IsAbstract) { - throw new ArgumentException($"The type {abstractBaseType} is not abstract", nameof(abstractBaseType)); + throw new ArgumentException( + $"The type {abstractBaseType} is not abstract", + nameof(abstractBaseType) + ); } - var relevantTypes = typeof(BusinessObject).Assembly.GetTypes().Where(abstractBaseType.IsAssignableFrom); - foreach (var relevantType in relevantTypes.Where(t => !IgnoreOrderTypes.Contains(t) && !t.Name.Contains("Marktrolle"))) + var relevantTypes = typeof(BusinessObject) + .Assembly.GetTypes() + .Where(abstractBaseType.IsAssignableFrom); + foreach ( + var relevantType in relevantTypes.Where(t => + !IgnoreOrderTypes.Contains(t) && !t.Name.Contains("Marktrolle") + ) + ) { var properties = relevantType.GetProperties(); var orders = new HashSet(); foreach (var dtProperty in properties) { - var systemTextIgnore = dtProperty.GetCustomAttributes().FirstOrDefault(); + var systemTextIgnore = dtProperty + .GetCustomAttributes() + .FirstOrDefault(); if (systemTextIgnore is not null) { continue; } - var systemTextJsonOrderAttribute = dtProperty.GetCustomAttributes().FirstOrDefault(); - systemTextJsonOrderAttribute.Should() - .NotBeNull(because: $"The property {dtProperty.Name} of {relevantType.Name} should have System.Text.JsonPropertyOrderAttribute"); - var newtonSoftJsonPropertyAttribute = dtProperty.GetCustomAttributes().FirstOrDefault(); - newtonSoftJsonPropertyAttribute.Should().NotBeNull($"The property {dtProperty.Name} of {relevantType.Name} should have Newtonsoft.Json.JsonPropertyAttribute"); + var systemTextJsonOrderAttribute = dtProperty + .GetCustomAttributes() + .FirstOrDefault(); + systemTextJsonOrderAttribute + .Should() + .NotBeNull( + because: $"The property {dtProperty.Name} of {relevantType.Name} should have System.Text.JsonPropertyOrderAttribute" + ); + var newtonSoftJsonPropertyAttribute = dtProperty + .GetCustomAttributes() + .FirstOrDefault(); + newtonSoftJsonPropertyAttribute + .Should() + .NotBeNull( + $"The property {dtProperty.Name} of {relevantType.Name} should have Newtonsoft.Json.JsonPropertyAttribute" + ); var systemTextOrder = systemTextJsonOrderAttribute.Order; - orders.Should().NotContain(systemTextOrder, - because: $"The JsonPropertyOrderAttribute should be unique for {relevantType} but found multiple occurrences of {systemTextOrder}"); + orders + .Should() + .NotContain( + systemTextOrder, + because: $"The JsonPropertyOrderAttribute should be unique for {relevantType} but found multiple occurrences of {systemTextOrder}" + ); orders.Add(systemTextOrder); - var newtonsoftIgnore = dtProperty.GetCustomAttributes().FirstOrDefault(); + var newtonsoftIgnore = dtProperty + .GetCustomAttributes() + .FirstOrDefault(); if (newtonsoftIgnore is not null) { continue; } var newtonsoftOrder = newtonSoftJsonPropertyAttribute.Order; - systemTextOrder.Should().Be(newtonsoftOrder, because: $"System.Text Order and Newtonsoft Order of {relevantType.Name}.{dtProperty.Name} should be the same."); + systemTextOrder + .Should() + .Be( + newtonsoftOrder, + because: $"System.Text Order and Newtonsoft Order of {relevantType.Name}.{dtProperty.Name} should be the same." + ); } } } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestJsonSchemaGeneration.cs b/BO4ETestProject/TestJsonSchemaGeneration.cs index d1b89c31..c0484343 100644 --- a/BO4ETestProject/TestJsonSchemaGeneration.cs +++ b/BO4ETestProject/TestJsonSchemaGeneration.cs @@ -26,13 +26,15 @@ public void BasicTest() [TestMethod] public void NegativeTest() { - Assert.ThrowsException(() => BusinessObject.GetJsonSchema(typeof(string)), - "Illegal types must result in a ArgumentException."); + Assert.ThrowsException( + () => BusinessObject.GetJsonSchema(typeof(string)), + "Illegal types must result in a ArgumentException." + ); } - private const int LastDataRowOffset = 50; private const int MaxSchemasPerHour = 10; + [TestMethod] [DataRow(0)] [DataRow(10)] @@ -40,12 +42,15 @@ public void NegativeTest() [DataRow(30)] [DataRow(40)] [DataRow(LastDataRowOffset)] // using these different data rows allows you to workaround the 10schema per hour limitation (MaxSchemasPerHour) - public void TestJSchemaFileGenerationBo(int offset) { - var relevantBusinessObjectTypes = typeof(BusinessObject).Assembly.GetTypes() + var relevantBusinessObjectTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => t.IsSubclassOf(typeof(BusinessObject))); - relevantBusinessObjectTypes.Count().Should().BeLessThan(LastDataRowOffset + MaxSchemasPerHour); // if this fails, add another data row to this test method + relevantBusinessObjectTypes + .Count() + .Should() + .BeLessThan(LastDataRowOffset + MaxSchemasPerHour); // if this fails, add another data row to this test method try // generate plain json schemas { foreach (var type in relevantBusinessObjectTypes.Skip(offset).Take(MaxSchemasPerHour)) @@ -61,4 +66,4 @@ public void TestJSchemaFileGenerationBo(int offset) // thats life. pay for it if you'd like to :P } } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestMaLoMeLoId.cs b/BO4ETestProject/TestMaLoMeLoId.cs index 57933271..d9076ae6 100644 --- a/BO4ETestProject/TestMaLoMeLoId.cs +++ b/BO4ETestProject/TestMaLoMeLoId.cs @@ -42,7 +42,7 @@ public void TestMaLoValidity() MarktlokationsId = "1235678901", Sparte = Sparte.STROM, Energierichtung = Energierichtung.AUSSP, - Regelzone = null + Regelzone = null, }; Assert.IsFalse(malo.IsValid()); // because the obligatory bilanzierungsmethode is not set malo.Bilanzierungsmethode = Bilanzierungsmethode.SLP; @@ -59,4 +59,4 @@ public void TestMaLoValidity() malo.Bilanzierungsgebiet = "11YN10000762-01E"; Assert.IsTrue(malo.IsValid()); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestMultiLangJson.cs b/BO4ETestProject/TestMultiLangJson.cs index 7a68675d..6b386f30 100644 --- a/BO4ETestProject/TestMultiLangJson.cs +++ b/BO4ETestProject/TestMultiLangJson.cs @@ -16,12 +16,12 @@ public void TestContractResolverSerialization() var mlb = new MultiLangBo { DatumDeutsch = new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero), - WertDeutsch = "Hallo Welt" + WertDeutsch = "Hallo Welt", }; var settings = new JsonSerializerSettings { ContractResolver = new MultiLangResolver(Language.EN), - Formatting = Formatting.Indented + Formatting = Formatting.Indented, }; var json = JsonConvert.SerializeObject(mlb, settings); @@ -48,19 +48,34 @@ public void TestNestedContractResolverSerialization() { BoolDeutsch = true, InternDeutsch = "Hallo", - IntDeutsch = 33 + IntDeutsch = 33, }, InternList = new List { - new NestedObject {BoolDeutsch = false, IntDeutsch = 10, InternDeutsch = "internalList1"}, - new NestedObject {BoolDeutsch = false, IntDeutsch = 35, InternDeutsch = "internalList2"}, - new NestedObject {BoolDeutsch = true, IntDeutsch = 1200, InternDeutsch = "internalList3"} - } + new NestedObject + { + BoolDeutsch = false, + IntDeutsch = 10, + InternDeutsch = "internalList1", + }, + new NestedObject + { + BoolDeutsch = false, + IntDeutsch = 35, + InternDeutsch = "internalList2", + }, + new NestedObject + { + BoolDeutsch = true, + IntDeutsch = 1200, + InternDeutsch = "internalList3", + }, + }, }; var settings = new JsonSerializerSettings { ContractResolver = new MultiLangResolver(Language.EN), - Formatting = Formatting.Indented + Formatting = Formatting.Indented, }; var json = JsonConvert.SerializeObject(mlb, settings); @@ -133,4 +148,4 @@ public class MultiLangBo : BusinessObject // var json = JsonConvert.SerializeObject(rechnung, settings); // } //} -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestNotizDeserialization.cs b/BO4ETestProject/TestNotizDeserialization.cs index bb7737b0..b3ddd307 100644 --- a/BO4ETestProject/TestNotizDeserialization.cs +++ b/BO4ETestProject/TestNotizDeserialization.cs @@ -12,7 +12,8 @@ public class TestNotizDeserialization public void TestMinusRemovalNewtonsoft() { var n = JsonConvert.DeserializeObject( - "{\"klaerfallnummer\":\"468982\",\"autor\":\"Max Mustermann\",\"zeitpunkt\":\"2019-05-24T14:05:00Z\",\"inhalt\":\"hallo. das ist eine notiz mit einem lustigen emoji 🥝\n------------------------------------------------------------------------\",\"tdid\":\"0002\",\"tdname\":\"0000468982\",\"tdobject\":\"EMMA_CASE\"}"); + "{\"klaerfallnummer\":\"468982\",\"autor\":\"Max Mustermann\",\"zeitpunkt\":\"2019-05-24T14:05:00Z\",\"inhalt\":\"hallo. das ist eine notiz mit einem lustigen emoji 🥝\n------------------------------------------------------------------------\",\"tdid\":\"0002\",\"tdname\":\"0000468982\",\"tdobject\":\"EMMA_CASE\"}" + ); Assert.AreEqual("hallo. das ist eine notiz mit einem lustigen emoji 🥝", n.Inhalt); } @@ -20,8 +21,9 @@ public void TestMinusRemovalNewtonsoft() public void TestMinusRemoval() { var n = JsonSerializer.Deserialize( - "{\"klaerfallnummer\":\"468982\",\"autor\":\"Max Mustermann\",\"zeitpunkt\":\"2019-05-24T14:05:00Z\",\"inhalt\":\"hallo. das ist eine notiz mit einem lustigen emoji 🥝\\n------------------------------------------------------------------------\",\"tdid\":\"0002\",\"tdname\":\"0000468982\",\"tdobject\":\"EMMA_CASE\"}"); + "{\"klaerfallnummer\":\"468982\",\"autor\":\"Max Mustermann\",\"zeitpunkt\":\"2019-05-24T14:05:00Z\",\"inhalt\":\"hallo. das ist eine notiz mit einem lustigen emoji 🥝\\n------------------------------------------------------------------------\",\"tdid\":\"0002\",\"tdname\":\"0000468982\",\"tdobject\":\"EMMA_CASE\"}" + ); Assert.IsNotNull(n); Assert.AreEqual("hallo. das ist eine notiz mit einem lustigen emoji 🥝", n.Inhalt); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestNullable.cs b/BO4ETestProject/TestNullable.cs index a3f74b19..92d86043 100644 --- a/BO4ETestProject/TestNullable.cs +++ b/BO4ETestProject/TestNullable.cs @@ -1,13 +1,10 @@ using System; using System.Linq; using System.Reflection; - using BO4E.BO; using BO4E.COM; using FluentAssertions; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json; namespace TestBO4E; @@ -21,7 +18,6 @@ public void TestNullableAttributesFromCOM() TestNullableAttributesFromAbstract(typeof(COM)); } - [TestMethod] public void TestNullableAttributesFromBO() { @@ -30,32 +26,39 @@ public void TestNullableAttributesFromBO() private NullabilityInfoContext _nullabilityContext = new(); - protected void TestNullableAttributesFromAbstract(Type abstractBaseType) { if (!abstractBaseType.IsAbstract) { - throw new ArgumentException($"The type {abstractBaseType} is not abstract", nameof(abstractBaseType)); + throw new ArgumentException( + $"The type {abstractBaseType} is not abstract", + nameof(abstractBaseType) + ); } - var relevantTypes = typeof(BusinessObject).Assembly.GetTypes() + var relevantTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => abstractBaseType.IsAssignableFrom(t)); foreach (var relevantType in relevantTypes) { var properties = relevantType.GetProperties(); foreach (var dtProperty in properties) { - var jpA = dtProperty.GetCustomAttributes().FirstOrDefault(); if (jpA is not null) { if (jpA.Required != Required.Always) // all not required fields have to be nullable { var nullabilityInfo = _nullabilityContext.Create(dtProperty); - nullabilityInfo.ReadState.Should().Be(NullabilityState.Nullable, $"The property {dtProperty.Name} of type {relevantType.Name} has to be nullable"); + nullabilityInfo + .ReadState.Should() + .Be( + NullabilityState.Nullable, + $"The property {dtProperty.Name} of type {relevantType.Name} has to be nullable" + ); } } } } } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestProtoFileGeneration.cs b/BO4ETestProject/TestProtoFileGeneration.cs index 27adc7ca..2fd45094 100644 --- a/BO4ETestProject/TestProtoFileGeneration.cs +++ b/BO4ETestProject/TestProtoFileGeneration.cs @@ -26,14 +26,16 @@ public class TestProtoFileGeneration typeof(Rechnung), typeof(Region), typeof(Vertrag), - typeof(Zaehler) + typeof(Zaehler), }; [TestMethod] public void TestProtoGenerationBo() { - var method = typeof(Serializer).GetMethod(nameof(Serializer.GetProto), - new[] { typeof(ProtoBuf.Meta.SchemaGenerationOptions) }); + var method = typeof(Serializer).GetMethod( + nameof(Serializer.GetProto), + new[] { typeof(ProtoBuf.Meta.SchemaGenerationOptions) } + ); Assert.IsNotNull(method); var options = new ProtoBuf.Meta.SchemaGenerationOptions @@ -54,4 +56,4 @@ public void TestProtoGenerationBo() File.WriteAllText(path, protoString, new UTF8Encoding(false)); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestProtobufAttributes.cs b/BO4ETestProject/TestProtobufAttributes.cs index 0a81bf82..487f227b 100644 --- a/BO4ETestProject/TestProtobufAttributes.cs +++ b/BO4ETestProject/TestProtobufAttributes.cs @@ -55,11 +55,17 @@ protected void TestUniqueProtobufMemberIdAbstract(Type abstractType) { if (!abstractType.IsAbstract) { - throw new ArgumentException($"The type {abstractType} is not abstract", nameof(abstractType)); + throw new ArgumentException( + $"The type {abstractType} is not abstract", + nameof(abstractType) + ); } - foreach (var type in - typeof(BusinessObject).Assembly.GetTypes().Where(t => abstractType.IsAssignableFrom(t))) + foreach ( + var type in typeof(BusinessObject) + .Assembly.GetTypes() + .Where(t => abstractType.IsAssignableFrom(t)) + ) TestProtobufType(type, type.BaseType == abstractType || type == abstractType); } @@ -70,47 +76,73 @@ protected void TestProtobufType(Type type, bool isDirectBase) if (isDirectBase) { allFields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); - fieldsWithProtoMemberAttribute = type.GetFields(BindingFlags.Public | BindingFlags.Instance) + fieldsWithProtoMemberAttribute = type.GetFields( + BindingFlags.Public | BindingFlags.Instance + ) .Where(f => f.GetCustomAttributes(typeof(ProtoMemberAttribute), true).Any()); } else { - allFields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); - fieldsWithProtoMemberAttribute = type - .GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(f => - f.GetCustomAttributes(typeof(ProtoMemberAttribute), false).Any()); + allFields = type.GetFields( + BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly + ); + fieldsWithProtoMemberAttribute = type.GetFields( + BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly + ) + .Where(f => f.GetCustomAttributes(typeof(ProtoMemberAttribute), false).Any()); } var nonOfficialFieldsWithProtoMember = allFields + .Where(field => field.GetCustomAttributes(typeof(NonOfficialAttribute)).Any()) // those fields having an [NonOfficial(...)] attribute .Where(field => - field.GetCustomAttributes(typeof(NonOfficialAttribute)) - .Any()) // those fields having an [NonOfficial(...)] attribute - .Where(field => - ((NonOfficialAttribute)field.GetCustomAttributes(typeof(NonOfficialAttribute)).First()) - .HasCategory(NonOfficialCategory.CUSTOMER_REQUIREMENTS)) // and the customer_requirements category + ( + (NonOfficialAttribute) + field.GetCustomAttributes(typeof(NonOfficialAttribute)).First() + ).HasCategory(NonOfficialCategory.CUSTOMER_REQUIREMENTS) + ) // and the customer_requirements category .Intersect(fieldsWithProtoMemberAttribute); // and a [ProtoMember()] attribute var wrongTagsNonOfficial = nonOfficialFieldsWithProtoMember.Where(f => - ((ProtoMemberAttribute)f.GetCustomAttributes(typeof(ProtoMemberAttribute)).First()).Tag < 1000); - Assert.AreEqual(0, wrongTagsNonOfficial.Count(), - $"Fields in {type} are non official and do not have proto tags >= 1000: {string.Join(", ", wrongTagsNonOfficial.Select(f => f.Name))}"); - var wrongTagsOfficial = fieldsWithProtoMemberAttribute.Except(nonOfficialFieldsWithProtoMember).Where(f => - ((ProtoMemberAttribute)f.GetCustomAttributes(typeof(ProtoMemberAttribute)).First()).Tag > 1000); - Assert.AreEqual(0, wrongTagsOfficial.Count(), - $"Fields in {type} are official but have proto tags >= 1000: {string.Join(", ", wrongTagsOfficial.Select(f => f.Name))}"); + ((ProtoMemberAttribute)f.GetCustomAttributes(typeof(ProtoMemberAttribute)).First()).Tag + < 1000 + ); + Assert.AreEqual( + 0, + wrongTagsNonOfficial.Count(), + $"Fields in {type} are non official and do not have proto tags >= 1000: {string.Join(", ", wrongTagsNonOfficial.Select(f => f.Name))}" + ); + var wrongTagsOfficial = fieldsWithProtoMemberAttribute + .Except(nonOfficialFieldsWithProtoMember) + .Where(f => + ( + (ProtoMemberAttribute) + f.GetCustomAttributes(typeof(ProtoMemberAttribute)).First() + ).Tag > 1000 + ); + Assert.AreEqual( + 0, + wrongTagsOfficial.Count(), + $"Fields in {type} are official but have proto tags >= 1000: {string.Join(", ", wrongTagsOfficial.Select(f => f.Name))}" + ); try { if (isDirectBase) { - Assert.AreEqual(allFields.Length, fieldsWithProtoMemberAttribute.Count(), - $"Missing protobuf attributes for {type} for: " + - string.Join(", ", allFields.Except(fieldsWithProtoMemberAttribute))); + Assert.AreEqual( + allFields.Length, + fieldsWithProtoMemberAttribute.Count(), + $"Missing protobuf attributes for {type} for: " + + string.Join(", ", allFields.Except(fieldsWithProtoMemberAttribute)) + ); } } catch (ArgumentOutOfRangeException aoore) when (aoore.ParamName == "tag") { - Assert.IsTrue(false, $"Do you have any ProtoMember attributes with an id<=0 in {type}?"); + Assert.IsTrue( + false, + $"Do you have any ProtoMember attributes with an id<=0 in {type}?" + ); throw; } @@ -122,13 +154,19 @@ protected void TestProtobufType(Type type, bool isDirectBase) .GroupBy(pma => pma.Tag) .Where(g => g.Count() > 1) .ToDictionary(pma => pma.Key, y => y.Count()); - Assert.AreEqual(0, duplicateTags.Count, - $"The following [(ProtoMember()] tags in {type} are not unique: {string.Join(", ", duplicateTags.Keys)}"); + Assert.AreEqual( + 0, + duplicateTags.Count, + $"The following [(ProtoMember()] tags in {type} are not unique: {string.Join(", ", duplicateTags.Keys)}" + ); } else { - Assert.AreEqual(0, fieldsWithProtoMemberAttribute.Count(), - $"Classes like {type} not directly inheriting from BusinessObject or COM must not have Protobuf Attributes (due to protobuf-net bugs)"); + Assert.AreEqual( + 0, + fieldsWithProtoMemberAttribute.Count(), + $"Classes like {type} not directly inheriting from BusinessObject or COM must not have Protobuf Attributes (due to protobuf-net bugs)" + ); } } @@ -136,42 +174,78 @@ protected void TestProtobufDateTimeWorkaround(Type abstractBaseType) { if (!abstractBaseType.IsAbstract) { - throw new ArgumentException($"The type {abstractBaseType} is not abstract", nameof(abstractBaseType)); + throw new ArgumentException( + $"The type {abstractBaseType} is not abstract", + nameof(abstractBaseType) + ); } - var relevantTypes = typeof(BusinessObject).Assembly.GetTypes() + var relevantTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => abstractBaseType.IsAssignableFrom(t)); foreach (var relevantType in relevantTypes) { - var dtProperties = relevantType.GetProperties().Where(p => - p.PropertyType == typeof(DateTime)); + var dtProperties = relevantType + .GetProperties() + .Where(p => p.PropertyType == typeof(DateTime)); foreach (var dtProperty in dtProperties) { // there must be an attribute like described in https://github.com/protobuf-net/protobuf-net.Grpc/issues/56#issuecomment-580509687 var pma = dtProperty.GetCustomAttributes().FirstOrDefault(); - Assert.IsNotNull(pma, - $"The property {dtProperty.Name} of type {relevantType.Name} is missing the ProtoMemberAttribute."); - var cla = dtProperty.GetCustomAttributes().FirstOrDefault(); - Assert.AreEqual(CompatibilityLevel.Level240, cla?.Level, $"The property {dtProperty.Name} of type {relevantType.Name} does not have the Compatability Level Attribute or the wrong value"); + Assert.IsNotNull( + pma, + $"The property {dtProperty.Name} of type {relevantType.Name} is missing the ProtoMemberAttribute." + ); + var cla = dtProperty + .GetCustomAttributes() + .FirstOrDefault(); + Assert.AreEqual( + CompatibilityLevel.Level240, + cla?.Level, + $"The property {dtProperty.Name} of type {relevantType.Name} does not have the Compatability Level Attribute or the wrong value" + ); } - var nullableDtProperties = relevantType.GetProperties().Where(p => - p.PropertyType == typeof(DateTime?) || p.PropertyType == typeof(DateTimeOffset) || p.PropertyType == typeof(DateTimeOffset?)); + var nullableDtProperties = relevantType + .GetProperties() + .Where(p => + p.PropertyType == typeof(DateTime?) + || p.PropertyType == typeof(DateTimeOffset) + || p.PropertyType == typeof(DateTimeOffset?) + ); foreach (var nullableDtProperty in nullableDtProperties) { // as long as protobuf-net is not able to handle nullable native types this is required. see f.e. https://github.com/protobuf-net/protobuf-net/issues/742 - var pia = nullableDtProperty.GetCustomAttributes().FirstOrDefault(); - if (relevantType == typeof(Zeitraum) && new HashSet { "startzeitpunkt", "endzeitpunkt" }.Contains(nullableDtProperty.Name.ToLower())) + var pia = nullableDtProperty + .GetCustomAttributes() + .FirstOrDefault(); + if ( + relevantType == typeof(Zeitraum) + && new HashSet { "startzeitpunkt", "endzeitpunkt" }.Contains( + nullableDtProperty.Name.ToLower() + ) + ) { continue; } - Assert.IsNotNull(pia, - $"The property {nullableDtProperty.Name} of type {relevantType.Name} is missing the {nameof(ProtoIgnoreAttribute)}."); - Assert.IsTrue(relevantType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance).Any(p => p.GetCustomAttributes().Any(pma => pma.Name == nullableDtProperty.Name) - && p.GetCustomAttributes().Any() - && p.GetCustomAttributes().Any() - && p.GetCustomAttributes().Any(cla => cla.Level == CompatibilityLevel.Level240)), - $"There is no workaround property for {relevantType.FullName}.{nullableDtProperty.Name} that has a {nameof(ProtoMemberAttribute)} with the same 'Name={nullableDtProperty.Name}' and the expected Compatability Level and JsonIgnore Attributes."); + Assert.IsNotNull( + pia, + $"The property {nullableDtProperty.Name} of type {relevantType.Name} is missing the {nameof(ProtoIgnoreAttribute)}." + ); + Assert.IsTrue( + relevantType + .GetProperties(BindingFlags.NonPublic | BindingFlags.Instance) + .Any(p => + p.GetCustomAttributes() + .Any(pma => pma.Name == nullableDtProperty.Name) + && p.GetCustomAttributes() + .Any() + && p.GetCustomAttributes().Any() + && p.GetCustomAttributes() + .Any(cla => cla.Level == CompatibilityLevel.Level240) + ), + $"There is no workaround property for {relevantType.FullName}.{nullableDtProperty.Name} that has a {nameof(ProtoMemberAttribute)} with the same 'Name={nullableDtProperty.Name}' and the expected Compatability Level and JsonIgnore Attributes." + ); } } } @@ -180,59 +254,79 @@ protected void TestUniqueProtoIncludeTagAbstract(Type abstractBaseType) // ToDo: { if (!abstractBaseType.IsAbstract) { - throw new ArgumentException($"The type {abstractBaseType} is not abstract", nameof(abstractBaseType)); + throw new ArgumentException( + $"The type {abstractBaseType} is not abstract", + nameof(abstractBaseType) + ); } - var duplicateIncludeTags = typeof(BusinessObject).Assembly.GetTypes() + var duplicateIncludeTags = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => abstractBaseType.IsAssignableFrom(t)) .SelectMany(t => t.GetCustomAttributes(typeof(ProtoIncludeAttribute), false)) .Cast() .GroupBy(pia => pia.Tag) .Where(g => g.Count() > 1) .ToDictionary(pia => pia.Key, tag => tag.Count()); - Assert.AreEqual(0, duplicateIncludeTags.Count, - $"The following [(ProtoInclude(, ...)] attributes are not unique: {string.Join(", ", duplicateIncludeTags.Keys)}"); + Assert.AreEqual( + 0, + duplicateIncludeTags.Count, + $"The following [(ProtoInclude(, ...)] attributes are not unique: {string.Join(", ", duplicateIncludeTags.Keys)}" + ); } [TestMethod] public void TestProtoEnumConsistency() //https://github.com/protobuf-net/protobuf-net/issues/60 { - var enumTypes = typeof(AbgabeArt).Assembly.GetTypes() - .Where(t => t.IsEnum && t.Namespace.StartsWith("BO4E.ENUM") && - !t.Namespace.StartsWith("BO4E.ENUM.EDI")); + var enumTypes = typeof(AbgabeArt) + .Assembly.GetTypes() + .Where(t => + t.IsEnum + && t.Namespace.StartsWith("BO4E.ENUM") + && !t.Namespace.StartsWith("BO4E.ENUM.EDI") + ); var allValues = new List>(); foreach (var enumType in enumTypes) { - var naturalEnumValues = enumType.GetFields() + var naturalEnumValues = enumType + .GetFields() .Where(f => !f.GetCustomAttributes().Any()) .Select(f => new Tuple(enumType, f.Name)); allValues.AddRange(naturalEnumValues); //var protoEnumValues = enumType.GetFields().SelectMany(f => f.GetCustomAttributes()).Select(pea => new Tuple(enumType, pea.Name)); //allValues.AddRange(protoEnumValues); - foreach (var field in enumType.GetFields() - .Where(f => f.GetCustomAttributes().Any())) + foreach ( + var field in enumType + .GetFields() + .Where(f => f.GetCustomAttributes().Any()) + ) { var pea = field.GetCustomAttributes().First(); Assert.AreEqual(enumType.Name + "_" + field.Name, pea.Name); allValues.Add(new Tuple(enumType, pea.Name)); } - Assert.IsTrue(Enum.IsDefined(enumType, 0), - $"Any enum must define a ZERO like value for Protobuf3 but {enumType} doesn't."); + Assert.IsTrue( + Enum.IsDefined(enumType, 0), + $"Any enum must define a ZERO like value for Protobuf3 but {enumType} doesn't." + ); } var nonDistinctValues = allValues .GroupBy(tuple => tuple.Item2) // group by field/protoenum name .Where(g => g.Count() > 1 && g.Key != "value__") .ToDictionary(x => x.Key, y => y.Select(t => t.Item1.Name)); - Assert.IsFalse(nonDistinctValues.Any(), - $"There are non-distinct Enum values. Add a matching [ProtoEnum] attribute to: {JsonConvert.SerializeObject(nonDistinctValues)}"); + Assert.IsFalse( + nonDistinctValues.Any(), + $"There are non-distinct Enum values. Add a matching [ProtoEnum] attribute to: {JsonConvert.SerializeObject(nonDistinctValues)}" + ); } [TestMethod] public void TestExplicitProtobufInheritance() { - var businessObjectTypes = typeof(BusinessObject).Assembly.GetTypes() + var businessObjectTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => typeof(BusinessObject).IsAssignableFrom(t)); var boTypesCrossProduct = from baseType in businessObjectTypes @@ -245,46 +339,61 @@ where baseType.IsAssignableFrom(inheritingType) && baseType != inheritingType foreach (var typePair in boTypesCrossProduct.Distinct()) { // Assert.IsTrue(typePair.baseType.GetCustomAttributes(typeof(ProtoContractAttribute), false).Any(), $"The (base) type {typePair.baseType} has not [ProtoContract] attribute."); // ToDo: re-add this line because fields on BO / COM level are not properly proto-serialized as of now! - if (typePair.inheritingType.BaseType == - typeof(BusinessObject)) //because protobuf-net doesn't support mutliple levels of inheritance + if (typePair.inheritingType.BaseType == typeof(BusinessObject)) //because protobuf-net doesn't support mutliple levels of inheritance { Assert.IsTrue( - typePair.inheritingType.GetCustomAttributes(typeof(ProtoContractAttribute), false).Any(), - $"The (inheriting) type {typePair.inheritingType} has not [ProtoContract] attribute."); + typePair + .inheritingType.GetCustomAttributes(typeof(ProtoContractAttribute), false) + .Any(), + $"The (inheriting) type {typePair.inheritingType} has not [ProtoContract] attribute." + ); } else { Assert.IsFalse( - typePair.inheritingType.GetCustomAttributes(typeof(ProtoContractAttribute), false).Any(), - $"The (INDIRECTLY inheriting) type {typePair.inheritingType} has the [ProtoContract] attribute."); // bug in protobuf-net + typePair + .inheritingType.GetCustomAttributes(typeof(ProtoContractAttribute), false) + .Any(), + $"The (INDIRECTLY inheriting) type {typePair.inheritingType} has the [ProtoContract] attribute." + ); // bug in protobuf-net } - if (typePair.inheritingType.BaseType == typePair.baseType && - typePair.baseType != typeof(BusinessObject)) + if ( + typePair.inheritingType.BaseType == typePair.baseType + && typePair.baseType != typeof(BusinessObject) + ) { // remove the if-block around this statement as soon as protobuf-net supports multiple levels of inheritance // Symptomes: // 1: ProtoBuf.ProtoException: Type 'BO4E.COM.Preisgarantie' can only participate in one inheritance hierarchy (BO4E.COM.Verbrauch) ---> System.InvalidOperationException: Type 'BO4E.COM.Preisgarantie' can only participate in one inheritance hierarchy // 2: System.InvalidOperationException: Duplicate field-number detected; - var typesReferencedByBase = typePair.baseType - .GetCustomAttributes(typeof(ProtoIncludeAttribute), false).Cast() + var typesReferencedByBase = typePair + .baseType.GetCustomAttributes(typeof(ProtoIncludeAttribute), false) + .Cast() .Select(pia => pia.KnownType); - Assert.IsFalse(typesReferencedByBase.Contains(typePair.inheritingType), - $"The base type {typePair.baseType} does not reference the inheriting type {typePair.inheritingType} in a [ProtoInclude(, {typePair.inheritingType})] attribute."); + Assert.IsFalse( + typesReferencedByBase.Contains(typePair.inheritingType), + $"The base type {typePair.baseType} does not reference the inheriting type {typePair.inheritingType} in a [ProtoInclude(, {typePair.inheritingType})] attribute." + ); continue; } - Assert.IsTrue(typePair.baseType.GetCustomAttributes(typeof(ProtoIncludeAttribute), false).Any(), - $"The base type {typePair.baseType} must refer to the inheriting type {typePair.inheritingType} using a [ProtoInclude] attribute."); + Assert.IsTrue( + typePair.baseType.GetCustomAttributes(typeof(ProtoIncludeAttribute), false).Any(), + $"The base type {typePair.baseType} must refer to the inheriting type {typePair.inheritingType} using a [ProtoInclude] attribute." + ); if (typePair.inheritingType.BaseType == typePair.baseType) { - var typesReferencedByBase = typePair.baseType - .GetCustomAttributes(typeof(ProtoIncludeAttribute), false).Cast() + var typesReferencedByBase = typePair + .baseType.GetCustomAttributes(typeof(ProtoIncludeAttribute), false) + .Cast() .Select(pia => pia.KnownType); - Assert.IsTrue(typesReferencedByBase.Contains(typePair.inheritingType), - $"The base type {typePair.baseType} does not reference the inheriting type {typePair.inheritingType} in a [ProtoInclude(, {typePair.inheritingType})] attribute."); + Assert.IsTrue( + typesReferencedByBase.Contains(typePair.inheritingType), + $"The base type {typePair.baseType} does not reference the inheriting type {typePair.inheritingType} in a [ProtoInclude(, {typePair.inheritingType})] attribute." + ); } } } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestProtobufSerialization.cs b/BO4ETestProject/TestProtobufSerialization.cs index 5776a767..59395988 100644 --- a/BO4ETestProject/TestProtobufSerialization.cs +++ b/BO4ETestProject/TestProtobufSerialization.cs @@ -20,7 +20,7 @@ public void TestProtobufRoundTripUnterschrift() { Datum = new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero), Name = "Hans Wurst", - Ort = "Musterstadt" + Ort = "Musterstadt", }; Assert.IsTrue(unterschrift.IsValid(), "Must not serialize invalid COM"); var unterschriftRoundTrip = SerializeAsBase64RoundTrip(unterschrift); @@ -43,9 +43,9 @@ public void TestProtobufRoundTripEnergiemenge() { Einheit = Mengeneinheit.KWH, Wert = 10.0M, - Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0 ,TimeSpan.Zero), + Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), Enddatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero), - Obiskennzahl = "1-0:1.8.1" + Obiskennzahl = "1-0:1.8.1", //Guid = v1Guid }, new Verbrauch @@ -54,10 +54,10 @@ public void TestProtobufRoundTripEnergiemenge() Wert = 23.0M, Startdatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero), Enddatum = new DateTimeOffset(2019, 1, 3, 0, 0, 0, TimeSpan.Zero), - Obiskennzahl = "1-0:1.8.1" + Obiskennzahl = "1-0:1.8.1", //Guid = null - } - } + }, + }, }; Assert.IsTrue(em.IsValid(), "Must not serialize invalid Business Objects."); var emRoundTrip = SerializeAsBase64RoundTrip(em); diff --git a/BO4ETestProject/TestSperrauftrag.cs b/BO4ETestProject/TestSperrauftrag.cs index 9dfacc87..452b01c5 100644 --- a/BO4ETestProject/TestSperrauftrag.cs +++ b/BO4ETestProject/TestSperrauftrag.cs @@ -16,11 +16,8 @@ namespace TestBO4E; [TestClass] public class TestSperrauftrag { - private readonly JsonSerializerOptions _options = new() - { - Converters = { new JsonStringEnumConverter() }, - IgnoreNullValues = true - }; + private readonly JsonSerializerOptions _options = + new() { Converters = { new JsonStringEnumConverter() }, IgnoreNullValues = true }; [TestMethod] public void TestSperrauftragSerializationMaximal() @@ -28,7 +25,10 @@ public void TestSperrauftragSerializationMaximal() var sperrauftrag = new Sperrauftrag { Ausfuehrungsdatum = new DateTimeOffset(2022, 1, 5, 1, 1, 1, TimeSpan.Zero), - Bemerkungen = new List { "Der Typ erwartet uns mit Baseballschläger am Zähler" }, + Bemerkungen = new List + { + "Der Typ erwartet uns mit Baseballschläger am Zähler", + }, Sparte = Sparte.STROM, Zaehlernummer = "1YSE29183123", Lieferanschrift = new Adresse @@ -37,7 +37,7 @@ public void TestSperrauftragSerializationMaximal() Hausnummer = "8", Landescode = Landescode.DE, Postleitzahl = "04109", - Ort = "Leipzig" + Ort = "Leipzig", }, MarktlokationsId = "54321012345", IstVomGerichtsvollzieherAngeordnet = true, @@ -45,9 +45,10 @@ public void TestSperrauftragSerializationMaximal() { new() { - ExRefName = "Blocking service internal ID, you can choose any key here that you recognize", + ExRefName = + "Blocking service internal ID, you can choose any key here that you recognize", ExRefWert = Guid.NewGuid().ToString(), - } + }, }, Sperrauftragsstatus = Auftragsstatus.ZUGESTIMMT, Mindestpreis = new Preis @@ -55,14 +56,14 @@ public void TestSperrauftragSerializationMaximal() Bezugswert = Mengeneinheit.ANZAHL, Einheit = Waehrungseinheit.EUR, Status = Preisstatus.VORLAEUFIG, - Wert = 10.00M + Wert = 10.00M, }, Hoechstpreis = new Preis { Bezugswert = Mengeneinheit.ANZAHL, Einheit = Waehrungseinheit.EUR, Status = Preisstatus.VORLAEUFIG, - Wert = 20.00M + Wert = 20.00M, }, }; sperrauftrag.IsValid().Should().BeTrue(); @@ -82,7 +83,7 @@ public void TestSperrauftragSerializationMinimal() Hausnummer = "8", Landescode = Landescode.DE, Postleitzahl = "04109", - Ort = "Leipzig" + Ort = "Leipzig", }, MarktlokationsId = "54321012345", IstVomGerichtsvollzieherAngeordnet = true, @@ -105,7 +106,7 @@ public void TestEntsperrauftragMaximal() Hausnummer = "8", Landescode = Landescode.DE, Postleitzahl = "04109", - Ort = "Leipzig" + Ort = "Leipzig", }, MarktlokationsId = "54321012345", Zaehlernummer = "1Yasdasdasd", @@ -116,11 +117,11 @@ public void TestEntsperrauftragMaximal() { ExRefName = "Blocking service internal ID", ExRefWert = Guid.NewGuid().ToString(), - } - } + }, + }, }; entsperrauftrag.IsValid().Should().BeTrue(); var entsperrauftragJson = JsonSerializer.Serialize(entsperrauftrag, _options); entsperrauftragJson.Should().NotBe(null); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestStringEnumConverter.cs b/BO4ETestProject/TestStringEnumConverter.cs index d24946de..7d3a1998 100644 --- a/BO4ETestProject/TestStringEnumConverter.cs +++ b/BO4ETestProject/TestStringEnumConverter.cs @@ -21,16 +21,20 @@ namespace TestBO4E; public enum LegacyGasQualitaet { /// High Caloric Gas - [EnumMember(Value = "H_GAS")] H_GAS = 1, + [EnumMember(Value = "H_GAS")] + H_GAS = 1, /// Low Caloric Gas - [EnumMember(Value = "L_GAS")] L_GAS = 2, + [EnumMember(Value = "L_GAS")] + L_GAS = 2, /// High Caloric Gas - [EnumMember(Value = "HGAS")] HGAS = 1, + [EnumMember(Value = "HGAS")] + HGAS = 1, /// Low Caloric Gas - [EnumMember(Value = "LGAS")] LGAS = 2, + [EnumMember(Value = "LGAS")] + LGAS = 2, } public class SomethingWithGasqualitaet @@ -38,15 +42,10 @@ public class SomethingWithGasqualitaet public LegacyGasQualitaet Gasqualitaet { get; set; } } - - [TestClass] public class TestStringEnumConverter { - private readonly IList einheiten = new List - { - Mengeneinheit.TAG - }; + private readonly IList einheiten = new List { Mengeneinheit.TAG }; [TestMethod] public void TestMengeneinheitNewtonsoft() @@ -60,7 +59,7 @@ public void TestMengeneinheit() { var options = new JsonSerializerOptions { - Converters = { new StringNullableEnumConverter() } + Converters = { new StringNullableEnumConverter() }, }; var jsonString = JsonSerializer.Serialize(einheiten, options); Assert.IsTrue(jsonString.Contains("TAG")); @@ -71,13 +70,15 @@ public void TestMengeneinheit() [DataRow(LegacyGasQualitaet.L_GAS)] [DataRow(LegacyGasQualitaet.HGAS)] [DataRow(LegacyGasQualitaet.H_GAS)] - [Ignore("This test/the newtonsoft.json code path just worked accidentally, as a commenter in https://github.com/dotnet/runtime/issues/107296 pointed out")] + [Ignore( + "This test/the newtonsoft.json code path just worked accidentally, as a commenter in https://github.com/dotnet/runtime/issues/107296 pointed out" + )] public void Test_Newtonsoft_With_Degenerate_Enum(LegacyGasQualitaet qualiaet) { - var jsonString = JsonConvert.SerializeObject(new SomethingWithGasqualitaet - { - Gasqualitaet = qualiaet - }, new StringEnumConverter()); + var jsonString = JsonConvert.SerializeObject( + new SomethingWithGasqualitaet { Gasqualitaet = qualiaet }, + new StringEnumConverter() + ); jsonString.Should().ContainAny("H_GAS", "L_GAS").And.NotContainAny("HGAS", "LGAS"); } @@ -86,17 +87,16 @@ public void Test_Newtonsoft_With_Degenerate_Enum(LegacyGasQualitaet qualiaet) [DataRow(LegacyGasQualitaet.L_GAS)] [DataRow(LegacyGasQualitaet.HGAS)] // as of 2024-09-03 both H-GAS test cases fail but both L-GAS test cases pass 🤯 [DataRow(LegacyGasQualitaet.H_GAS)] - [Ignore("this test fails but at least I understand it now: See https://github.com/dotnet/runtime/issues/107296")] + [Ignore( + "this test fails but at least I understand it now: See https://github.com/dotnet/runtime/issues/107296" + )] public void Test_System_Text_With_Degenerate_Enum(LegacyGasQualitaet qualiaet) { - var options = new JsonSerializerOptions - { - Converters = { new JsonStringEnumConverter() } - }; - var jsonString = JsonSerializer.Serialize(new SomethingWithGasqualitaet - { - Gasqualitaet = qualiaet - }, options); + var options = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } }; + var jsonString = JsonSerializer.Serialize( + new SomethingWithGasqualitaet { Gasqualitaet = qualiaet }, + options + ); jsonString.Should().ContainAny("H_GAS", "L_GAS").And.NotContainAny("HGAS", "LGAS"); } @@ -116,7 +116,10 @@ public class ClassWithNonNullableGasqualitaet [DataRow("LGAS", Gasqualitaet.L_GAS)] [DataRow("L_GAS", Gasqualitaet.L_GAS)] [DataRow(null, null)] - public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqualitaet(string? jsonValue, Gasqualitaet? expectedGasqualitaet) + public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqualitaet( + string? jsonValue, + Gasqualitaet? expectedGasqualitaet + ) { string jsonString; if (jsonValue != null) @@ -128,8 +131,14 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqual jsonString = "{\"Foo\": null}"; } - var settings = new JsonSerializerOptions { Converters = { new SystemTextGasqualitaetStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = { new SystemTextGasqualitaetStringEnumConverter() }, + }; + var actual = System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -142,7 +151,10 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqual [DataRow("H_GAS", Gasqualitaet.H_GAS)] [DataRow("LGAS", Gasqualitaet.L_GAS)] [DataRow("L_GAS", Gasqualitaet.L_GAS)] - public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet(string? jsonValue, Gasqualitaet expectedGasqualitaet) + public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet( + string? jsonValue, + Gasqualitaet expectedGasqualitaet + ) { string jsonString; if (jsonValue != null) @@ -153,8 +165,14 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gas { jsonString = "{\"Foo\": null}"; } - var settings = new JsonSerializerOptions { Converters = { new SystemTextGasqualitaetStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = { new SystemTextGasqualitaetStringEnumConverter() }, + }; + var actual = System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -168,7 +186,10 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gas [DataRow("LGAS", Gasqualitaet.L_GAS)] [DataRow("L_GAS", Gasqualitaet.L_GAS)] [DataRow(null, null)] - public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqualitaet(string? jsonValue, Gasqualitaet? expectedGasqualitaet) + public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Nullable_Gasqualitaet( + string? jsonValue, + Gasqualitaet? expectedGasqualitaet + ) { string jsonString; if (jsonValue != null) @@ -182,9 +203,16 @@ public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Nullable_Gasquali var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftGasqualitaetStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftGasqualitaetStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -197,7 +225,10 @@ public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Nullable_Gasquali [DataRow("H_GAS", Gasqualitaet.H_GAS)] [DataRow("LGAS", Gasqualitaet.L_GAS)] [DataRow("L_GAS", Gasqualitaet.L_GAS)] - public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet(string? jsonValue, Gasqualitaet expectedGasqualitaet) + public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet( + string? jsonValue, + Gasqualitaet expectedGasqualitaet + ) { string jsonString; if (jsonValue != null) @@ -211,9 +242,17 @@ public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasq var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftGasqualitaetStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftGasqualitaetStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = + Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -221,15 +260,23 @@ public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasq reSerializedJsonString.Should().Contain(expectedGasqualitaet.ToString()); } - [TestMethod] [DataRow(1, Gasqualitaet.H_GAS)] [DataRow(2, Gasqualitaet.L_GAS)] - public void Test_SystemText_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet_Integer(int jsonValue, Gasqualitaet expectedGasqualitaet) + public void Test_SystemText_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet_Integer( + int jsonValue, + Gasqualitaet expectedGasqualitaet + ) { string jsonString = "{\"Foo\": " + jsonValue + "}"; - var settings = new JsonSerializerOptions { Converters = { new SystemTextGasqualitaetStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = { new SystemTextGasqualitaetStringEnumConverter() }, + }; + var actual = System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -240,14 +287,25 @@ public void Test_SystemText_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasq [TestMethod] [DataRow(1, Gasqualitaet.H_GAS)] [DataRow(2, Gasqualitaet.L_GAS)] - public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet_Integer(int jsonValue, Gasqualitaet expectedGasqualitaet) + public void Test_Newtonsoft_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet_Integer( + int jsonValue, + Gasqualitaet expectedGasqualitaet + ) { string jsonString = "{\"Foo\": " + jsonValue + "}"; var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftGasqualitaetStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftGasqualitaetStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = + Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedGasqualitaet); @@ -269,7 +327,10 @@ public class ClassWithNonNullableVerwendungszweck [DataRow("MEHRMINDERMENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow("MEHRMINDERMBENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow(null, null)] - public void Test_System_Text_Verwendungszweck_Legacy_Converter_With_Nullable_Verwendungszweck(string? jsonValue, Verwendungszweck? expectedVerwendungszweck) + public void Test_System_Text_Verwendungszweck_Legacy_Converter_With_Nullable_Verwendungszweck( + string? jsonValue, + Verwendungszweck? expectedVerwendungszweck + ) { string jsonString; if (jsonValue != null) @@ -281,8 +342,14 @@ public void Test_System_Text_Verwendungszweck_Legacy_Converter_With_Nullable_Ver jsonString = "{\"Foo\": null}"; } - var settings = new JsonSerializerOptions { Converters = { new SystemTextVerwendungszweckStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = { new SystemTextVerwendungszweckStringEnumConverter() }, + }; + var actual = System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); @@ -293,7 +360,10 @@ public void Test_System_Text_Verwendungszweck_Legacy_Converter_With_Nullable_Ver [TestMethod] [DataRow("MEHRMINDERMENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow("MEHRMINDERMBENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] - public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet(string? jsonValue, Verwendungszweck expectedVerwendungszweck) + public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gasqualitaet( + string? jsonValue, + Verwendungszweck expectedVerwendungszweck + ) { string jsonString; if (jsonValue != null) @@ -304,8 +374,15 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gas { jsonString = "{\"Foo\": null}"; } - var settings = new JsonSerializerOptions { Converters = { new SystemTextVerwendungszweckStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = { new SystemTextVerwendungszweckStringEnumConverter() }, + }; + var actual = + System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); @@ -313,12 +390,14 @@ public void Test_System_Text_Gasqualitaet_Legacy_Converter_With_Non_Nullable_Gas reSerializedJsonString.Should().Contain(expectedVerwendungszweck.ToString()); } - [TestMethod] [DataRow("MEHRMINDERMENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow("MEHRMINDERMBENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow(null, null)] - public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Nullable_Verwendungszweck(string? jsonValue, Verwendungszweck? expectedVerwendungszweck) + public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Nullable_Verwendungszweck( + string? jsonValue, + Verwendungszweck? expectedVerwendungszweck + ) { string jsonString; if (jsonValue != null) @@ -332,9 +411,17 @@ public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Nullable_Verw var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftVerwendungszweckStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftVerwendungszweckStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = + Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); @@ -345,14 +432,25 @@ public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Nullable_Verw [TestMethod] [DataRow("MEHRMINDERMENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] [DataRow("MEHRMINDERMBENGENABRECHNUNG", Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] - public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck(string? jsonValue, Verwendungszweck expectedVerwendungszweck) + public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck( + string? jsonValue, + Verwendungszweck expectedVerwendungszweck + ) { string jsonString = "{\"Foo\": \"" + jsonValue + "\"}"; var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftVerwendungszweckStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftVerwendungszweckStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = + Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); @@ -361,12 +459,29 @@ public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Non_Nullable_ } [TestMethod] - [DataRow((int)Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] - public void Test_SystemText_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck_Integer(int jsonValue, Verwendungszweck expectedVerwendungszweck) + [DataRow( + (int)Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, + Verwendungszweck.MEHRMINDERMENGENABRECHNUNG + )] + public void Test_SystemText_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck_Integer( + int jsonValue, + Verwendungszweck expectedVerwendungszweck + ) { string jsonString = "{\"Foo\": " + jsonValue + "}"; - var settings = new JsonSerializerOptions { Converters = { new SystemTextVerwendungszweckStringEnumConverter(), new JsonStringEnumConverter() } }; - var actual = System.Text.Json.JsonSerializer.Deserialize(jsonString, settings); + var settings = new JsonSerializerOptions + { + Converters = + { + new SystemTextVerwendungszweckStringEnumConverter(), + new JsonStringEnumConverter(), + }, + }; + var actual = + System.Text.Json.JsonSerializer.Deserialize( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); @@ -375,20 +490,33 @@ public void Test_SystemText_Verwendungszweck_Legacy_Converter_With_Non_Nullable_ } [TestMethod] - [DataRow((int)Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, Verwendungszweck.MEHRMINDERMENGENABRECHNUNG)] - public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck_Integer(int jsonValue, Verwendungszweck expectedVerwendungszweck) + [DataRow( + (int)Verwendungszweck.MEHRMINDERMENGENABRECHNUNG, + Verwendungszweck.MEHRMINDERMENGENABRECHNUNG + )] + public void Test_Newtonsoft_Verwendungszweck_Legacy_Converter_With_Non_Nullable_Verwendungszweck_Integer( + int jsonValue, + Verwendungszweck expectedVerwendungszweck + ) { string jsonString = "{\"Foo\": " + jsonValue + "}"; var settings = new Newtonsoft.Json.JsonSerializerSettings() { - Converters = { new NewtonsoftVerwendungszweckStringEnumConverter(), new StringEnumConverter() } + Converters = + { + new NewtonsoftVerwendungszweckStringEnumConverter(), + new StringEnumConverter(), + }, }; - var actual = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString, settings); + var actual = + Newtonsoft.Json.JsonConvert.DeserializeObject( + jsonString, + settings + ); actual.Should().NotBeNull(); actual.Foo.Should().Be(expectedVerwendungszweck); var reSerializedJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(actual, settings); reSerializedJsonString.Should().Contain(expectedVerwendungszweck.ToString()); } - -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestUserProperties.cs b/BO4ETestProject/TestUserProperties.cs index fc96f0c2..b55c8440 100644 --- a/BO4ETestProject/TestUserProperties.cs +++ b/BO4ETestProject/TestUserProperties.cs @@ -36,7 +36,10 @@ public void TestDeserialization() var melo = JsonConvert.DeserializeObject(meloJson); Assert.IsTrue(melo.IsValid()); Assert.IsNotNull(melo.UserProperties); - Assert.AreEqual("some_value_not_covered_by_bo4e", melo.UserProperties["myCustomInfo"] as string); + Assert.AreEqual( + "some_value_not_covered_by_bo4e", + melo.UserProperties["myCustomInfo"] as string + ); Assert.AreEqual(123.456M, (decimal)(double)melo.UserProperties["myCustomValue"]); } @@ -44,15 +47,24 @@ public void TestDeserialization() public void TestConvertingUserPropertyToBoolean() { var options = LenientParsing.MOST_LENIENT.GetJsonSerializerOptions(); - var meloJson = @"{""messlokationsId"": ""DE0123456789012345678901234567890"", ""sparte"": ""STROM"", ""myCustomInfo"": ""some_value_not_covered_by_bo4e"", ""myCustomValue"": ""not a boolean""}"; + var meloJson = + @"{""messlokationsId"": ""DE0123456789012345678901234567890"", ""sparte"": ""STROM"", ""myCustomInfo"": ""some_value_not_covered_by_bo4e"", ""myCustomValue"": ""not a boolean""}"; var melo = JsonSerializer.Deserialize(meloJson, options); melo.Should().NotBeNull(); melo.IsValid().Should().BeTrue(); melo.UserProperties.Should().NotBeEmpty(); - melo.UserProperties.Should().ContainKey("myCustomValue").WhoseValue.ToString().Should().Be("not a boolean"); + melo.UserProperties.Should() + .ContainKey("myCustomValue") + .WhoseValue.ToString() + .Should() + .Be("not a boolean"); var flagHasBeenSet = melo.SetFlag("myCustomValue", true); - flagHasBeenSet.Should().BeTrue(because: "the non-boolean existing value (which is overwritten) should not crash the code"); + flagHasBeenSet + .Should() + .BeTrue( + because: "the non-boolean existing value (which is overwritten) should not crash the code" + ); melo.TryGetUserProperty("myCustomValue", out bool booleanValue).Should().BeTrue(); booleanValue.Should().BeTrue(); } @@ -66,7 +78,10 @@ public void TestDeserializationSystemTextJson() var melo = JsonSerializer.Deserialize(meloJson, options); Assert.IsTrue(melo.IsValid()); Assert.IsNotNull(melo.UserProperties); - Assert.AreEqual("some_value_not_covered_by_bo4e", melo.UserProperties["myCustomInfo"].ToString()); + Assert.AreEqual( + "some_value_not_covered_by_bo4e", + melo.UserProperties["myCustomInfo"].ToString() + ); Assert.AreEqual(123.456M, ((JsonElement)melo.UserProperties["myCustomValue"]).GetDecimal()); } @@ -83,13 +98,22 @@ private void _AssertUserProperties(Messlokation melo) Assert.IsFalse(melo.UserPropertyEquals("myCustomValue", "asd")); // the cast exception is catched inside. Assert.IsFalse(melo.UserPropertyEquals("some_key_that_was_not_found", "asd")); Assert.IsTrue( - melo.EvaluateUserProperty("myCustomInfo", up => !string.IsNullOrEmpty(up))); + melo.EvaluateUserProperty( + "myCustomInfo", + up => !string.IsNullOrEmpty(up) + ) + ); melo.UserProperties = null; Assert.IsFalse(melo.UserPropertyEquals("there are no user properties", "asd")); Assert.IsFalse(melo.TryGetUserProperty("there are no user properties", out string _)); - Assert.ThrowsException(() => - melo.EvaluateUserProperty("there are no user properties", _ => default)); + Assert.ThrowsException( + () => + melo.EvaluateUserProperty( + "there are no user properties", + _ => default + ) + ); Assert.IsFalse(melo.UserPropertyEquals("myNullProp", true)); } @@ -114,7 +138,7 @@ public void TestFlags() var melo = new Messlokation { MesslokationsId = "DE0123456789012345678901234567890", - Sparte = Sparte.STROM + Sparte = Sparte.STROM, }; Assert.IsNull(melo.UserProperties); Assert.IsFalse(melo.HasFlagSet("foo")); @@ -144,7 +168,7 @@ public void TestSetterGetter() var melo = new Messlokation { MesslokationsId = "DE0123456789012345678901234567890", - Sparte = Sparte.STROM + Sparte = Sparte.STROM, }; Assert.IsNull(melo.UserProperties); @@ -171,7 +195,7 @@ public void TestDeletion() var melo = new Messlokation { MesslokationsId = "DE0123456789012345678901234567890", - Sparte = Sparte.STROM + Sparte = Sparte.STROM, }; Assert.IsNull(melo.UserProperties); @@ -213,12 +237,14 @@ public void TestBusinessObjectHasAmbiguousUserProperties() Zaehlergroesse = Geraetemerkmal.GAS_G6, UserProperties = new Dictionary { - {"zaehlergroesse", "Foo"}, - {"BoTyp", "Dei Mudder"} - } + { "zaehlergroesse", "Foo" }, + { "BoTyp", "Dei Mudder" }, + }, }; zaehlerWithAmbiguousProperties.HasAmbiguousUserProperties().Should().BeTrue(); - zaehlerWithAmbiguousProperties.GetAmbiguousUserPropertiesKeys().Should() + zaehlerWithAmbiguousProperties + .GetAmbiguousUserPropertiesKeys() + .Should() .Contain("zaehlergroesse") .And.Contain("BoTyp") .And.HaveCount(2); @@ -226,7 +252,7 @@ public void TestBusinessObjectHasAmbiguousUserProperties() var zaehlerWithoutAmbiguousProperties = new Zaehler() { Zaehlergroesse = Geraetemerkmal.GAS_G6, - UserProperties = new Dictionary { { "foo", "bar" } } + UserProperties = new Dictionary { { "foo", "bar" } }, }; zaehlerWithoutAmbiguousProperties.HasAmbiguousUserProperties().Should().BeFalse(); zaehlerWithoutAmbiguousProperties.GetAmbiguousUserPropertiesKeys().Should().BeEmpty(); @@ -240,12 +266,14 @@ public void TestComHasAmbiguousUserProperties() Hausnummer = "17", UserProperties = new Dictionary { - {"Hausnummer", 423}, - {"Postleitzahl", "foobar"}, - } + { "Hausnummer", 423 }, + { "Postleitzahl", "foobar" }, + }, }; adresseWithAmbiguousProperties.HasAmbiguousUserProperties().Should().BeTrue(); - adresseWithAmbiguousProperties.GetAmbiguousUserPropertiesKeys().Should() + adresseWithAmbiguousProperties + .GetAmbiguousUserPropertiesKeys() + .Should() .Contain("Hausnummer") .And.Contain("Postleitzahl") .And.HaveCount(2); @@ -253,9 +281,9 @@ public void TestComHasAmbiguousUserProperties() var adresseWithoutAmbiguousProperties = new Adresse() { Hausnummer = "17", - UserProperties = new Dictionary { { "foo", "bar" } } + UserProperties = new Dictionary { { "foo", "bar" } }, }; adresseWithoutAmbiguousProperties.HasAmbiguousUserProperties().Should().BeFalse(); adresseWithoutAmbiguousProperties.GetAmbiguousUserPropertiesKeys().Should().BeEmpty(); } -} \ No newline at end of file +} diff --git a/BO4ETestProject/TestZeitfenster.cs b/BO4ETestProject/TestZeitfenster.cs index 18573508..58dbccac 100644 --- a/BO4ETestProject/TestZeitfenster.cs +++ b/BO4ETestProject/TestZeitfenster.cs @@ -1,7 +1,5 @@ using System; - using BO4E.COM; - using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestBO4E; diff --git a/BO4ETestProject/TestZeitraumDeserialization.cs b/BO4ETestProject/TestZeitraumDeserialization.cs index 00d3fe28..872bc463 100644 --- a/BO4ETestProject/TestZeitraumDeserialization.cs +++ b/BO4ETestProject/TestZeitraumDeserialization.cs @@ -13,7 +13,10 @@ namespace TestBO4E; [TestClass] public class TestZeitraumDeserialization { - private void _TestZeitraumDeserialization(Func serializer, Func deserializer) + private void _TestZeitraumDeserialization( + Func serializer, + Func deserializer + ) { var zeitraum = new Zeitraum { @@ -21,7 +24,9 @@ private void _TestZeitraumDeserialization(Func serializer, Fun Enddatum = new DateTimeOffset(2022, 1, 2, 0, 0, 0, TimeSpan.Zero), }; var jsonString = serializer(zeitraum); - var jsonDict = System.Text.Json.JsonSerializer.Deserialize>(jsonString); // we deserialize into an anonymous dict just to be decoupled from the json hacks, it is not important that we use system.text for that + var jsonDict = System.Text.Json.JsonSerializer.Deserialize>( + jsonString + ); // we deserialize into an anonymous dict just to be decoupled from the json hacks, it is not important that we use system.text for that jsonDict["startdatum"].Should().NotBeNull(); jsonDict["enddatum"].Should().NotBeNull(); jsonDict["startzeitpunkt"].Should().BeEquivalentTo(jsonDict["startdatum"]); @@ -33,14 +38,22 @@ private void _TestZeitraumDeserialization(Func serializer, Fun jsonString = System.Text.Json.JsonSerializer.Serialize(jsonDict); var deserializedZeitraum = deserializer(jsonString); - deserializedZeitraum.Should().BeEquivalentTo(zeitraum, opts => opts.Excluding(zr => zr.Dauer).Excluding(zr => zr.Einheit)); + deserializedZeitraum + .Should() + .BeEquivalentTo( + zeitraum, + opts => opts.Excluding(zr => zr.Dauer).Excluding(zr => zr.Einheit) + ); // excluding the two props because they are part of a not so glorious hack `FillNullValues` in the Zeitraum class which I don't want to touch here. } [TestMethod] public void TestZeitraumDeserializationNewtonsoft() { - _TestZeitraumDeserialization(zr => JsonConvert.SerializeObject(zr, new StringEnumConverter()), str => JsonConvert.DeserializeObject(str)); + _TestZeitraumDeserialization( + zr => JsonConvert.SerializeObject(zr, new StringEnumConverter()), + str => JsonConvert.DeserializeObject(str) + ); } [TestMethod] @@ -48,8 +61,11 @@ public void TestZeitraumDeserializationSystemText() { var jsonOptions = new JsonSerializerOptions() { - Converters = { new JsonStringEnumConverter() } + Converters = { new JsonStringEnumConverter() }, }; - _TestZeitraumDeserialization(zr => System.Text.Json.JsonSerializer.Serialize(zr, jsonOptions), str => System.Text.Json.JsonSerializer.Deserialize(str, jsonOptions)); + _TestZeitraumDeserialization( + zr => System.Text.Json.JsonSerializer.Serialize(zr, jsonOptions), + str => System.Text.Json.JsonSerializer.Deserialize(str, jsonOptions) + ); } -} \ No newline at end of file +} diff --git a/SchemaGenerator/Program.cs b/SchemaGenerator/Program.cs index 4ec94924..797405db 100644 --- a/SchemaGenerator/Program.cs +++ b/SchemaGenerator/Program.cs @@ -1,6 +1,6 @@ using System.Text; -using Newtonsoft.Json.Schema; using BO4E.BO; +using Newtonsoft.Json.Schema; using NJsonSchema; using NJsonSchema.Generation; using JsonSchema = NJsonSchema.JsonSchema; @@ -14,14 +14,20 @@ // Validate arguments if (args.Length < 3) { - Console.Error.WriteLine("Error: You must provide an offset, a JSON output directory, and an OpenAPI output directory."); - Console.Error.WriteLine("Usage: dotnet run -- "); + Console.Error.WriteLine( + "Error: You must provide an offset, a JSON output directory, and an OpenAPI output directory." + ); + Console.Error.WriteLine( + "Usage: dotnet run -- " + ); Environment.Exit(1); // Exit with a specific error code for missing arguments } if (!int.TryParse(args[0], out offset)) { - Console.Error.WriteLine($"Error: Invalid argument '{args[0]}'. Please provide a valid integer offset."); + Console.Error.WriteLine( + $"Error: Invalid argument '{args[0]}'. Please provide a valid integer offset." + ); Environment.Exit(2); // Exit with a specific error code for invalid offset } @@ -58,13 +64,15 @@ public class JsonSchemaGenerator public static void GenerateSchemas(int offset, string jsonOutputDirectory) { - var relevantBusinessObjectTypes = typeof(BusinessObject).Assembly - .GetTypes() + var relevantBusinessObjectTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => t.IsSubclassOf(typeof(BusinessObject))); if (relevantBusinessObjectTypes.Count() > LastDataRowOffset + MaxSchemasPerHour) { - throw new InvalidOperationException("Too many BusinessObject types. Increase the LastDataRowOffset or adjust the MaxSchemasPerHour."); + throw new InvalidOperationException( + "Too many BusinessObject types. Increase the LastDataRowOffset or adjust the MaxSchemasPerHour." + ); } try @@ -84,13 +92,15 @@ public static void GenerateSchemas(int offset, string jsonOutputDirectory) if (!File.Exists(path)) { - using (File.Create(path)) - { - } + using (File.Create(path)) { } } var utf8WithoutByteOrderMark = new UTF8Encoding(false); - File.WriteAllText(path, schema.ToString(SchemaVersion.Draft7), utf8WithoutByteOrderMark); + File.WriteAllText( + path, + schema.ToString(SchemaVersion.Draft7), + utf8WithoutByteOrderMark + ); } } catch (JSchemaException jse) @@ -102,8 +112,8 @@ public static void GenerateSchemas(int offset, string jsonOutputDirectory) public static void GenerateOpenApiSchemas(int offset, string openApiOutputDirectory) { - var relevantBusinessObjectTypes = typeof(BusinessObject).Assembly - .GetTypes() + var relevantBusinessObjectTypes = typeof(BusinessObject) + .Assembly.GetTypes() .Where(t => t.IsSubclassOf(typeof(BusinessObject))); try @@ -116,19 +126,17 @@ public static void GenerateOpenApiSchemas(int offset, string openApiOutputDirect foreach (var type in relevantBusinessObjectTypes.Skip(offset)) { - var schema = JsonSchema.FromType(type, new SystemTextJsonSchemaGeneratorSettings() - { - SchemaType = SchemaType.OpenApi3 - }); + var schema = JsonSchema.FromType( + type, + new SystemTextJsonSchemaGeneratorSettings() { SchemaType = SchemaType.OpenApi3 } + ); var path = Path.Combine(openApiOutputDirectory, $"{type.Name}.json"); Console.WriteLine($"Generating OpenAPI schema for {type.Name} at {path}."); if (!File.Exists(path)) { - using (File.Create(path)) - { - } + using (File.Create(path)) { } } var utf8WithoutByteOrderMark = new UTF8Encoding(false); diff --git a/TestBO4E.Extensions/ShowCaseTests/EnergiemengeShowCaseTests.cs b/TestBO4E.Extensions/ShowCaseTests/EnergiemengeShowCaseTests.cs index ec7acc0c..d720fe76 100644 --- a/TestBO4E.Extensions/ShowCaseTests/EnergiemengeShowCaseTests.cs +++ b/TestBO4E.Extensions/ShowCaseTests/EnergiemengeShowCaseTests.cs @@ -29,7 +29,7 @@ public void ShowCaseTest() Startdatum = new DateTime(2020, 3, 1, 0, 0, 0, DateTimeKind.Utc), Enddatum = new DateTime(2020, 3, 8, 0, 0, 0, DateTimeKind.Utc), Wert = 456.0M, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, }, new Verbrauch { @@ -37,25 +37,30 @@ public void ShowCaseTest() Startdatum = new DateTime(2020, 3, 25, 0, 0, 0, DateTimeKind.Utc), Enddatum = new DateTime(2020, 4, 1, 0, 0, 0, DateTimeKind.Utc), Wert = 123.0M, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG - } - } + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, + }, + }, }; Debug.WriteLine( - $"You got Verbrauch data for {decimal.Round(em.GetCoverage() * 100.0M)}% of the time in between {em.Energieverbrauch.Select(v => v.Startdatum).Min():yyyy-MM-dd} and {em.Energieverbrauch.Select(v => v.Enddatum).Max():yyyy-MM-dd}"); + $"You got Verbrauch data for {decimal.Round(em.GetCoverage() * 100.0M)}% of the time in between {em.Energieverbrauch.Select(v => v.Startdatum).Min():yyyy-MM-dd} and {em.Energieverbrauch.Select(v => v.Enddatum).Max():yyyy-MM-dd}" + ); // You got Verbrauch data for 45% of the time in between 2020-03-01 and 2020-04-01 var consumption = em.GetTotalConsumption(); Debug.WriteLine($"The total consumption is {consumption.Item1}{consumption.Item2}"); // The total consumption is 579,0KWH - var consumptionMarch7 = em.GetConsumption(new TimeRange( - new DateTimeOffset(2020, 3, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - new DateTimeOffset(2020, 3, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime)); + var consumptionMarch7 = em.GetConsumption( + new TimeRange( + new DateTimeOffset(2020, 3, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + new DateTimeOffset(2020, 3, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime + ) + ); Debug.WriteLine( - $"The total consumption on March 7 is {decimal.Round(consumptionMarch7.Item1)}{consumptionMarch7.Item2}"); + $"The total consumption on March 7 is {decimal.Round(consumptionMarch7.Item1)}{consumptionMarch7.Item2}" + ); // The total consumption on March 7 is 65KWH // ToDo: show other methods. } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/ShowCaseTests/VerbrauchShowCaseTests.cs b/TestBO4E.Extensions/ShowCaseTests/VerbrauchShowCaseTests.cs index e28018f2..c6499eee 100644 --- a/TestBO4E.Extensions/ShowCaseTests/VerbrauchShowCaseTests.cs +++ b/TestBO4E.Extensions/ShowCaseTests/VerbrauchShowCaseTests.cs @@ -19,7 +19,7 @@ public void ShowCaseTest() Enddatum = new DateTime(2020, 3, 8, 0, 0, 0, DateTimeKind.Utc), Wert = 0.456M, Einheit = Mengeneinheit.MW, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, }; verbrauchA.ConvertToUnit(Mengeneinheit.KW); @@ -42,13 +42,15 @@ public void ShowCaseTest() Enddatum = new DateTime(2020, 3, 14, 0, 0, 0, DateTimeKind.Utc), Wert = 0.1M, Einheit = Mengeneinheit.KW, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, }; foreach (var v in verbrauchA.Merge(verbrauchB)) - Debug.WriteLine($"{v.Startdatum:yyyy-MM-dd} to {v.Enddatum:yyyy-MM-dd}: {v.Wert}{v.Einheit}"); + Debug.WriteLine( + $"{v.Startdatum:yyyy-MM-dd} to {v.Enddatum:yyyy-MM-dd}: {v.Wert}{v.Einheit}" + ); // 2020-03-01 to 2020-03-07: 456,000KW // 2020-03-07 to 2020-03-08: 456,100KW // 2020-03-08 to 2020-03-14: 0,1KW } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestBenachrichtigungExtension.cs b/TestBO4E.Extensions/TestBenachrichtigungExtension.cs index 65addf81..fda1fcd7 100644 --- a/TestBO4E.Extensions/TestBenachrichtigungExtension.cs +++ b/TestBO4E.Extensions/TestBenachrichtigungExtension.cs @@ -20,9 +20,9 @@ public void TestHas() Bearbeiter = "dei mudder", Infos = new List { - new GenericStringStringInfo {KeyColumn = "ads", Value = "xyz"}, - new GenericStringStringInfo {KeyColumn = "null", Value = null} - } + new GenericStringStringInfo { KeyColumn = "ads", Value = "xyz" }, + new GenericStringStringInfo { KeyColumn = "null", Value = null }, + }, }; Assert.IsTrue(b.Has("ads", "xyz")); @@ -41,7 +41,8 @@ public void TestHas() public void TestMoveInfo2UP() { var b = JsonConvert.DeserializeObject( - "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"468985\",\"prioritaet\":2,\"bearbeitungsstatus\":0,\"kurztext\":\"Manuelles Überschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-04-01T14:27:23Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"\",\"notizen\":null,\"deadline\":null,\"aufgaben\":null,\"infos\":null,\"aufgaben\":[{\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"OVERWRITE\",\"ausgefuehrt\":\"true\"},{\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"DISPLAY\",\"ausgefuehrt\":\"true\"}],\"infos\":[{\"keyColumn\":\"MESSLOKATIONSID\",\"value\":\"DE000360478090000000\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_FROM\",\"value\":\"2019-02-25T23:00:00Z\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_TO\",\"value\":\"2019-03-19T22:44:59Z\",\"boolean_true_column\":false}],\"notizen\":[]}"); + "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"468985\",\"prioritaet\":2,\"bearbeitungsstatus\":0,\"kurztext\":\"Manuelles Überschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-04-01T14:27:23Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"\",\"notizen\":null,\"deadline\":null,\"aufgaben\":null,\"infos\":null,\"aufgaben\":[{\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"OVERWRITE\",\"ausgefuehrt\":\"true\"},{\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\",\"aufgabenId\":\"DISPLAY\",\"ausgefuehrt\":\"true\"}],\"infos\":[{\"keyColumn\":\"MESSLOKATIONSID\",\"value\":\"DE000360478090000000\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_FROM\",\"value\":\"2019-02-25T23:00:00Z\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_TO\",\"value\":\"2019-03-19T22:44:59Z\",\"boolean_true_column\":false}],\"notizen\":[]}" + ); Assert.IsTrue(b.Has("MESSLOKATIONSID")); Assert.IsTrue(b.UserProperties == null || b.UserProperties.Count == 0); b.MoveInfosToUserProperties(); @@ -54,7 +55,8 @@ public void TestMoveInfo2UP() public void TestHasWithMesslokationsId() { var b = JsonConvert.DeserializeObject( - "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"483052\",\"prioritaet\":2,\"bearbeitungsstatus\":2,\"kurztext\":\"Manuelles Überschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-05-22T12:14:32Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"SCHLEBDA\",\"notizen\":[],\"deadline\":null,\"aufgaben\":[{\"aufgabenId\":\"OVERWRITE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungszeitpunkt\":\"2019-05-22T12:18:50Z\",\"ausfuehrender\":\"SCHLEBDA\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"DISPLAY\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"REIMPORT\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"EXTERN_IGNORE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"}],\"infos\":[{\"keyColumn\":\"MESS\",\"value\":\"9905048000007\",\"boolean_true_column\":false},{\"keyColumn\":\"MESSLOKATIONSID\",\"value\":\"DE0003604780400000000000010000176\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_FROM\",\"value\":\"2019-04-16T22:00:00Z\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_TO\",\"value\":\"2019-04-17T21:59:59Z\",\"boolean_true_column\":false}],\"casenr\":\"483052\"}"); + "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"483052\",\"prioritaet\":2,\"bearbeitungsstatus\":2,\"kurztext\":\"Manuelles Überschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-05-22T12:14:32Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"SCHLEBDA\",\"notizen\":[],\"deadline\":null,\"aufgaben\":[{\"aufgabenId\":\"OVERWRITE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungszeitpunkt\":\"2019-05-22T12:18:50Z\",\"ausfuehrender\":\"SCHLEBDA\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"DISPLAY\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"REIMPORT\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"EXTERN_IGNORE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":false,\"ausfuehrungszeitpunkt\":null,\"ausfuehrender\":\"\",\"ccat\":\"ZE01\",\"casenr\":\"483052\",\"objtype\":\"ZISUPROFIL\"}],\"infos\":[{\"keyColumn\":\"MESS\",\"value\":\"9905048000007\",\"boolean_true_column\":false},{\"keyColumn\":\"MESSLOKATIONSID\",\"value\":\"DE0003604780400000000000010000176\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_FROM\",\"value\":\"2019-04-16T22:00:00Z\",\"boolean_true_column\":false},{\"keyColumn\":\"TIMESPAN_TO\",\"value\":\"2019-04-17T21:59:59Z\",\"boolean_true_column\":false}],\"casenr\":\"483052\"}" + ); Assert.IsTrue(b.Has("MESSLOKATIONSID")); // funktioniert wahrscheinlich Assert.IsTrue(b.Has("MESSLOKATIONSID", "DE0003604780400000000000010000176")); } @@ -63,10 +65,11 @@ public void TestHasWithMesslokationsId() public void TestDateTimePredicates() { var b = JsonConvert.DeserializeObject( - "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"469568\",\"prioritaet\":2,\"bearbeitungsstatus\":1,\"kurztext\":\"Manuelles \u00dcberschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-04-02T13:35:03Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"SCHLEBDA\",\"notizen\":[],\"deadline\":null,\"aufgaben\":[{\"aufgabenId\":\"OVERWRITE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungsdatum\":null,\"ausfuehrender\":null,\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"DISPLAY\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungsdatum\":null,\"ausfuehrender\":null,\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\"}],\"infos\":null,\"MESS\":\"9977768000005\",\"MESSLOKATIONSID\":\"DE0003604763800000000000010376811\",\"TIMESPAN_FROM\":\"2019-03-11T23:30:00Z\",\"TIMESPAN_TO\":\"2019-03-12T22:59:59Z\"}"); + "{\"versionStruktur\":1,\"boTyp\":\"BENACHRICHTIGUNG\",\"benachrichtigungsId\":\"469568\",\"prioritaet\":2,\"bearbeitungsstatus\":1,\"kurztext\":\"Manuelles \u00dcberschreiben von Profilwerten\",\"erstellungsZeitpunkt\":\"2019-04-02T13:35:03Z\",\"kategorie\":\"ZE01\",\"bearbeiter\":\"SCHLEBDA\",\"notizen\":[],\"deadline\":null,\"aufgaben\":[{\"aufgabenId\":\"OVERWRITE\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungsdatum\":null,\"ausfuehrender\":null,\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\"},{\"aufgabenId\":\"DISPLAY\",\"beschreibung\":null,\"deadline\":null,\"ausgefuehrt\":true,\"ausfuehrungsdatum\":null,\"ausfuehrender\":null,\"ccat\":\"ZE01\",\"objtype\":\"ZISUPROFIL\"}],\"infos\":null,\"MESS\":\"9977768000005\",\"MESSLOKATIONSID\":\"DE0003604763800000000000010376811\",\"TIMESPAN_FROM\":\"2019-03-11T23:30:00Z\",\"TIMESPAN_TO\":\"2019-03-12T22:59:59Z\"}" + ); Assert.IsTrue(b.UserProperties.TryGetValue("TIMESPAN_FROM", out var jtLower)); _ = (DateTime)jtLower; Assert.IsTrue(b.UserProperties.TryGetValue("TIMESPAN_TO", out var jtUpper)); _ = (DateTime)jtUpper; } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestCloningExtension.cs b/TestBO4E.Extensions/TestCloningExtension.cs index 30992aea..99200f2e 100644 --- a/TestBO4E.Extensions/TestCloningExtension.cs +++ b/TestBO4E.Extensions/TestCloningExtension.cs @@ -14,10 +14,7 @@ public class TestCloningExtension [TestMethod] public void TestCloning() { - var bo = new Messlokation - { - MesslokationsId = "DE345" - }; + var bo = new Messlokation { MesslokationsId = "DE345" }; var cloneBo = bo.DeepClone(); Assert.AreNotSame(bo, cloneBo); // Assert.AreEqual((Messlokation)bo, cloneBo); <--- keine ahnung warum das failed. vllt. auch mit json patch/diff arbeiten wie im hubnet projekt @@ -39,7 +36,7 @@ public void TestCloningEnergiemenge() Obiskennzahl = "dei vadder", Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, Startdatum = new DateTime(2018, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc), - Enddatum = new DateTime(2019, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc) + Enddatum = new DateTime(2019, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc), }, new Verbrauch { @@ -48,9 +45,9 @@ public void TestCloningEnergiemenge() Obiskennzahl = "dei mudder", Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, Startdatum = new DateTime(2019, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc), - Enddatum = new DateTime(2020, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc) - } - } + Enddatum = new DateTime(2020, 12, 31, 23, 0, 0, 0, DateTimeKind.Utc), + }, + }, }; var cloned = em.DeepClone(); Assert.AreEqual(em.Energieverbrauch.Count, cloned.Energieverbrauch.Count); @@ -60,6 +57,9 @@ public void TestCloningEnergiemenge() var cloned3 = ((BusinessObject)em).DeepClone(); Assert.IsTrue(cloned3 is Energiemenge); - Assert.AreEqual(em.Energieverbrauch.Count, (cloned3 as Energiemenge).Energieverbrauch.Count); + Assert.AreEqual( + em.Energieverbrauch.Count, + (cloned3 as Energiemenge).Energieverbrauch.Count + ); } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestEnergiemengeExtension.cs b/TestBO4E.Extensions/TestEnergiemengeExtension.cs index 30bfbdd5..4f65d7b4 100644 --- a/TestBO4E.Extensions/TestEnergiemengeExtension.cs +++ b/TestBO4E.Extensions/TestEnergiemengeExtension.cs @@ -10,17 +10,20 @@ namespace TestBO4E.Extensions; [TestClass] public class TestEnergiemengeExtension { - internal static readonly TimeRange GERMAN_MARCH_2018 = - new TimeRange(new DateTime(2018, 2, 28, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2018, 3, 31, 22, 0, 0, DateTimeKind.Utc)); + internal static readonly TimeRange GERMAN_MARCH_2018 = new TimeRange( + new DateTime(2018, 2, 28, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2018, 3, 31, 22, 0, 0, DateTimeKind.Utc) + ); - internal static readonly TimeRange GERMAN_APRIL_2018 = - new TimeRange(new DateTime(2018, 3, 31, 22, 0, 0, DateTimeKind.Utc), - new DateTime(2018, 4, 30, 22, 0, 0, DateTimeKind.Utc)); + internal static readonly TimeRange GERMAN_APRIL_2018 = new TimeRange( + new DateTime(2018, 3, 31, 22, 0, 0, DateTimeKind.Utc), + new DateTime(2018, 4, 30, 22, 0, 0, DateTimeKind.Utc) + ); - internal static readonly TimeRange march2425 = - new TimeRange(new DateTime(2018, 3, 23, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2018, 3, 25, 22, 0, 0, DateTimeKind.Utc)); + internal static readonly TimeRange march2425 = new TimeRange( + new DateTime(2018, 3, 23, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2018, 3, 25, 22, 0, 0, DateTimeKind.Utc) + ); [TestMethod] public void TestTestingRanges() @@ -30,14 +33,14 @@ public void TestTestingRanges() Assert.AreEqual(47, march2425.Duration.TotalHours); } - [TestMethod] public void TestDetangling() { var em = JsonConvert.DeserializeObject( - "{\"versionStruktur\":1,\"boTyp\":\"ENERGIEMENGE\",\"lokationsId\":\"DE0003604780400000000000012345678\",\"lokationstyp\":\"MeLo\",\"energieverbrauch\":[{\"startdatum\":\"2019-03-01T00:00:00Z\",\"enddatum\":\"2019-06-24T00:00:00Z\",\"wertermittlungsverfahren\":\"MESSUNG\",\"obiskennzahl\":\"1-0:1.8.0\",\"wert\":1,\"einheit\":\"KWH\",\"zaehlernummer\":\"10654212\"},{\"startdatum\":\"2019-03-01T00:00:00Z\",\"enddatum\":\"2019-06-24T00:00:00Z\",\"wertermittlungsverfahren\":\"MESSUNG\",\"obiskennzahl\":\"1-0:2.8.0\",\"wert\":1,\"einheit\":\"KWH\",\"zaehlernummer\":\"10654212\"}],\"anlagennummer\":\"50693510\",\"messlokationsId\":\"DE0003604780400000000000012345678\",\"marktlokationsId\":\"\",\"isMelo\":true,\"zaehlernummer\":\"10654212\"}"); + "{\"versionStruktur\":1,\"boTyp\":\"ENERGIEMENGE\",\"lokationsId\":\"DE0003604780400000000000012345678\",\"lokationstyp\":\"MeLo\",\"energieverbrauch\":[{\"startdatum\":\"2019-03-01T00:00:00Z\",\"enddatum\":\"2019-06-24T00:00:00Z\",\"wertermittlungsverfahren\":\"MESSUNG\",\"obiskennzahl\":\"1-0:1.8.0\",\"wert\":1,\"einheit\":\"KWH\",\"zaehlernummer\":\"10654212\"},{\"startdatum\":\"2019-03-01T00:00:00Z\",\"enddatum\":\"2019-06-24T00:00:00Z\",\"wertermittlungsverfahren\":\"MESSUNG\",\"obiskennzahl\":\"1-0:2.8.0\",\"wert\":1,\"einheit\":\"KWH\",\"zaehlernummer\":\"10654212\"}],\"anlagennummer\":\"50693510\",\"messlokationsId\":\"DE0003604780400000000000012345678\",\"marktlokationsId\":\"\",\"isMelo\":true,\"zaehlernummer\":\"10654212\"}" + ); em.Detangle(); Assert.AreEqual(2, em.Energieverbrauch.Count); // todo: add real test. this one is limited. } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestEnergiemengeExtensionCompleteness.cs b/TestBO4E.Extensions/TestEnergiemengeExtensionCompleteness.cs index a1042f2d..aa837205 100644 --- a/TestBO4E.Extensions/TestEnergiemengeExtensionCompleteness.cs +++ b/TestBO4E.Extensions/TestEnergiemengeExtensionCompleteness.cs @@ -1,21 +1,17 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; using BO4E.BO; using BO4E.COM; using BO4E.ENUM; using BO4E.Extensions.BusinessObjects.Energiemenge; using BO4E.meta; using BO4E.meta.LenientConverters; - using Itenso.TimePeriod; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - using JsonSerializer = System.Text.Json.JsonSerializer; namespace TestBO4E.Extensions; @@ -25,12 +21,13 @@ public class TestEnergiemengeExtensionCompleteness { internal static readonly TimeRange CHRISTMAS_2018 = new TimeRange( new DateTimeOffset(2018, 12, 23, 22, 0, 0, TimeSpan.Zero).UtcDateTime, - new DateTimeOffset(2018, 12, 31, 22, 0, 0, TimeSpan.Zero).UtcDateTime); + new DateTimeOffset(2018, 12, 31, 22, 0, 0, TimeSpan.Zero).UtcDateTime + ); internal static readonly TimeRange GERMAN_YEAR_2018 = new TimeRange( new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - new DateTimeOffset(2018, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime); - + new DateTimeOffset(2018, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + ); [TestMethod] public void TestFirstLastGap() @@ -47,7 +44,7 @@ public void TestFirstLastGap() Wert = 123.456M, Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 4, 0, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2019, 1, 4, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, new Verbrauch { @@ -55,18 +52,34 @@ public void TestFirstLastGap() Wert = 123.456M, Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, Startdatum = new DateTimeOffset(2019, 1, 4, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime - } - } + Enddatum = new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + }, + }, }; - var cr = em.GetCompletenessReport(new TimeRange(new DateTime(2018, 12, 29, 0, 0, 0, DateTimeKind.Utc), - new DateTime(2019, 1, 10, 0, 0, 0, DateTimeKind.Utc))); + var cr = em.GetCompletenessReport( + new TimeRange( + new DateTime(2018, 12, 29, 0, 0, 0, DateTimeKind.Utc), + new DateTime(2019, 1, 10, 0, 0, 0, DateTimeKind.Utc) + ) + ); Assert.AreEqual(2, cr.Gaps.Count); - Assert.AreEqual(new DateTimeOffset(2018, 12, 29, 0, 0, 0, TimeSpan.Zero), cr.Gaps.First().Startdatum); - Assert.AreEqual(new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), cr.Gaps.First().Enddatum); - Assert.AreEqual(new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero), cr.Gaps.Last().Startdatum); - Assert.AreEqual(new DateTimeOffset(2019, 1, 10, 0, 0, 0, TimeSpan.Zero), cr.Gaps.Last().Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 12, 29, 0, 0, 0, TimeSpan.Zero), + cr.Gaps.First().Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), + cr.Gaps.First().Enddatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero), + cr.Gaps.Last().Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 1, 10, 0, 0, 0, TimeSpan.Zero), + cr.Gaps.Last().Enddatum + ); } [TestMethod] @@ -76,7 +89,9 @@ public void TestNullableCoverage() { LokationsId = "DE123456789DieseEmhatkeineVerbräuche", LokationsTyp = Lokationstyp.MELO, - Energieverbrauch = new List() //empty list + Energieverbrauch = + new List() //empty list + , }; var cr1 = em1.GetCompletenessReport(); Assert.IsNotNull(cr1); @@ -87,10 +102,16 @@ public void TestNullableCoverage() { LokationsId = "54321012345DieseEmhatkeineVerbräuche", LokationsTyp = Lokationstyp.MELO, - Energieverbrauch = new List() //empty list + Energieverbrauch = + new List() //empty list + , }; - var cr2 = em2.GetCompletenessReport(CHRISTMAS_2018, Wertermittlungsverfahren.MESSUNG, "1-2-3-4", - Mengeneinheit.KUBIKMETER); + var cr2 = em2.GetCompletenessReport( + CHRISTMAS_2018, + Wertermittlungsverfahren.MESSUNG, + "1-2-3-4", + Mengeneinheit.KUBIKMETER + ); Assert.IsNotNull(cr2); Assert.IsNotNull(cr2.Coverage); // not null because no values but configuration given Assert.AreEqual(0.0M, cr2.Coverage); @@ -106,7 +127,9 @@ public void TestNullableCoverage() [TestMethod] public void TestDailyCompleteness() { - foreach (var boFile in Directory.GetFiles("Energiemenge/completeness/", "50hz_prognose*.json")) + foreach ( + var boFile in Directory.GetFiles("Energiemenge/completeness/", "50hz_prognose*.json") + ) { string jsonString; using (var r = new StreamReader(boFile)) @@ -130,7 +153,9 @@ public void TestMonthlySlices() [Obsolete] internal void TestMonthlySlices(bool testFirstOnly = true, bool useParallelExecution = false) { - foreach (var boFile in Directory.GetFiles("Energiemenge/completeness", "50hz_prognose*.json")) + foreach ( + var boFile in Directory.GetFiles("Energiemenge/completeness", "50hz_prognose*.json") + ) { string jsonString; using (var r = new StreamReader(boFile)) @@ -139,8 +164,7 @@ internal void TestMonthlySlices(bool testFirstOnly = true, bool useParallelExecu } var em = JsonConvert.DeserializeObject(jsonString); var result = em.GetMonthlyCompletenessReports(GERMAN_YEAR_2018, useParallelExecution); - Assert.AreEqual(12, - result.Count); // don't care about values of coverage, just the start/end and count of reports generated. + Assert.AreEqual(12, result.Count); // don't care about values of coverage, just the start/end and count of reports generated. if (testFirstOnly) { break; // one test is enough. the rest is covered by the individual completeness report tests @@ -155,20 +179,30 @@ public void TestParallization() for (var i = 0; i < 10; i++) { Energiemenge em; - using (var r = - new StreamReader(Directory.GetFiles("Energiemenge/completeness", "threeyears.json").First())) + using ( + var r = new StreamReader( + Directory.GetFiles("Energiemenge/completeness", "threeyears.json").First() + ) + ) { var jsonString = r.ReadToEnd(); em = JsonConvert.DeserializeObject(jsonString); } - - em.GetMonthlyCompletenessReports(new TimeRange(new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc))); + em.GetMonthlyCompletenessReports( + new TimeRange( + new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ) + ); em.GetMonthlyCompletenessReports( - new TimeRange(new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc)), true); + new TimeRange( + new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ), + true + ); //Assert.IsTrue(mpParallel.DurationMilliseconds < 3000, $"Parallel completeness report generation was too slow. Expected less than 3 seconds but was {mpParallel.DurationMilliseconds}ms: {mpParallel.RenderPlainText()}"); //Assert.IsTrue(mpParallel.DurationMilliseconds < (int)mpLinear.DurationMilliseconds * 1.25M, $"Parallel: {mpParallel.DurationMilliseconds}, Non-Parallel: {mpLinear.DurationMilliseconds}"); @@ -185,22 +219,31 @@ public async Task TestParallizationSystemTextJson() Energiemenge em; var r = Directory.GetFiles("Energiemenge/completeness", "threeyears.json").First(); await using var openStream = File.OpenRead(r); - em = await JsonSerializer.DeserializeAsync(openStream, - LenientParsing.MOST_LENIENT.GetJsonSerializerOptions()); - - - em.GetMonthlyCompletenessReports(new TimeRange(new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc))); + em = await JsonSerializer.DeserializeAsync( + openStream, + LenientParsing.MOST_LENIENT.GetJsonSerializerOptions() + ); + em.GetMonthlyCompletenessReports( + new TimeRange( + new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ) + ); em.GetMonthlyCompletenessReports( - new TimeRange(new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc)), true); + new TimeRange( + new DateTime(2016, 1, 31, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2016, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ), + true + ); //Assert.IsTrue(mpParallel.DurationMilliseconds < 3000, $"Parallel completeness report generation was too slow. Expected less than 3 seconds but was {mpParallel.DurationMilliseconds}ms: {mpParallel.RenderPlainText()}"); //Assert.IsTrue(mpParallel.DurationMilliseconds < (int)mpLinear.DurationMilliseconds * 1.25M, $"Parallel: {mpParallel.DurationMilliseconds}, Non-Parallel: {mpLinear.DurationMilliseconds}"); } } + //int a = 0; @@ -221,47 +264,71 @@ public void TestDailyParallization() dateTime = dateTime.AddMinutes(15); var endDateTime = dateTime.AddMinutes(15); - listvb.Add(new Verbrauch - { Startdatum = dateTime, Enddatum = endDateTime, Einheit = Mengeneinheit.JAHR, Wert = 12 }); + listvb.Add( + new Verbrauch + { + Startdatum = dateTime, + Enddatum = endDateTime, + Einheit = Mengeneinheit.JAHR, + Wert = 12, + } + ); dateTime = endDateTime; } em.Energieverbrauch = listvb; - - em.GetMonthlyCompletenessReports(new TimeRange(new DateTime(2015, 1, 1, 23, 00, 0, DateTimeKind.Utc), - new DateTime(2019, 12, 31, 23, 0, 0, DateTimeKind.Utc))); + em.GetMonthlyCompletenessReports( + new TimeRange( + new DateTime(2015, 1, 1, 23, 00, 0, DateTimeKind.Utc), + new DateTime(2019, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ) + ); //Assert.IsTrue(mpLinear.DurationMilliseconds < 4000, $"Linear completeness report generation was too slow. Expected less than 4 seconds but was {mpLinear.DurationMilliseconds}ms: {mpLinear.RenderPlainText()}"); em.GetDailyCompletenessReports( - new TimeRange(new DateTime(2015, 1, 01, 23, 0, 0, DateTimeKind.Utc), - new DateTime(2019, 12, 31, 23, 0, 0, DateTimeKind.Utc)), true); + new TimeRange( + new DateTime(2015, 1, 01, 23, 0, 0, DateTimeKind.Utc), + new DateTime(2019, 12, 31, 23, 0, 0, DateTimeKind.Utc) + ), + true + ); //Assert.IsTrue(mpParallel.DurationMilliseconds < 3000, $"Parallel completeness report generation was too slow. Expected less than 3 seconds but was {mpParallel.DurationMilliseconds}ms: {mpParallel.RenderPlainText()}"); //Assert.IsTrue(mpParallel.DurationMilliseconds < (int)mpLinear.DurationMilliseconds * 1.25M, $"Parallel: {mpParallel.DurationMilliseconds}, Non-Parallel: {mpLinear.DurationMilliseconds}"); } - [TestMethod] public void TestDailyCompletenessDST() { var localStart = TimeZoneInfo.ConvertTimeFromUtc( new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo); //, DateTimeKind.Unspecified); + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ); //, DateTimeKind.Unspecified); var localEnd = TimeZoneInfo.ConvertTimeFromUtc( new DateTimeOffset(2018, 3, 26, 22, 0, 0, TimeSpan.Zero).UtcDateTime, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo); //, DateTimeKind.Unspecified); + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ); //, DateTimeKind.Unspecified); if (TimeZoneInfo.Local != CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) { - localStart = - DateTime.SpecifyKind( - TimeZoneInfo.ConvertTime(localStart, TimeZoneInfo.Local, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), DateTimeKind.Unspecified); + localStart = DateTime.SpecifyKind( + TimeZoneInfo.ConvertTime( + localStart, + TimeZoneInfo.Local, + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + DateTimeKind.Unspecified + ); localEnd = DateTime.SpecifyKind( - TimeZoneInfo.ConvertTime(localEnd, TimeZoneInfo.Local, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), DateTimeKind.Unspecified); + TimeZoneInfo.ConvertTime( + localEnd, + TimeZoneInfo.Local, + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + DateTimeKind.Unspecified + ); } else { @@ -271,65 +338,86 @@ public void TestDailyCompletenessDST() var utcStart = new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero); var utcEnd = new DateTimeOffset(2018, 3, 26, 22, 0, 0, TimeSpan.Zero); - if (TimeZoneInfo.Local.SupportsDaylightSavingTime && - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.Equals(TimeZoneInfo.Local)) + if ( + TimeZoneInfo.Local.SupportsDaylightSavingTime + && CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.Equals( + TimeZoneInfo.Local + ) + ) { Assert.IsFalse( - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.IsDaylightSavingTime(localStart)); + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.IsDaylightSavingTime( + localStart + ) + ); Assert.IsTrue( - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.IsDaylightSavingTime(localEnd)); + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo.IsDaylightSavingTime( + localEnd + ) + ); } var verbrauchSlices = new List { - new TimeRange - { - Start = utcStart.UtcDateTime, - End = utcStart.AddHours(1).UtcDateTime - } + new TimeRange { Start = utcStart.UtcDateTime, End = utcStart.AddHours(1).UtcDateTime }, }; while (verbrauchSlices.Last().End < utcEnd) - verbrauchSlices.Add(new TimeRange - { - Start = verbrauchSlices.Last().Start.AddHours(1), - End = verbrauchSlices.Last().End.AddHours(1) - }); + verbrauchSlices.Add( + new TimeRange + { + Start = verbrauchSlices.Last().Start.AddHours(1), + End = verbrauchSlices.Last().End.AddHours(1), + } + ); Assert.AreEqual(2 * 24 - 1, verbrauchSlices.Count); var em = new Energiemenge { LokationsId = "MeinUnitTest123", LokationsTyp = Lokationstyp.MELO, - Energieverbrauch = verbrauchSlices.Select(vs => new Verbrauch - { - Startdatum = vs.Start, - Enddatum = vs.End, - Einheit = Mengeneinheit.KWH, - Wert = (decimal)123.456, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG - } - ).ToList() + Energieverbrauch = verbrauchSlices + .Select(vs => new Verbrauch + { + Startdatum = vs.Start, + Enddatum = vs.End, + Einheit = Mengeneinheit.KWH, + Wert = (decimal)123.456, + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, + }) + .ToList(), }; - var result = em.GetDailyCompletenessReports(new TimeRange(utcStart.UtcDateTime, utcEnd.UtcDateTime)); + var result = em.GetDailyCompletenessReports( + new TimeRange(utcStart.UtcDateTime, utcEnd.UtcDateTime) + ); Assert.AreEqual(2, result.Count); - Assert.AreEqual(new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero), - result.First().Value.ReferenceTimeFrame.Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 3, 25, 22, 0, 0, TimeSpan.Zero), - result.First().Value.ReferenceTimeFrame.Enddatum); - Assert.AreEqual(new DateTimeOffset(2018, 3, 25, 22, 0, 0, TimeSpan.Zero), - result.Last().Value.ReferenceTimeFrame.Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 3, 26, 22, 0, 0, TimeSpan.Zero), - result.Last().Value.ReferenceTimeFrame.Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero), + result.First().Value.ReferenceTimeFrame.Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 3, 25, 22, 0, 0, TimeSpan.Zero), + result.First().Value.ReferenceTimeFrame.Enddatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 3, 25, 22, 0, 0, TimeSpan.Zero), + result.Last().Value.ReferenceTimeFrame.Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 3, 26, 22, 0, 0, TimeSpan.Zero), + result.Last().Value.ReferenceTimeFrame.Enddatum + ); } [TestMethod] public void TestAddDaysDSTSpring() { var utcDt = new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero).UtcDateTime; - var localDt = - DateTime.SpecifyKind( - TimeZoneInfo.ConvertTimeFromUtc( - new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), DateTimeKind.Unspecified); + var localDt = DateTime.SpecifyKind( + TimeZoneInfo.ConvertTimeFromUtc( + new DateTimeOffset(2018, 3, 24, 23, 0, 0, TimeSpan.Zero).UtcDateTime, + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + DateTimeKind.Unspecified + ); var resultUtc = utcDt.AddDaysDST(1); var resultLocal = localDt.AddDaysDST(1); @@ -338,24 +426,35 @@ public void TestAddDaysDSTSpring() Assert.AreEqual(DateTimeKind.Unspecified, resultLocal.Kind); Assert.AreEqual(23, new TimeRange(utcDt, resultUtc).Duration.TotalHours); - Assert.AreEqual(23, new TimeRange - { - Start = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), - End = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) - }.Duration.TotalHours); + Assert.AreEqual( + 23, + new TimeRange + { + Start = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + End = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + } + .Duration + .TotalHours + ); } [TestMethod] public void TestAddDaysDSTAutumn() { var utcDt = new DateTimeOffset(2018, 10, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime; - var localDt = - DateTime.SpecifyKind( - TimeZoneInfo.ConvertTimeFromUtc( - new DateTimeOffset(2018, 10, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), DateTimeKind.Unspecified); + var localDt = DateTime.SpecifyKind( + TimeZoneInfo.ConvertTimeFromUtc( + new DateTimeOffset(2018, 10, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime, + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + DateTimeKind.Unspecified + ); var resultUtc = utcDt.AddDaysDST(1); var resultLocal = localDt.AddDaysDST(1); @@ -364,24 +463,35 @@ public void TestAddDaysDSTAutumn() Assert.AreEqual(DateTimeKind.Unspecified, resultLocal.Kind); Assert.AreEqual(25, new TimeRange(utcDt, resultUtc).Duration.TotalHours); - Assert.AreEqual(25, new TimeRange - { - Start = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), - End = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) - }.Duration.TotalHours); + Assert.AreEqual( + 25, + new TimeRange + { + Start = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + End = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + } + .Duration + .TotalHours + ); } [TestMethod] public void TestAddDaysDSTSummer() // could be winter as well ;) { var utcDt = new DateTimeOffset(2018, 7, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime; - var localDt = - DateTime.SpecifyKind( - TimeZoneInfo.ConvertTimeFromUtc( - new DateTimeOffset(2018, 7, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime, - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), DateTimeKind.Unspecified); + var localDt = DateTime.SpecifyKind( + TimeZoneInfo.ConvertTimeFromUtc( + new DateTimeOffset(2018, 7, 27, 22, 0, 0, TimeSpan.Zero).UtcDateTime, + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + DateTimeKind.Unspecified + ); var resultUtc = utcDt.AddDaysDST(1); var resultLocal = localDt.AddDaysDST(1); @@ -390,12 +500,21 @@ public void TestAddDaysDSTAutumn() Assert.AreEqual(DateTimeKind.Unspecified, resultLocal.Kind); Assert.AreEqual(24, new TimeRange(utcDt, resultUtc).Duration.TotalHours); - Assert.AreEqual(24, new TimeRange - { - Start = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo), - End = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), - CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo) - }.Duration.TotalHours); + Assert.AreEqual( + 24, + new TimeRange + { + Start = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(localDt, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + End = TimeZoneInfo.ConvertTimeToUtc( + DateTime.SpecifyKind(resultLocal, DateTimeKind.Unspecified), + CentralEuropeStandardTime.CentralEuropeStandardTimezoneInfo + ), + } + .Duration + .TotalHours + ); } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestEnergiemengeExtensionPlausibility.cs b/TestBO4E.Extensions/TestEnergiemengeExtensionPlausibility.cs index c427261e..f2a0226b 100644 --- a/TestBO4E.Extensions/TestEnergiemengeExtensionPlausibility.cs +++ b/TestBO4E.Extensions/TestEnergiemengeExtensionPlausibility.cs @@ -16,7 +16,9 @@ public class TestEnergiemengeExtensionPlausibility [TestMethod] public void TestPlausibilityReportGenerationSomeCustomer() { - foreach (var boFile in Directory.GetFiles("Energiemenge/plausibility", "somecustomer*.json")) + foreach ( + var boFile in Directory.GetFiles("Energiemenge/plausibility", "somecustomer*.json") + ) { JObject json; using (var r = new StreamReader(boFile)) @@ -31,12 +33,16 @@ public void TestPlausibilityReportGenerationSomeCustomer() throw new ArgumentException($"Test file {boFile} has no key '{key}'."); } - var emReference = JsonConvert.DeserializeObject(json["reference"].ToString()); + var emReference = JsonConvert.DeserializeObject( + json["reference"].ToString() + ); var emOther = JsonConvert.DeserializeObject(json["other"].ToString()); var prActual = emReference.GetPlausibilityReport(emOther); - var prExpected = JsonConvert.DeserializeObject(json["expectedResult"].ToString()); + var prExpected = JsonConvert.DeserializeObject( + json["expectedResult"].ToString() + ); //Assert.AreEqual(prExpected, prActual); } } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestMengeneinheitExtension.cs b/TestBO4E.Extensions/TestMengeneinheitExtension.cs index 2216ab4e..1d347c3d 100644 --- a/TestBO4E.Extensions/TestMengeneinheitExtension.cs +++ b/TestBO4E.Extensions/TestMengeneinheitExtension.cs @@ -38,11 +38,13 @@ public void TestConversionFactor() Assert.AreEqual(0.001M, Mengeneinheit.KW.GetConversionFactor(Mengeneinheit.MW)); foreach (Mengeneinheit me1 in Enum.GetValues(typeof(Mengeneinheit))) - foreach (Mengeneinheit me2 in Enum.GetValues(typeof(Mengeneinheit))) - if (!me1.IsConvertibleTo(me2)) - { - Assert.ThrowsException(() => me1.GetConversionFactor(me2), - $"Conversion {me1}-->{me2} should throw an exception!"); - } + foreach (Mengeneinheit me2 in Enum.GetValues(typeof(Mengeneinheit))) + if (!me1.IsConvertibleTo(me2)) + { + Assert.ThrowsException( + () => me1.GetConversionFactor(me2), + $"Conversion {me1}-->{me2} should throw an exception!" + ); + } } -} \ No newline at end of file +} diff --git a/TestBO4E.Extensions/TestVerbrauchExtension.cs b/TestBO4E.Extensions/TestVerbrauchExtension.cs index 619b4e2e..502a89ea 100644 --- a/TestBO4E.Extensions/TestVerbrauchExtension.cs +++ b/TestBO4E.Extensions/TestVerbrauchExtension.cs @@ -20,7 +20,7 @@ public class TestVerbrauchExtension Einheit = Mengeneinheit.KWH, Wert = 31 + 2 * 28, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; private static readonly Verbrauch dtV2 = new Verbrauch @@ -30,7 +30,7 @@ public class TestVerbrauchExtension Einheit = Mengeneinheit.KWH, Wert = 31, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; private static readonly Verbrauch dtV3 = new Verbrauch @@ -40,7 +40,7 @@ public class TestVerbrauchExtension Einheit = Mengeneinheit.KWH, Wert = 31 + 2 * 28 + 3 * 31, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero), }; [TestMethod] @@ -53,7 +53,7 @@ public void TestMergeNoOverlap() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v2 = new Verbrauch { @@ -62,7 +62,7 @@ public void TestMergeNoOverlap() Einheit = Mengeneinheit.KWH, Wert = 3, Startdatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero), }; var result = v1.Merge(v2); Assert.AreEqual(2, result.Count); @@ -80,7 +80,7 @@ public void TestMergeAdjacentExtensive() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v2 = new Verbrauch { @@ -89,7 +89,7 @@ public void TestMergeAdjacentExtensive() Einheit = Mengeneinheit.KWH, Wert = 3, Startdatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; var result = v1.Merge(v2); Assert.AreEqual(1, result.Count); @@ -108,7 +108,7 @@ public void TestMergeAdjacentIntensive() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v2 = new Verbrauch { @@ -117,7 +117,7 @@ public void TestMergeAdjacentIntensive() Einheit = Mengeneinheit.KW, Wert = 3, Startdatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; var result12 = v1.Merge(v2); Assert.AreEqual(2, result12.Count); @@ -131,7 +131,7 @@ public void TestMergeAdjacentIntensive() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v4 = new Verbrauch { @@ -140,11 +140,10 @@ public void TestMergeAdjacentIntensive() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; } - [TestMethod] public void TestMergeOverlappingExtensive() { @@ -155,7 +154,7 @@ public void TestMergeOverlappingExtensive() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v2 = new Verbrauch { @@ -164,7 +163,7 @@ public void TestMergeOverlappingExtensive() Einheit = Mengeneinheit.KWH, Wert = 3, Startdatum = new DateTimeOffset(2018, 1, 15, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; var result = v1.Merge(v2); Assert.AreEqual(1, result.Count); @@ -173,7 +172,6 @@ public void TestMergeOverlappingExtensive() Assert.AreEqual(8, result.First().Wert); } - [TestMethod] public void TestMergeOverlappingIntensive() { @@ -184,7 +182,7 @@ public void TestMergeOverlappingIntensive() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), }; var v2 = new Verbrauch { @@ -193,7 +191,7 @@ public void TestMergeOverlappingIntensive() Einheit = Mengeneinheit.KW, Wert = 3, Startdatum = new DateTimeOffset(2018, 1, 15, 23, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero) + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), }; var rawResult = v1.Merge(v2); var result = new List(rawResult); @@ -218,7 +216,7 @@ public void TestMergeRedundantIntensiveSameTime() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var v2 = new Verbrauch { @@ -227,7 +225,7 @@ public void TestMergeRedundantIntensiveSameTime() Einheit = Mengeneinheit.KW, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var rawResult = v1.MergeRedundant(v2, true); var result = new List(rawResult); @@ -247,7 +245,7 @@ public void TestMergeRedundantExtensiveSameTime() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var v2 = new Verbrauch { @@ -256,7 +254,7 @@ public void TestMergeRedundantExtensiveSameTime() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var rawResult = v1.MergeRedundant(v2, true); var result = new List(rawResult); @@ -264,7 +262,6 @@ public void TestMergeRedundantExtensiveSameTime() Assert.AreEqual(5, result.First().Wert); } - [TestMethod] public void TestMergeRedundantExtensiveLeftJustifiedOverlap() { @@ -275,7 +272,7 @@ public void TestMergeRedundantExtensiveLeftJustifiedOverlap() Einheit = Mengeneinheit.KWH, Wert = 5, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var v2 = new Verbrauch { @@ -284,7 +281,7 @@ public void TestMergeRedundantExtensiveLeftJustifiedOverlap() Einheit = Mengeneinheit.KWH, Wert = 3, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; var rawResult = v1.MergeRedundant(v2, true); @@ -293,29 +290,43 @@ public void TestMergeRedundantExtensiveLeftJustifiedOverlap() Assert.AreEqual(1, result.Count); Assert.AreEqual(2, result.First().Wert); - Assert.AreEqual(new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), result.First().Startdatum); + Assert.AreEqual( + new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), + result.First().Startdatum + ); //Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), result.First().enddatum); //Assert.AreEqual(5, result.Last().wert); //Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), result.Last().startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), result.Last().Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), + result.Last().Enddatum + ); } [TestMethod] public void TestMergeRedundantRightJustifiedOverlap() { var v1 = JsonConvert.DeserializeObject( - "{\"startdatum\":\"2018-12-25T16:22:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":1539,\"einheit\":2,\"zaehlernummer\":\"10000548\"}"); + "{\"startdatum\":\"2018-12-25T16:22:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":1539,\"einheit\":2,\"zaehlernummer\":\"10000548\"}" + ); var v2 = JsonConvert.DeserializeObject( - "{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":911,\"einheit\":2,\"zaehlernummer\":\"10000548\"}"); + "{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":911,\"einheit\":2,\"zaehlernummer\":\"10000548\"}" + ); var rawResult = v1.MergeRedundant(v2, true); var result = new List(rawResult); result.Sort(new VerbrauchDateTimeComparer()); Assert.AreEqual(1, result.Count); Assert.AreEqual(2450.0M, result.First().Wert); - Assert.AreEqual(new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), result.First().Startdatum); - Assert.AreEqual(new DateTimeOffset(2019, 12, 25, 08, 20, 0, TimeSpan.Zero), result.First().Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), + result.First().Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 12, 25, 08, 20, 0, TimeSpan.Zero), + result.First().Enddatum + ); } [TestMethod] @@ -324,11 +335,23 @@ public void TestDetangleTwofold() var result = Detangle(new List { dtV1, dtV2 }); result.Sort(new VerbrauchDateTimeComparer()); Assert.AreEqual(2, result.Count); - Assert.AreEqual(new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), result.First().Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), result.First().Enddatum); + Assert.AreEqual( + new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero), + result.First().Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), + result.First().Enddatum + ); Assert.AreEqual(31, result.First().Wert); - Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), result.Last().Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), result.Last().Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 1, 31, 23, 0, 0, TimeSpan.Zero), + result.Last().Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 2, 28, 23, 0, 0, TimeSpan.Zero), + result.Last().Enddatum + ); Assert.AreEqual(2 * 28, result.Last().Wert); } @@ -338,14 +361,32 @@ public void TestDetangleThreefold() var result = Detangle(new List { dtV1, dtV2, dtV3 }); result.Sort(new VerbrauchDateTimeComparer()); Assert.AreEqual(3, result.Count); - Assert.AreEqual(new DateTimeOffset(2017, 12, 31, 23, 0, 0, 0, TimeSpan.Zero), result[0].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, 0, TimeSpan.Zero), result[0].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2017, 12, 31, 23, 0, 0, 0, TimeSpan.Zero), + result[0].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 1, 31, 23, 0, 0, 0, TimeSpan.Zero), + result[0].Enddatum + ); Assert.AreEqual(31, result[0].Wert); - Assert.AreEqual(new DateTimeOffset(2018, 1, 31, 23, 0, 0, 0, TimeSpan.Zero), result[1].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 2, 28, 23, 0, 0, 0, TimeSpan.Zero), result[1].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 1, 31, 23, 0, 0, 0, TimeSpan.Zero), + result[1].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 2, 28, 23, 0, 0, 0, TimeSpan.Zero), + result[1].Enddatum + ); Assert.AreEqual(2 * 28, result[1].Wert); - Assert.AreEqual(new DateTimeOffset(2018, 2, 28, 23, 0, 0, 0, TimeSpan.Zero), result[2].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 3, 31, 23, 0, 0, 0, TimeSpan.Zero), result[2].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 2, 28, 23, 0, 0, 0, TimeSpan.Zero), + result[2].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 3, 31, 23, 0, 0, 0, TimeSpan.Zero), + result[2].Enddatum + ); Assert.AreEqual(3 * 31, result[2].Wert); } @@ -353,36 +394,74 @@ public void TestDetangleThreefold() public void TestHfSapDataDetangle() { var testList = JsonConvert.DeserializeObject>( - "[{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2018-09-01T00:00:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":50,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":961,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":2500,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":911,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":2450,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-12-25T16:22:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":1539,\"einheit\":2,\"zaehlernummer\":\"10000548\"}]"); - Assert.AreEqual(3, testList.Count(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.MESSUNG)); - Assert.AreEqual(3, testList.Count(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.PROGNOSE)); + "[{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2018-09-01T00:00:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":50,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":961,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2000-01-01T00:00:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":2500,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2018-12-25T16:22:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":911,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-09-01T00:00:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":1,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":2450,\"einheit\":2,\"zaehlernummer\":\"10000548\"},{\"startdatum\":\"2018-12-25T16:22:00Z\",\"enddatum\":\"2019-12-25T08:20:00Z\",\"wertermittlungsverfahren\":0,\"obiskennzahl\":\"1-1:1.8.0\",\"wert\":1539,\"einheit\":2,\"zaehlernummer\":\"10000548\"}]" + ); + Assert.AreEqual( + 3, + testList.Count(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.MESSUNG) + ); + Assert.AreEqual( + 3, + testList.Count(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.PROGNOSE) + ); var result = Detangle(testList); result.Sort(new VerbrauchDateTimeComparer()); //Assert.AreEqual(5, result.Count); - var subResultMessung = result.Where(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.MESSUNG) + var subResultMessung = result + .Where(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.MESSUNG) .ToList(); Assert.AreEqual(2, subResultMessung.Count); - Assert.AreEqual(new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), subResultMessung[0].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), subResultMessung[0].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), + subResultMessung[0].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), + subResultMessung[0].Enddatum + ); Assert.AreEqual(50, subResultMessung[0].Wert); - Assert.AreEqual(new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), subResultMessung[1].Startdatum); - Assert.AreEqual(new DateTimeOffset(2019, 12, 25, 8, 20, 0, TimeSpan.Zero), subResultMessung[1].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), + subResultMessung[1].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 12, 25, 8, 20, 0, TimeSpan.Zero), + subResultMessung[1].Enddatum + ); Assert.AreEqual(2450, subResultMessung[1].Wert); - var subResultPrognose = result.Where(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.PROGNOSE) + var subResultPrognose = result + .Where(v => v.Wertermittlungsverfahren == Wertermittlungsverfahren.PROGNOSE) .ToList(); Assert.AreEqual(3, subResultPrognose.Count); - Assert.AreEqual(new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), subResultPrognose[0].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), subResultPrognose[0].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), + subResultPrognose[0].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), + subResultPrognose[0].Enddatum + ); Assert.AreEqual(50, subResultPrognose[0].Wert); - Assert.AreEqual(new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), subResultPrognose[1].Startdatum); - Assert.AreEqual(new DateTimeOffset(2018, 12, 25, 16, 22, 0, TimeSpan.Zero), subResultPrognose[1].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 9, 1, 0, 0, 0, TimeSpan.Zero), + subResultPrognose[1].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2018, 12, 25, 16, 22, 0, TimeSpan.Zero), + subResultPrognose[1].Enddatum + ); Assert.AreEqual(911, subResultPrognose[1].Wert); - Assert.AreEqual(new DateTimeOffset(2018, 12, 25, 16, 22, 0, TimeSpan.Zero), - subResultPrognose[2].Startdatum); - Assert.AreEqual(new DateTimeOffset(2019, 12, 25, 8, 20, 0, TimeSpan.Zero), subResultPrognose[2].Enddatum); + Assert.AreEqual( + new DateTimeOffset(2018, 12, 25, 16, 22, 0, TimeSpan.Zero), + subResultPrognose[2].Startdatum + ); + Assert.AreEqual( + new DateTimeOffset(2019, 12, 25, 8, 20, 0, TimeSpan.Zero), + subResultPrognose[2].Enddatum + ); Assert.AreEqual(1539, subResultPrognose[2].Wert); } @@ -396,12 +475,14 @@ public void TestUnitConversion() Einheit = Mengeneinheit.MW, Wert = 17, Startdatum = new DateTimeOffset(2017, 12, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2018, 3, 31, 23, 0, 0, TimeSpan.Zero).UtcDateTime, }; v1.ConvertToUnit(Mengeneinheit.KW); Assert.AreEqual(Mengeneinheit.KW, v1.Einheit); Assert.AreEqual(17000.0M, v1.Wert); - Assert.ThrowsException(() => v1.ConvertToUnit(Mengeneinheit.KWH)); + Assert.ThrowsException( + () => v1.ConvertToUnit(Mengeneinheit.KWH) + ); } -} \ No newline at end of file +} diff --git a/TestBO4E.Reporting/ShowCaseTests/CompletenessReportShowCaseTests.cs b/TestBO4E.Reporting/ShowCaseTests/CompletenessReportShowCaseTests.cs index 978d170c..eecef38a 100644 --- a/TestBO4E.Reporting/ShowCaseTests/CompletenessReportShowCaseTests.cs +++ b/TestBO4E.Reporting/ShowCaseTests/CompletenessReportShowCaseTests.cs @@ -28,25 +28,36 @@ public void ShowCaseTest() Startdatum = new DateTimeOffset(2020, 3, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, Enddatum = new DateTimeOffset(2020, 3, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime, Wert = 456.0M, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, }, new Verbrauch { Einheit = Mengeneinheit.KWH, - Startdatum = new DateTimeOffset(2020, 3, 25, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + Startdatum = new DateTimeOffset( + 2020, + 3, + 25, + 0, + 0, + 0, + TimeSpan.Zero + ).UtcDateTime, Enddatum = new DateTimeOffset(2020, 4, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, Wert = 123.0M, - Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG - } - } + Wertermittlungsverfahren = Wertermittlungsverfahren.MESSUNG, + }, + }, }; var cr = em.GetCompletenessReport(); - Debug.WriteLine($"{nameof(em)} has a coverage of {decimal.Round(cr.Coverage.Value * 100.0M)}%."); + Debug.WriteLine( + $"{nameof(em)} has a coverage of {decimal.Round(cr.Coverage.Value * 100.0M)}%." + ); // em has a coverage of 45%. Debug.WriteLine( - $"{nameof(em)} has no values for the following intervals: {string.Join(", ", cr.Gaps.Select(g => g.Startdatum.ToString("yyyy-MM-dd") + " to " + g.Enddatum.ToString("yyyy-MM-dd")))}"); + $"{nameof(em)} has no values for the following intervals: {string.Join(", ", cr.Gaps.Select(g => g.Startdatum.ToString("yyyy-MM-dd") + " to " + g.Enddatum.ToString("yyyy-MM-dd")))}" + ); // em has no values for the following intervals: 2020-03-08 to 2020-03-25 } -} \ No newline at end of file +} diff --git a/TestBO4E.Reporting/TestCompletenessReportSorting.cs b/TestBO4E.Reporting/TestCompletenessReportSorting.cs index 0f6a935c..3d63e1a4 100644 --- a/TestBO4E.Reporting/TestCompletenessReportSorting.cs +++ b/TestBO4E.Reporting/TestCompletenessReportSorting.cs @@ -17,22 +17,22 @@ public void TestStartdatumSorting() { ReferenceTimeFrame = new Zeitraum { - Startdatum = new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc) - } + Startdatum = new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }, }; var cr2 = new CompletenessReport { ReferenceTimeFrame = new Zeitraum { - Startdatum = new DateTime(2002, 1, 1, 0, 0, 0, DateTimeKind.Utc) - } + Startdatum = new DateTime(2002, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }, }; var cr3 = new CompletenessReport { ReferenceTimeFrame = new Zeitraum { - Startdatum = new DateTime(2003, 1, 1, 0, 0, 0, DateTimeKind.Utc) - } + Startdatum = new DateTime(2003, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }, }; var crList = new List { cr2, cr3, cr1 }; // before sorting @@ -52,12 +52,12 @@ public void TestStartdatumSorting() { ReferenceTimeFrame = new Zeitraum { - Startdatum = new DateTime(1999, 1, 1, 0, 0, 0, DateTimeKind.Utc) - } + Startdatum = new DateTime(1999, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }, }; crList.Add(cr0); crList.Sort(); Assert.IsNull(crList.First().ReferenceTimeFrame); Assert.AreEqual(1999, crList[1].ReferenceTimeFrame.Startdatum.Value.Year); } -} \ No newline at end of file +} diff --git a/TestBO4E.Reporting/TestReportToCsv.cs b/TestBO4E.Reporting/TestReportToCsv.cs index 6921612d..a827fc76 100644 --- a/TestBO4E.Reporting/TestReportToCsv.cs +++ b/TestBO4E.Reporting/TestReportToCsv.cs @@ -25,8 +25,8 @@ public void TestCompletenessReportToCsv() ReferenceTimeFrame = new Zeitraum { Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero) - } + Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero), + }, }; var result = cr.ToCsv(';', true, Environment.NewLine); var lines = new List(result.Split(Environment.NewLine)); @@ -35,10 +35,10 @@ public void TestCompletenessReportToCsv() // reihenfolge var reihenfolge = new List> { - new Dictionary {["LokationsId"] = "messlokationsId"}, - new Dictionary {["Coverage"] = "Newcoverage"}, - new Dictionary {["Zeitraum.Startdatum"] = "time.startdatum"}, - new Dictionary {["Zeitraum.Enddatum"] = "time.enddatum"} + new Dictionary { ["LokationsId"] = "messlokationsId" }, + new Dictionary { ["Coverage"] = "Newcoverage" }, + new Dictionary { ["Zeitraum.Startdatum"] = "time.startdatum" }, + new Dictionary { ["Zeitraum.Enddatum"] = "time.enddatum" }, }; //string JSONdata = "{'completenessZfa':[{'lokationsId':'lokationsId'},{'coverage':'coverage'},{'Zeitraum.einheit':'einheit'},{'Zeitraum.dauer':'dauer'},{'Zeitraum.startdatum':'startdatum'},{'Zeitraum.enddatum':'enddatum'},{'obiskennzahl':'obiskennzahl'},{'einheit':'einheit'},{'wertermittlungsverfahren':'wertermittlungsverfahren'},{'startdatum':'Verbrauch.startdatum'},{'enddatum':'Verbrauch.enddatum'},{'wert':'Verbrauch.wert'},{'headerLine':'1'}]}"; @@ -48,9 +48,20 @@ public void TestCompletenessReportToCsv() var newresult = cr.ToCsv(';', true, Environment.NewLine, reihenfolge); lines = new List(newresult.Split(Environment.NewLine)); Assert.AreEqual(2, lines.Count); - var decimalSeparator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator; - Assert.AreEqual("DE12345;0" + decimalSeparator + "87;2019-01-01T00:00:00Z;2019-03-01T00:00:00Z;", lines[1]); - var commaResult = cr.ToCsv(',', lineTerminator: Environment.NewLine, reihenfolge: reihenfolge); + var decimalSeparator = Thread + .CurrentThread + .CurrentCulture + .NumberFormat + .NumberDecimalSeparator; + Assert.AreEqual( + "DE12345;0" + decimalSeparator + "87;2019-01-01T00:00:00Z;2019-03-01T00:00:00Z;", + lines[1] + ); + var commaResult = cr.ToCsv( + ',', + lineTerminator: Environment.NewLine, + reihenfolge: reihenfolge + ); var separator = ""; if (decimalSeparator == ",") { @@ -58,11 +69,22 @@ public void TestCompletenessReportToCsv() } Assert.AreEqual( - $"DE12345,{separator}0" + decimalSeparator + - $"87{separator},2019-01-01T00:00:00Z,2019-03-01T00:00:00Z,", commaResult.Split(Environment.NewLine)[1]); - var dpunktResult = cr.ToCsv(':', lineTerminator: Environment.NewLine, reihenfolge: reihenfolge); - Assert.AreEqual("DE12345:0" + decimalSeparator + "87:\"2019-01-01T00:00:00Z\":\"2019-03-01T00:00:00Z\":", - dpunktResult.Split(Environment.NewLine)[1]); + $"DE12345,{separator}0" + + decimalSeparator + + $"87{separator},2019-01-01T00:00:00Z,2019-03-01T00:00:00Z,", + commaResult.Split(Environment.NewLine)[1] + ); + var dpunktResult = cr.ToCsv( + ':', + lineTerminator: Environment.NewLine, + reihenfolge: reihenfolge + ); + Assert.AreEqual( + "DE12345:0" + + decimalSeparator + + "87:\"2019-01-01T00:00:00Z\":\"2019-03-01T00:00:00Z\":", + dpunktResult.Split(Environment.NewLine)[1] + ); cr.Values = new List { @@ -70,28 +92,34 @@ public void TestCompletenessReportToCsv() { Wert = 17, Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, new CompletenessReport.BasicVerbrauch { Wert = 21, Startdatum = new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2019, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, new CompletenessReport.BasicVerbrauch { Wert = 35, Startdatum = new DateTimeOffset(2019, 1, 12, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime - } + Enddatum = new DateTimeOffset(2019, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + }, }; reihenfolge.Add(new Dictionary { ["Wert"] = "V.wert" }); reihenfolge.Add(new Dictionary { ["Startdatum"] = "V.startdatum" }); reihenfolge.Add(new Dictionary { ["Enddatum"] = "V.enddatum" }); - var multiplicityResult = cr.ToCsv(lineTerminator: Environment.NewLine, reihenfolge: reihenfolge); - Assert.AreEqual(2 + cr.Values.Count, new List(multiplicityResult.Split(Environment.NewLine)).Count); + var multiplicityResult = cr.ToCsv( + lineTerminator: Environment.NewLine, + reihenfolge: reihenfolge + ); + Assert.AreEqual( + 2 + cr.Values.Count, + new List(multiplicityResult.Split(Environment.NewLine)).Count + ); } [TestMethod] @@ -99,8 +127,9 @@ public void TestDeserialisationCompletenessReportColumnsToCsv() { var jsonData = "{'completenessZfa':[{'lokationsId':'lokationsId'},{'coverage':'coverage'},{'referenceTimeFrame.einheit':'referenceTimeFrame.einheit'},{'referenceTimeFrame.dauer':'referenceTimeFrame.dauer'},{'referenceTimeFrame.startdatum':'referenceTimeFrame.startdatum'},{'referenceTimeFrame.enddatum':'referenceTimeFrame.enddatum'},{'obiskennzahl':'obiskennzahl'},{'einheit':'einheit'},{'wertermittlungsverfahren':'wertermittlungsverfahren'},{'values.startdatum':'Verbrauch.startdatum'},{'values.enddatum':'Verbrauch.enddatum'},{'values.wert':'Verbrauch.wert'},{'headerLine':'1'}]}"; - var reihenfolge = - JsonConvert.DeserializeObject>>>(jsonData); + var reihenfolge = JsonConvert.DeserializeObject< + Dictionary>> + >(jsonData); Assert.AreEqual("coverage", reihenfolge["completenessZfa"][1].Values.First()); } @@ -114,7 +143,8 @@ public void TestDeserialisationCompletenessReportToCsv() var counter = 1; foreach (var report in reports) { - lastCsvText += report.ToCsv(';', counter == 1, Environment.NewLine) + Environment.NewLine; + lastCsvText += + report.ToCsv(';', counter == 1, Environment.NewLine) + Environment.NewLine; counter++; } @@ -131,7 +161,8 @@ public void TestPrivateFieldsAndUserProperties() var counter = 1; foreach (var report in reports) { - lastCsvText += report.ToCsv(';', counter == 1, Environment.NewLine) + Environment.NewLine; + lastCsvText += + report.ToCsv(';', counter == 1, Environment.NewLine) + Environment.NewLine; counter++; } @@ -160,21 +191,31 @@ public void TestPrivateFieldsAndUserPropertiesHardCodingCSV() var counter = 0; foreach (var report in reports) { - var singleReportLine = report.ToCSV(";", counter == 0, Environment.NewLine) + Environment.NewLine; + var singleReportLine = + report.ToCSV(";", counter == 0, Environment.NewLine) + Environment.NewLine; if (counter == 0) { - Assert.IsTrue(singleReportLine.Split(Environment.NewLine)[1] - .StartsWith("2019-09-30T22:00:00Z;2019-10-31T23:00:00Z;;50985149762")); // no melo, just malo + Assert.IsTrue( + singleReportLine + .Split(Environment.NewLine)[1] + .StartsWith("2019-09-30T22:00:00Z;2019-10-31T23:00:00Z;;50985149762") + ); // no melo, just malo Assert.IsTrue(singleReportLine.Contains("IMS")); - var missingEntries = - ((new DateTime(2019, 10, 31, 23, 0, 0, 0, DateTimeKind.Utc) - - new DateTime(2019, 10, 27, 0, 0, 0, 0, DateTimeKind.Utc)).TotalHours * 4).ToString(); + var missingEntries = ( + ( + new DateTime(2019, 10, 31, 23, 0, 0, 0, DateTimeKind.Utc) + - new DateTime(2019, 10, 27, 0, 0, 0, 0, DateTimeKind.Utc) + ).TotalHours * 4 + ).ToString(); Assert.IsTrue(singleReportLine.Contains($";{missingEntries};")); } else if (counter == 0) // ToDo: where did this come from? { - Assert.IsTrue(singleReportLine.StartsWith( - "2019-09-30T22:00:00Z;2019-10-31T23:00:00Z;DE0004096816100000000000000200712;;")); // no malo, just melo + Assert.IsTrue( + singleReportLine.StartsWith( + "2019-09-30T22:00:00Z;2019-10-31T23:00:00Z;DE0004096816100000000000000200712;;" + ) + ); // no malo, just melo Assert.IsTrue(singleReportLine.Contains("RLM")); } @@ -187,7 +228,6 @@ public void TestPrivateFieldsAndUserPropertiesHardCodingCSV() Assert.IsFalse(lastCsvText.Contains("_errorMessage")); } - [TestMethod] public void TestCompletenessReportMitGapToCsv() { @@ -196,59 +236,75 @@ public void TestCompletenessReportMitGapToCsv() LokationsId = "DE12345", Coverage = 0.87M, // 87% Wertermittlungsverfahren = Wertermittlungsverfahren.PROGNOSE, - ReferenceTimeFrame = - new Zeitraum + ReferenceTimeFrame = new Zeitraum + { + Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), + Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero), + }, + Values = new List + { + new CompletenessReport.BasicVerbrauch { - Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero) + Wert = 17, + Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + Enddatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, - Values = - new List + new CompletenessReport.BasicVerbrauch { - new CompletenessReport.BasicVerbrauch - { - Wert = 17, - Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime - }, - new CompletenessReport.BasicVerbrauch - { - Wert = 21, - Startdatum = new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime - }, - new CompletenessReport.BasicVerbrauch - { - Wert = 35, - Startdatum = new DateTimeOffset(2019, 1, 12, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2019, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime - } + Wert = 21, + Startdatum = new DateTimeOffset(2019, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + Enddatum = new DateTimeOffset(2019, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, + new CompletenessReport.BasicVerbrauch + { + Wert = 35, + Startdatum = new DateTimeOffset( + 2019, + 1, + 12, + 0, + 0, + 0, + TimeSpan.Zero + ).UtcDateTime, + Enddatum = new DateTimeOffset(2019, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + }, + }, Gaps = new List { new CompletenessReport.BasicVerbrauch { Wert = 0, Startdatum = new DateTimeOffset(2017, 1, 1, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2017, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2017, 1, 2, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, new CompletenessReport.BasicVerbrauch { Wert = 0, Startdatum = new DateTimeOffset(2017, 1, 7, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2017, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime + Enddatum = new DateTimeOffset(2017, 1, 8, 0, 0, 0, TimeSpan.Zero).UtcDateTime, }, new CompletenessReport.BasicVerbrauch { Wert = 0, - Startdatum = new DateTimeOffset(2017, 1, 12, 0, 0, 0, TimeSpan.Zero).UtcDateTime, - Enddatum = new DateTimeOffset(2017, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime - } - } + Startdatum = new DateTimeOffset( + 2017, + 1, + 12, + 0, + 0, + 0, + TimeSpan.Zero + ).UtcDateTime, + Enddatum = new DateTimeOffset(2017, 1, 13, 0, 0, 0, TimeSpan.Zero).UtcDateTime, + }, + }, }; var multiplicityResult = cr.ToCsv(lineTerminator: Environment.NewLine); - Assert.AreEqual(2 + cr.Values.Count + cr.Gaps.Count, - new List(multiplicityResult.Split(Environment.NewLine)).Count); + Assert.AreEqual( + 2 + cr.Values.Count + cr.Gaps.Count, + new List(multiplicityResult.Split(Environment.NewLine)).Count + ); } [TestMethod] @@ -262,40 +318,43 @@ public void TestCompletenessReportToCsvExceptions() ReferenceTimeFrame = new Zeitraum { Startdatum = new DateTimeOffset(2019, 1, 1, 0, 0, 0, TimeSpan.Zero), - Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero) - } + Enddatum = new DateTimeOffset(2019, 3, 1, 0, 0, 0, TimeSpan.Zero), + }, }; // reihenfolge var reihenfolge = new List> { - new Dictionary {["LokationsId"] = "messlokationsId"}, - new Dictionary {["Coverage"] = "Newcoverage"}, - new Dictionary {["Zeitraum.Startdatum"] = "time.startdatum"}, - new Dictionary {["Zeitraum.Enddatum"] = "time.enddatum"}, - new Dictionary {["Wert"] = null}, - new Dictionary {["Startdatum"] = "V.startdatum"}, - new Dictionary {["Enddatum"] = "V.enddatum"}, - null + new Dictionary { ["LokationsId"] = "messlokationsId" }, + new Dictionary { ["Coverage"] = "Newcoverage" }, + new Dictionary { ["Zeitraum.Startdatum"] = "time.startdatum" }, + new Dictionary { ["Zeitraum.Enddatum"] = "time.enddatum" }, + new Dictionary { ["Wert"] = null }, + new Dictionary { ["Startdatum"] = "V.startdatum" }, + new Dictionary { ["Enddatum"] = "V.enddatum" }, + null, }; var newResult = string.Empty; - Assert.ThrowsException(() => cr.ToCsv(';', true, Environment.NewLine, reihenfolge)); + Assert.ThrowsException( + () => cr.ToCsv(';', true, Environment.NewLine, reihenfolge) + ); Assert.AreEqual(newResult, ""); - // reihenfolge var reihenfolge2 = new List> { - new Dictionary {["lokationsId"] = "messlokationsId"}, - new Dictionary {["coverage"] = "Newcoverage"}, - new Dictionary {["Zeitraum.startdatum"] = "time.startdatum"}, - new Dictionary {["Zeitraum.enddatum"] = "time.enddatum"}, - new Dictionary {["wert"] = "V.wert"}, - new Dictionary {["startdatum"] = "V.startdatum"}, - new Dictionary {["enddatum"] = "V.enddatum"}, - new Dictionary {["asdasd"] = "000"} + new Dictionary { ["lokationsId"] = "messlokationsId" }, + new Dictionary { ["coverage"] = "Newcoverage" }, + new Dictionary { ["Zeitraum.startdatum"] = "time.startdatum" }, + new Dictionary { ["Zeitraum.enddatum"] = "time.enddatum" }, + new Dictionary { ["wert"] = "V.wert" }, + new Dictionary { ["startdatum"] = "V.startdatum" }, + new Dictionary { ["enddatum"] = "V.enddatum" }, + new Dictionary { ["asdasd"] = "000" }, }; - Assert.ThrowsException(() => cr.ToCsv(';', true, Environment.NewLine, reihenfolge2)); + Assert.ThrowsException( + () => cr.ToCsv(';', true, Environment.NewLine, reihenfolge2) + ); Assert.AreEqual(newResult, ""); } @@ -303,7 +362,8 @@ public void TestCompletenessReportToCsvExceptions() public void TestSerializingCrWithoutGaps() { var report = JsonConvert.DeserializeObject( - "{\"_errorMessage\":\"Cannot use autoconfigured method because there are no values.\",\"boTyp\":\"COMPLETENESSREPORT\",\"versionStruktur\":1,\"obiskennzahl\":\"1-1:1.29.0\",\"values\":[],\"einheit\":0,\"gaps\":null,\"referenceTimeFrame\":{ \"einheit\":4,\"dauer\":1.0,\"startdatum\":\"2020-06-30T22:00:00+00:00\",\"enddatum\":\"2020-07-01T22:00:00+00:00\"},\"wertermittlungsverfahren\":0,\"lokationsId\":\"DE000XXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"coverage\":0.0,\"profil\":\"000000000111129993\",\"profilRolle\":\"0001\",\"anlagennummer\":\"5111111111\",\"zw\":\"000000000020709888\",\"sap_time_zone\":\"CET\",\"sap_profdecimals\":\"06\",\"sapSanitized\":true,\"valueCount\":0,\"coverage_07-01\":0,\"coverage_07-02\":0,\"coverage_07-03\":0,\"coverage_07-04\":0,\"coverage_07-05\":0,\"coverage_07-06\":0,\"coverage_07-07\":0,\"coverage_07-08\":0,\"coverage_07-09\":0,\"coverage_07-10\":0,\"coverage_07-11\":0,\"coverage_07-12\":0,\"coverage_07-13\":0,\"coverage_07-14\":0,\"coverage_07-15\":0,\"coverage_07-16\":0,\"coverage_07-17\":0,\"coverage_07-18\":0,\"coverage_07-19\":0,\"coverage_07-20\":0,\"coverage_07-21\":0,\"coverage_07-22\":0,\"coverage_07-23\":0,\"coverage_07-24\":0,\"coverage_07-25\":0,\"coverage_07-26\":0,\"coverage_07-27\":0,\"coverage_07-28\":0,\"coverage_07-29\":0,\"coverage_07-30\":0,\"coverage_07-31\":0,\"coverage_sum\":0}"); + "{\"_errorMessage\":\"Cannot use autoconfigured method because there are no values.\",\"boTyp\":\"COMPLETENESSREPORT\",\"versionStruktur\":1,\"obiskennzahl\":\"1-1:1.29.0\",\"values\":[],\"einheit\":0,\"gaps\":null,\"referenceTimeFrame\":{ \"einheit\":4,\"dauer\":1.0,\"startdatum\":\"2020-06-30T22:00:00+00:00\",\"enddatum\":\"2020-07-01T22:00:00+00:00\"},\"wertermittlungsverfahren\":0,\"lokationsId\":\"DE000XXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"coverage\":0.0,\"profil\":\"000000000111129993\",\"profilRolle\":\"0001\",\"anlagennummer\":\"5111111111\",\"zw\":\"000000000020709888\",\"sap_time_zone\":\"CET\",\"sap_profdecimals\":\"06\",\"sapSanitized\":true,\"valueCount\":0,\"coverage_07-01\":0,\"coverage_07-02\":0,\"coverage_07-03\":0,\"coverage_07-04\":0,\"coverage_07-05\":0,\"coverage_07-06\":0,\"coverage_07-07\":0,\"coverage_07-08\":0,\"coverage_07-09\":0,\"coverage_07-10\":0,\"coverage_07-11\":0,\"coverage_07-12\":0,\"coverage_07-13\":0,\"coverage_07-14\":0,\"coverage_07-15\":0,\"coverage_07-16\":0,\"coverage_07-17\":0,\"coverage_07-18\":0,\"coverage_07-19\":0,\"coverage_07-20\":0,\"coverage_07-21\":0,\"coverage_07-22\":0,\"coverage_07-23\":0,\"coverage_07-24\":0,\"coverage_07-25\":0,\"coverage_07-26\":0,\"coverage_07-27\":0,\"coverage_07-28\":0,\"coverage_07-29\":0,\"coverage_07-30\":0,\"coverage_07-31\":0,\"coverage_sum\":0}" + ); report.ToCSV(";", true, Environment.NewLine); } -} \ No newline at end of file +}