From 56bd35d9a2777bb693ca43fcd6b623b0910bf866 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Fri, 25 Aug 2023 15:23:57 +0200 Subject: [PATCH] CommonMessurementUnits --- Common/.vs/config/applicationhost.config | 2 +- Common/Common.sln | 201 ++++++++++++++++++ Common/CommonConsole/App.config | 6 + Common/CommonConsole/CommonConsole.csproj | 63 ++++++ Common/CommonConsole/Program.cs | 51 +++++ .../CommonConsole/Properties/AssemblyInfo.cs | 36 ++++ Common/CommonConsole/packages.config | 4 + Common/CommonMessurementUnits/Base.cs | 31 +++ .../CommonMessurementUnits/BitExtensions.cs | 117 ++++++++++ .../CommonMessurementUnits.csproj | 80 +++++++ .../CommonMessurementUnits.snk | Bin 0 -> 596 bytes Common/CommonMessurementUnits/Current.cs | 28 +++ Common/CommonMessurementUnits/Flow.cs | 28 +++ .../JsonConverters/CurrentConverter.cs | 27 +++ .../JsonConverters/FlowConverter.cs | 27 +++ .../JsonConverters/PressureConverter.cs | 27 +++ .../JsonConverters/TemperatureConverter.cs | 27 +++ .../JsonConverters/TimeConverter.cs | 27 +++ .../JsonConverters/VolumeConverter.cs | 27 +++ Common/CommonMessurementUnits/Pressure.cs | 28 +++ .../Properties/AssemblyInfo.cs | 36 ++++ Common/CommonMessurementUnits/Temperature.cs | 22 ++ Common/CommonMessurementUnits/Time.cs | 46 ++++ Common/CommonMessurementUnits/Volume.cs | 34 +++ Common/CommonMessurementUnits/packages.config | 4 + Common/LaaProduction/Einheiten.cs | 79 +++++++ Common/LaaProduction/LaaProduction.csproj | 3 +- Common/LaaProduction/Programm.cs | 43 +++- .../MeterProcessState.csproj.user | 1 + 29 files changed, 1102 insertions(+), 3 deletions(-) create mode 100644 Common/CommonConsole/App.config create mode 100644 Common/CommonConsole/CommonConsole.csproj create mode 100644 Common/CommonConsole/Program.cs create mode 100644 Common/CommonConsole/Properties/AssemblyInfo.cs create mode 100644 Common/CommonConsole/packages.config create mode 100644 Common/CommonMessurementUnits/Base.cs create mode 100644 Common/CommonMessurementUnits/BitExtensions.cs create mode 100644 Common/CommonMessurementUnits/CommonMessurementUnits.csproj create mode 100644 Common/CommonMessurementUnits/CommonMessurementUnits.snk create mode 100644 Common/CommonMessurementUnits/Current.cs create mode 100644 Common/CommonMessurementUnits/Flow.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/CurrentConverter.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/FlowConverter.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/PressureConverter.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/TemperatureConverter.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/TimeConverter.cs create mode 100644 Common/CommonMessurementUnits/JsonConverters/VolumeConverter.cs create mode 100644 Common/CommonMessurementUnits/Pressure.cs create mode 100644 Common/CommonMessurementUnits/Properties/AssemblyInfo.cs create mode 100644 Common/CommonMessurementUnits/Temperature.cs create mode 100644 Common/CommonMessurementUnits/Time.cs create mode 100644 Common/CommonMessurementUnits/Volume.cs create mode 100644 Common/CommonMessurementUnits/packages.config create mode 100644 Common/LaaProduction/Einheiten.cs diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 1b9332b4..12afd122 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Common.sln b/Common/Common.sln index d93b1eda..008730d2 100644 --- a/Common/Common.sln +++ b/Common/Common.sln @@ -183,6 +183,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SIRT", "SIRT", "{AF973E0E-2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIRTBroadcaster.Host", "SIRTBroadcaster.Host\SIRTBroadcaster.Host.csproj", "{A9D1A99D-6E55-4394-86AD-B5C53E9225EB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction", "LaaProduction\LaaProduction.csproj", "{FD30EB7A-7809-4E62-9374-791D31877D6D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonMessurementUnits", "CommonMessurementUnits\CommonMessurementUnits.csproj", "{17C15B79-9A9E-4079-8FE2-0E563F18CA01}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonConsole", "CommonConsole\CommonConsole.csproj", "{AFC428F5-0141-4A3F-BEF2-470A89D972F6}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4 @@ -4249,6 +4255,198 @@ Global {A9D1A99D-6E55-4394-86AD-B5C53E9225EB}.XP32bit|x64.Build.0 = Release|Any CPU {A9D1A99D-6E55-4394-86AD-B5C53E9225EB}.XP32bit|x86.ActiveCfg = Release|Any CPU {A9D1A99D-6E55-4394-86AD-B5C53E9225EB}.XP32bit|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.COM|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|x64.ActiveCfg = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|x64.Build.0 = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|x86.ActiveCfg = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Debug|x86.Build.0 = Debug|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.PerformTest|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.Release|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.ReleaseTest|x86.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x64.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x64.Build.0 = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x86.ActiveCfg = Release|Any CPU + {FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x64.ActiveCfg = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x64.Build.0 = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x86.ActiveCfg = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x86.Build.0 = Debug|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x86.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x64.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x64.Build.0 = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x86.ActiveCfg = Release|Any CPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|x64.ActiveCfg = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|x64.Build.0 = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|x86.ActiveCfg = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|x86.Build.0 = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.PerformTest|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Release|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.ReleaseTest|x86.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|Any CPU.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|x64.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|x64.Build.0 = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|x86.ActiveCfg = Release|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.XP32bit|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4332,6 +4530,9 @@ Global {4221F992-599E-498C-A409-6D1E70E0A6F9} = {AF973E0E-2B44-4F1A-B1E7-77C8B4F30579} {AF973E0E-2B44-4F1A-B1E7-77C8B4F30579} = {99B23EE9-CE50-4924-A055-C39EFA038721} {A9D1A99D-6E55-4394-86AD-B5C53E9225EB} = {AF973E0E-2B44-4F1A-B1E7-77C8B4F30579} + {FD30EB7A-7809-4E62-9374-791D31877D6D} = {696A94BE-7237-4AE2-9E36-6059DE519971} + {17C15B79-9A9E-4079-8FE2-0E563F18CA01} = {C17363DF-A043-4F25-8EBA-2B3B078227DC} + {AFC428F5-0141-4A3F-BEF2-470A89D972F6} = {C17363DF-A043-4F25-8EBA-2B3B078227DC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164} diff --git a/Common/CommonConsole/App.config b/Common/CommonConsole/App.config new file mode 100644 index 00000000..aee9adf4 --- /dev/null +++ b/Common/CommonConsole/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj new file mode 100644 index 00000000..840f0f3c --- /dev/null +++ b/Common/CommonConsole/CommonConsole.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6} + Exe + CommonConsole + CommonConsole + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + {17C15B79-9A9E-4079-8FE2-0E563F18CA01} + CommonMessurementUnits + + + + \ No newline at end of file diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs new file mode 100644 index 00000000..f86a17ed --- /dev/null +++ b/Common/CommonConsole/Program.cs @@ -0,0 +1,51 @@ +namespace CommonConsole +{ + using CommonMessurementUnits; + + using System; + + public class Program + { + public static void Main(string[] args) + { + + int x = 3; + byte[] xb = x.GetBytes(); + Console.WriteLine(string.Join("", xb.GetBits())); + Console.WriteLine(xb.ToHex()); + long y = BitConverter.ToInt32(xb, 0); + Console.WriteLine(y); + + //var model = new TestClass + //{ + // Flow = 1, + // Time = 15.56, + // Volume = 40, + // Pressure = 250000, + // Current = 130, + // Temperature = 21.9 + //}; + + //var modelJson = JsonConvert.SerializeObject(model, Formatting.Indented); + //var testModel = JsonConvert.DeserializeObject(modelJson); + + //Console.WriteLine(modelJson); + //Console.WriteLine(JsonConvert.SerializeObject(testModel, Formatting.Indented)); + } + } + + public class TestClass + { + public Current Current { get; set; } + + public Flow Flow { get; set; } + + public Pressure Pressure { get; set; } + + public Temperature Temperature { get; set; } + + public Time Time { get; set; } + + public Volume Volume { get; set; } + } +} diff --git a/Common/CommonConsole/Properties/AssemblyInfo.cs b/Common/CommonConsole/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..91ef8d56 --- /dev/null +++ b/Common/CommonConsole/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CommonConsole")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CommonConsole")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("afc428f5-0141-4a3f-bef2-470a89d972f6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/CommonConsole/packages.config b/Common/CommonConsole/packages.config new file mode 100644 index 00000000..c865026e --- /dev/null +++ b/Common/CommonConsole/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Common/CommonMessurementUnits/Base.cs b/Common/CommonMessurementUnits/Base.cs new file mode 100644 index 00000000..41abb0f0 --- /dev/null +++ b/Common/CommonMessurementUnits/Base.cs @@ -0,0 +1,31 @@ +namespace CommonMessurementUnits +{ + public abstract class Base + { + public const int MsInSec = 1000; + public const int SecInMin = 60; + public const int MinInH = 60; + public const int HInDay = 24; + public const int MlInL = 1000; + public const int LInm3 = 1000; + public const int PInBar = 100000; + public const int MAInH = 1000; + + protected double value; + + public override string ToString() + => this.value.ToString(); + + public override bool Equals(object obj) + => this.value.Equals(obj); + + public override int GetHashCode() + => this.value.GetHashCode(); + + public static explicit operator double (Base @base) + => @base?.value ?? default(double); + + public static explicit operator double? (Base @base) + => @base?.value; + } +} diff --git a/Common/CommonMessurementUnits/BitExtensions.cs b/Common/CommonMessurementUnits/BitExtensions.cs new file mode 100644 index 00000000..95506da0 --- /dev/null +++ b/Common/CommonMessurementUnits/BitExtensions.cs @@ -0,0 +1,117 @@ +namespace CommonMessurementUnits +{ + using System; + using System.Linq; + using System.Text; + + public static class BitExtensions + { + public static byte[] GetBits(this byte[] bytes) + { + if (bytes is null) + { + return Array.Empty(); + } + + var bytesCount = bytes.Length; + var bitsCount = bytesCount * 8; + var bits = new byte[bitsCount]; + var bit = 0; + + foreach (var @byte in bytes) + { + for (int b = 7; b >= 0; b--) + { + bits[bit++] = (byte)((@byte >> b) % 2); + } + } + + return bits; + } + + public static byte[] GetBytes(this byte value, int take = 1) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this sbyte value, int take = 2) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this short value, int take = 2) + => BitConverter.GetBytes(value).Take(2); + + public static byte[] GetBytes(this ushort value, int take = 2) + => BitConverter.GetBytes(value).Take(2); + + public static byte[] GetBytes(this int value, int take = 4) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this uint value, int take = 4) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this long value, int take = 8) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this ulong value, int take = 8) + => BitConverter.GetBytes(value).Take(take); + + public static byte[] GetBytes(this double value) + => BitConverter.GetBytes(value); + + public static byte[] GetBytes(this string value) + => Encoding.ASCII.GetBytes(value); + + public static byte[] Swap(this byte[] bytes) + { + if (bytes is null) + { + return Array.Empty(); + } + + var length = bytes.Length; + var swapped = new byte[length]; + + for (int x = 0; x < length; x++) + { + swapped[x] = bytes[length - x - 1]; + } + + return swapped; + } + + public static byte[] Take(this byte[] bytesSRC, int count) + { + if (bytesSRC is null || count < 0) + { + return Array.Empty(); + } + + var bytesDST = new byte[count]; + + Array.Copy(bytesSRC, 0, bytesDST, 0, count); + + return bytesDST; + } + + public static string ToHex(this byte[] value, string separator = " ") + { + if (value is null) + { + return string.Empty; + } + + return BitConverter.ToString(value).Replace("-", separator); + } + + public static byte[] FromHex(this string value, string separator = " ") + { + if (string.IsNullOrWhiteSpace(value)) + { + return Array.Empty(); + } + + return value + .Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries) + .Select(x => byte.TryParse(x, out byte b) ? b : default(byte)) + .ToArray(); + } + } +} diff --git a/Common/CommonMessurementUnits/CommonMessurementUnits.csproj b/Common/CommonMessurementUnits/CommonMessurementUnits.csproj new file mode 100644 index 00000000..7c73bace --- /dev/null +++ b/Common/CommonMessurementUnits/CommonMessurementUnits.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {17C15B79-9A9E-4079-8FE2-0E563F18CA01} + Library + Properties + CommonMessurementUnits + CommonMessurementUnits + v4.8.1 + Stoyan Zlatev + Sensus - a Xylem brand + A lighter and better way to convert numbers in messurement units. + 2023 + https://slm.sms-esaap.com/la_operations/laapackages/ + 1.0.0.0 + 1.0.0.0 + 1.0.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + CommonMessurementUnits.snk + + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Common/CommonMessurementUnits/CommonMessurementUnits.snk b/Common/CommonMessurementUnits/CommonMessurementUnits.snk new file mode 100644 index 0000000000000000000000000000000000000000..5d02f37dcaa2092733abdf3e35de2088ab3d7c85 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097%%>zxjOf0vdbq*qy_xoq7QZumjQjbiN zJFqF5z>E)iPJh9&G`eWByzrYbdFs)02W3U{kYn=~yRwYq5&il9X;?TpT1vBS(ZfHa zuUD_RP2_-8SJi3RqlF~r{rl31O4ehq_-}M7ESrrT4~&SwJ2B}f+%A^DmQb?#vPGF+ zEYJ(&WLq~xA`U|!GGAJ?yV11cUj>hEIxBE_`H9juSqwRZ)LJ4p;nP|?b?z_ZFmY&pqfbWPe^mI zA7g~hBifyviqFVk1#|;^SkvvyF6`&B*Eki20{!{c*EdrRjz72)Fv*x)-RtJmxD zX9Qmq;O~uTqs3$nrEYnwDB^^VxW*prf$OUnacsI?m^=R?rb<6MLUXN5qP<5bdegI} z+>gv5P-8w?Q8!SzgJJWBHNL0i;+xV3(i`C_fmi60X9l~nS>O^wfvYq_?rzfIG&!MK ii|Cl|8(6gcpGK4QTgLs=lNSMPw*l^cC|3B;6nJ|7TPVu_ literal 0 HcmV?d00001 diff --git a/Common/CommonMessurementUnits/Current.cs b/Common/CommonMessurementUnits/Current.cs new file mode 100644 index 00000000..9568fe31 --- /dev/null +++ b/Common/CommonMessurementUnits/Current.cs @@ -0,0 +1,28 @@ +namespace CommonMessurementUnits +{ + using CommonMessurementUnits.JsonConverters; + + using Newtonsoft.Json; + + [JsonConverter(typeof(CurrentConverter))] + public class Current : Base + { + public double MiliampereHours + { + get => this.AmpereHours * MAInH; + set => this.AmpereHours = value / MAInH; + } + + public double AmpereHours + { + get => this.value; + set => this.value = value; + } + + public static implicit operator Current(double x) + => new Current { value = x }; + + public static implicit operator Current(double? x) + => new Current { value = x ?? 0 }; + } +} diff --git a/Common/CommonMessurementUnits/Flow.cs b/Common/CommonMessurementUnits/Flow.cs new file mode 100644 index 00000000..30503235 --- /dev/null +++ b/Common/CommonMessurementUnits/Flow.cs @@ -0,0 +1,28 @@ +namespace CommonMessurementUnits +{ + using CommonMessurementUnits.JsonConverters; + + using Newtonsoft.Json; + + [JsonConverter(typeof(FlowConverter))] + public class Flow : Base + { + public double CubicMeterInHour + { + get => this.value; + set => this.value = value; + } + + public double LiterInMinute + { + get => this.CubicMeterInHour / MinInH * LInm3; + set => this.CubicMeterInHour = value * MinInH / LInm3; + } + + public static implicit operator Flow(double x) + => new Flow { value = x }; + + public static implicit operator Flow(double? x) + => new Flow { value = x ?? 0 }; + } +} diff --git a/Common/CommonMessurementUnits/JsonConverters/CurrentConverter.cs b/Common/CommonMessurementUnits/JsonConverters/CurrentConverter.cs new file mode 100644 index 00000000..ba8f652a --- /dev/null +++ b/Common/CommonMessurementUnits/JsonConverters/CurrentConverter.cs @@ -0,0 +1,27 @@ +namespace CommonMessurementUnits.JsonConverters +{ + using Newtonsoft.Json; + + using System; + + public class CurrentConverter : JsonConverter + { + public override Current ReadJson(JsonReader reader, Type objectType, Current existingValue, bool hasExistingValue, JsonSerializer serializer) + { + while (reader.ValueType != typeof(double)) + { + reader.Read(); + } + + if (reader.Value is double value) + { + return value; + } + + return existingValue; + } + + public override void WriteJson(JsonWriter writer, Current value, JsonSerializer serializer) + => writer.WriteValue((double)value); + } +} diff --git a/Common/CommonMessurementUnits/JsonConverters/FlowConverter.cs b/Common/CommonMessurementUnits/JsonConverters/FlowConverter.cs new file mode 100644 index 00000000..a3bfa449 --- /dev/null +++ b/Common/CommonMessurementUnits/JsonConverters/FlowConverter.cs @@ -0,0 +1,27 @@ +namespace CommonMessurementUnits.JsonConverters +{ + using Newtonsoft.Json; + + using System; + + public class FlowConverter : JsonConverter + { + public override Flow ReadJson(JsonReader reader, Type objectType, Flow existingValue, bool hasExistingValue, JsonSerializer serializer) + { + while (reader.ValueType != typeof(double)) + { + reader.Read(); + } + + if (reader.Value is double value) + { + return value; + } + + return existingValue; + } + + public override void WriteJson(JsonWriter writer, Flow value, JsonSerializer serializer) + => writer.WriteValue((double)value); + } +} diff --git a/Common/CommonMessurementUnits/JsonConverters/PressureConverter.cs b/Common/CommonMessurementUnits/JsonConverters/PressureConverter.cs new file mode 100644 index 00000000..ca8eee7b --- /dev/null +++ b/Common/CommonMessurementUnits/JsonConverters/PressureConverter.cs @@ -0,0 +1,27 @@ +namespace CommonMessurementUnits.JsonConverters +{ + using System; + + using Newtonsoft.Json; + + public class PressureConverter : JsonConverter + { + public override Pressure ReadJson(JsonReader reader, Type objectType, Pressure existingValue, bool hasExistingValue, JsonSerializer serializer) + { + while (reader.ValueType != typeof(double)) + { + reader.Read(); + } + + if (reader.Value is double value) + { + return value; + } + + return existingValue; + } + + public override void WriteJson(JsonWriter writer, Pressure value, JsonSerializer serializer) + => writer.WriteValue((double)value); + } +} diff --git a/Common/CommonMessurementUnits/JsonConverters/TemperatureConverter.cs b/Common/CommonMessurementUnits/JsonConverters/TemperatureConverter.cs new file mode 100644 index 00000000..2d8e9214 --- /dev/null +++ b/Common/CommonMessurementUnits/JsonConverters/TemperatureConverter.cs @@ -0,0 +1,27 @@ +namespace CommonMessurementUnits.JsonConverters +{ + using Newtonsoft.Json; + + using System; + + public class TemperatureConverter : JsonConverter + { + public override Temperature ReadJson(JsonReader reader, Type objectType, Temperature existingValue, bool hasExistingValue, JsonSerializer serializer) + { + while (reader.ValueType != typeof(double)) + { + reader.Read(); + } + + if (reader.Value is double value) + { + return value; + } + + return existingValue; + } + + public override void WriteJson(JsonWriter writer, Temperature value, JsonSerializer serializer) + => writer.WriteValue((double)value); + } +} diff --git a/Common/CommonMessurementUnits/JsonConverters/TimeConverter.cs b/Common/CommonMessurementUnits/JsonConverters/TimeConverter.cs new file mode 100644 index 00000000..b611a985 --- /dev/null +++ b/Common/CommonMessurementUnits/JsonConverters/TimeConverter.cs @@ -0,0 +1,27 @@ +namespace CommonMessurementUnits.JsonConverters +{ + using System; + + using Newtonsoft.Json; + + public class TimeConverter : JsonConverter