OpenChargeMeteringFormat 0.1.0
See the version list below for details.
dotnet add package OpenChargeMeteringFormat --version 0.1.0
NuGet\Install-Package OpenChargeMeteringFormat -Version 0.1.0
<PackageReference Include="OpenChargeMeteringFormat" Version="0.1.0" />
paket add OpenChargeMeteringFormat --version 0.1.0
#r "nuget: OpenChargeMeteringFormat, 0.1.0"
// Install OpenChargeMeteringFormat as a Cake Addin #addin nuget:?package=OpenChargeMeteringFormat&version=0.1.0 // Install OpenChargeMeteringFormat as a Cake Tool #tool nuget:?package=OpenChargeMeteringFormat&version=0.1.0
OpenChargeMeteringFormat
A .NET implementation of the Open Charge Metering Format (OCMF).
Installation
The package can be found on nuget.org. You can install the package with:
Install-Package OpenChargeMeteringFormat
Usage
There is only one class you should interact with called OpenChargeMeteringFormatParser
.
It provides you with two methods to validate and parse OCMF messages:
var message = "OCMF|{...}|{...}";
// Optional: validate messages before usage
if (!OpenChargeMeteringFormatParser.IsValidMessage(message))
{
Console.WriteLine("Not a valid OCMF message.");
return;
}
// Mandatory: parse messages with implicit validation
var parseResult = OpenChargeMeteringFormatParser.ParseMessage(message);
if (parseResult.IsFailed)
{
Console.WriteLine($"Not a valid OCMF message: {parseResult.Errors.First()?.Message}");
return;
}
Console.WriteLine($"Identification status: {parseResult.Value.Payload.IdentificationStatus}");
Console.WriteLine($"Identification type: {parseResult.Value.Payload.IdentificationType}");
Console.WriteLine($"Identification data: {parseResult.Value.Payload.IdentificationData}");
Results
This library makes use of FluentResults
,
which allows returning a Result<OpenChargeMeteringFormatMessage>
covering both,
the success and the error scenario.
To check for success, use Result<OpenChargeMeteringFormatMessage>.IsSuccess
.
A success result will also contain a valid Result<OpenChargeMeteringFormatMessage>.Value
with the parsed OCMF message as content.
To check for failure, use Result<OpenChargeMeteringFormatMessage>.IsFailed
.
In case of failure, the result may contains errors which can be retrieved using
Result<OpenChargeMeteringFormatMessage>.Errors
. To check for presence of errors,
use Result<OpenChargeMeteringFormatMessage>.Errors.Any()
.
IsSuccess
and IsFailed
are mutually exclusive, i.e. when one is true
, the other is false
.
License
This library is open-sourced software licensed under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- FluentResults (>= 3.5.0)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.