RedStar.Amounts
4.2.0
dotnet add package RedStar.Amounts --version 4.2.0
NuGet\Install-Package RedStar.Amounts -Version 4.2.0
<PackageReference Include="RedStar.Amounts" Version="4.2.0" />
paket add RedStar.Amounts --version 4.2.0
#r "nuget: RedStar.Amounts, 4.2.0"
// Install RedStar.Amounts as a Cake Addin #addin nuget:?package=RedStar.Amounts&version=4.2.0 // Install RedStar.Amounts as a Cake Tool #tool nuget:?package=RedStar.Amounts&version=4.2.0
RedStar.Amounts
This project may seem dormant, but it is mainly due to having reach a stable point. It is still actively being maintained and is safe to use in production applications. If you encounter any issues or need extra features, don't hesitate to create an issue.
RedStar.Amounts contains classes to easily work with unit and amounts.
Too often, applications use integers, doubles, etc. to indicate distances, weights, and other measured values. This can cause problems because assumptions are made on the units, conversions have to be done, etc.
This can cause hard-to-trace bugs and leads to less readable code.
Say you have a public service (WCF, REST, ...) that takes in measurements from an external service. Which of the following do you prefer?
public class SomeService
{
public void ReportMeasurement(double length, double height)
{
// external system sends values in meters, but we work with cm
var lengthInCm = length * 100;
var heightInCm = height * 100;
var area = lengthInCm * heightInCm;
...
}
}
Or this:
public class SomeService
{
public void ReportMeasurement(Amount length, Amount height)
{
var area = length * height;
...
}
}
In the second example, the area
variable will automatically have a value and
a unit. The unit will be m².
This makes it easier and more fail-proof to do calculations later.
Installation
RedStar.Amounts consists of three Nuget packages:
- RedStar.Amounts: the core library
- RedStar.Amounts.StandardUnits: most likely what you need, will include standard units (length, weight, energy, etc)
- RedStar.Amounts.JsonNet: includes custom converters for JSON.NET
Packages are released according to semantic versioning and all latest versions should work together without any problems.
Documentation
You can find the latest documentation here.
.NET versions
This library targets .NET Standard 2.0.
Source, license
This code was taken and built upon from CodeProject. Credit is due to Rudi Breedenraedt. The code is licensed under the CPOL.
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on RedStar.Amounts:
Package | Downloads |
---|---|
RedStar.Amounts.StandardUnits
Standard units to use with the RedStar.Amounts package. These contain units that are part of the International System of Units (or SI, from the French Système Internationale). |
|
RedStar.Amounts.JsonNet
Custom converters for serializing and deseriazling RedStar.Amounts types to JSON using NewtonSoft's JSON.NET library. |
GitHub repositories
This package is not used by any popular GitHub repositories.