diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
index e917b001c2..4d95b67f21 100644
--- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
+++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
@@ -47,6 +47,7 @@ public override string Generate()
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -70,6 +71,7 @@ namespace UnitsNet
/// ");
Writer.W(@$"
+ [DataContract]
public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, ");
if (_quantity.BaseType == "decimal")
{
@@ -82,11 +84,13 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, ");
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = ""Value"", Order = 0)]
private readonly {_quantity.BaseType} _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = ""Unit"", Order = 1)]
private readonly {_unitEnumName}? _unit;
");
GenerateStaticConstructor();
diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs
new file mode 100644
index 0000000000..022b82f6ba
--- /dev/null
+++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs
@@ -0,0 +1,218 @@
+using System.Globalization;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Json;
+using UnitsNet.Units;
+using Xunit;
+
+namespace UnitsNet.Tests.Serialization.Json
+{
+ ///
+ /// These tests demonstrate the default behavior of the DataContractJsonSerializer when dealing with quantities
+ ///
+ /// Note that the produced schema is different from the one generated using the UnitsNet.Json package
+ ///
+ /// The default schema can easily be modified using a converter, a.k.a. DataContractSurrogate (.NET Framework)
+ ///
+ ///
+ ///
+ public class DefaultDataContractJsonSerializerTests : SerializationTestsBase
+ {
+ protected override string SerializeObject(object obj)
+ {
+ var serializer = new DataContractJsonSerializer(obj.GetType());
+ using var stream = new MemoryStream();
+ serializer.WriteObject(stream, obj);
+ stream.Position = 0;
+ using var streamReader = new StreamReader(stream);
+ return streamReader.ReadToEnd();
+ }
+
+ protected override T DeserializeObject(string xml)
+ {
+ var serializer = new DataContractJsonSerializer(typeof(T));
+ using var stream = new MemoryStream();
+ using var writer = new StreamWriter(stream);
+ writer.Write(xml);
+ writer.Flush();
+ stream.Position = 0;
+ return (T)serializer.ReadObject(stream);
+ }
+
+ [Fact]
+ public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit()
+ {
+ var quantity = new Mass(1.20, MassUnit.Milligram);
+ var expectedJson = "{\"Value\":1.2,\"Unit\":16}";
+
+ var json = SerializeObject(quantity);
+
+ Assert.Equal(expectedJson, json);
+ }
+
+ [Fact]
+ public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit()
+ {
+ var quantity = new Information(1.20m, InformationUnit.Exabyte);
+ var expectedJson = "{\"Value\":1.20,\"Unit\":4}";
+
+ var json = SerializeObject(quantity);
+
+ Assert.Equal(expectedJson, json);
+ }
+
+ [Fact]
+ public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit()
+ {
+ var quantity = new Mass(1E+9, MassUnit.Milligram);
+ var expectedJson = "{\"Value\":1000000000,\"Unit\":16}";
+
+ var json = SerializeObject(quantity);
+
+ Assert.Equal(expectedJson, json);
+ }
+
+ [Fact]
+ public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit()
+ {
+ var quantity = new Information(1E+9m, InformationUnit.Exabyte);
+ var expectedJson = "{\"Value\":1000000000,\"Unit\":4}";
+
+ var json = SerializeObject(quantity);
+
+ Assert.Equal(expectedJson, json);
+ }
+
+ [Fact]
+ public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit()
+ {
+ var json = "{\"Value\":1.2,\"Unit\":16}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.2, quantity.Value);
+ Assert.Equal(MassUnit.Milligram, quantity.Unit);
+ }
+
+ [Fact]
+ public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit()
+ {
+ var json = "{\"Value\":\"1.2\",\"Unit\":16}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.2, quantity.Value);
+ Assert.Equal(MassUnit.Milligram, quantity.Unit);
+ }
+
+ [Fact]
+ public void DoubleZeroQuantity_DeserializedFromIntegerUnitAndNoValue()
+ {
+ var json = "{\"Unit\":16}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(0, quantity.Value);
+ Assert.Equal(MassUnit.Milligram, quantity.Unit);
+ }
+
+ [Fact]
+ public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit()
+ {
+ var json = "{\"Value\":1.2}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.2, quantity.Value);
+ Assert.Equal(Mass.BaseUnit, quantity.Unit);
+ }
+
+ [Fact]
+ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput()
+ {
+ var json = "{}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(0, quantity.Value);
+ Assert.Equal(Mass.BaseUnit, quantity.Unit);
+ }
+
+ [Fact]
+ public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit()
+ {
+ var json = "{\"Value\":1.200,\"Unit\":4}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.200m, quantity.Value);
+ Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
+ }
+
+ [Fact]
+ public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndIntegerUnit()
+ {
+ var json = "{\"Value\":\"1.200\",\"Unit\":4}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.200m, quantity.Value);
+ Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
+ }
+
+ [Fact]
+ public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue()
+ {
+ var json = "{\"Unit\":4}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(0, quantity.Value);
+ Assert.Equal(InformationUnit.Exabyte, quantity.Unit);
+ }
+
+ [Fact]
+ public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit()
+ {
+ var json = "{\"Value\":1.200}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(1.200m, quantity.Value);
+ Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture));
+ Assert.Equal(Information.BaseUnit, quantity.Unit);
+ }
+
+ [Fact]
+ public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput()
+ {
+ var json = "{}";
+
+ var quantity = DeserializeObject(json);
+
+ Assert.Equal(0, quantity.Value);
+ Assert.Equal(Information.BaseUnit, quantity.Unit);
+ }
+
+ [Fact]
+ public void InterfaceObject_IncludesTypeInformation()
+ {
+ var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) };
+ var expectedJson = "{\"Quantity\":{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":4}}";
+
+ var json = SerializeObject(testObject);
+
+ Assert.Equal(expectedJson, json);
+ }
+
+ [Fact]
+ public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationException()
+ {
+ var testObject = new TestInterfaceObject { Quantity = new Volume(1.2, VolumeUnit.Microliter) };
+
+ Assert.Throws(() => SerializeObject(testObject));
+ }
+ }
+}
diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs
new file mode 100644
index 0000000000..d2a4f6d6b8
--- /dev/null
+++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs
@@ -0,0 +1,329 @@
+// Licensed under MIT No Attribution, see LICENSE file at the root.
+// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Runtime.Serialization;
+using UnitsNet.Units;
+using Xunit;
+
+namespace UnitsNet.Tests.Serialization
+{
+ ///
+ /// A set of serialization/deserialization tests that can be used by for testing the capabilities of different
+ /// serializers / schemas.
+ ///
+ ///
+ /// Note that some of the tests are marked as virtual: you can [Skip] them in the derived class, in case the given
+ /// capabilities are not supported.
+ ///
+ ///
+ /// The type of payload (typically string) that is the expected result of the serialization
+ /// process.
+ ///
+ public abstract class SerializationTestsBase
+ {
+ protected abstract TPayload SerializeObject(object obj);
+ protected abstract T DeserializeObject(TPayload payload);
+
+ [Theory]
+ [InlineData(1.0)]
+ [InlineData(0)]
+ [InlineData(-1.0)]
+ [InlineData(1E+36)]
+ [InlineData(1E-36)]
+ [InlineData(-1E+36)]
+ public void DoubleValueQuantity_SerializationRoundTrips(double value)
+ {
+ var quantity = new Mass(value, MassUnit.Milligram);
+
+ var payload = SerializeObject(quantity);
+ var result = DeserializeObject(payload);
+
+ Assert.Equal(quantity.Unit, result.Unit);
+ Assert.Equal(quantity.Value, result.Value);
+ Assert.Equal(quantity, result);
+ }
+
+ [Fact]
+ public void DecimalValueQuantity_SerializationRoundTrips()
+ {
+ var quantity = Information.FromExabytes(1.200m);
+
+ var payload = SerializeObject(quantity);
+ var result = DeserializeObject(payload);
+
+ Assert.Equal(quantity.Unit, result.Unit);
+ Assert.Equal(quantity.Value, result.Value);
+ Assert.Equal(quantity, result);
+ Assert.Equal("1.200", result.Value.ToString(CultureInfo.InvariantCulture));
+ }
+
+ [Fact]
+ public void LargeDecimalValueQuantity_SerializationRoundTrips()
+ {
+ var quantity = Information.FromExabytes(1E+24);
+
+ var payload = SerializeObject(quantity);
+ var result = DeserializeObject(payload);
+
+ Assert.Equal(quantity, result);
+ }
+
+ [Fact]
+ public void ArrayOfDoubleValueQuantities_SerializationRoundTrips()
+ {
+ var quantities = new[] { new Mass(1.2, MassUnit.Milligram), new Mass(2, MassUnit.Gram) };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject(payload);
+
+ Assert.Collection(results, result =>
+ {
+ Assert.Equal(quantities[0].Unit, result.Unit);
+ Assert.Equal(quantities[0].Value, result.Value);
+ Assert.Equal(quantities[0], result);
+ }, result =>
+ {
+ Assert.Equal(quantities[1].Unit, result.Unit);
+ Assert.Equal(quantities[1].Value, result.Value);
+ Assert.Equal(quantities[1], result);
+ });
+ }
+
+ [Fact]
+ public void ArrayOfDecimalValueQuantities_SerializationRoundTrips()
+ {
+ var quantities = new[] { new Information(1.2m, InformationUnit.Exabit), new Information(2, InformationUnit.Exabyte) };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject(payload);
+
+ Assert.Collection(results, result =>
+ {
+ Assert.Equal(quantities[0].Unit, result.Unit);
+ Assert.Equal(quantities[0].Value, result.Value);
+ Assert.Equal(quantities[0], result);
+ }, result =>
+ {
+ Assert.Equal(quantities[1].Unit, result.Unit);
+ Assert.Equal(quantities[1].Value, result.Value);
+ Assert.Equal(quantities[1], result);
+ });
+ }
+
+ [Fact]
+ public void EmptyArray_RoundTripsEmpty()
+ {
+ var payload = SerializeObject(Array.Empty());
+
+ var result = DeserializeObject(payload);
+
+ Assert.Empty(result);
+ }
+
+ [Fact]
+ public virtual void EnumerableOfDoubleValueQuantities_SerializationRoundTrips()
+ {
+ var firstQuantity = new Mass(1.2, MassUnit.Milligram);
+ var secondQuantity = new Mass(2, MassUnit.Gram);
+ var quantities = new List { firstQuantity, secondQuantity };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Collection(results, result =>
+ {
+ Assert.Equal(firstQuantity.Unit, result.Unit);
+ Assert.Equal(firstQuantity.Value, result.Value);
+ Assert.Equal(firstQuantity, result);
+ }, result =>
+ {
+ Assert.Equal(secondQuantity.Unit, result.Unit);
+ Assert.Equal(secondQuantity.Value, result.Value);
+ Assert.Equal(secondQuantity, result);
+ });
+ }
+
+ [Fact]
+ public virtual void EnumerableOfDecimalValueQuantities_SerializationRoundTrips()
+ {
+ var firstQuantity = new Information(1.2m, InformationUnit.Exabit);
+ var secondQuantity = new Information(2, InformationUnit.Exabyte);
+ var quantities = new List { firstQuantity, secondQuantity };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Collection(results, result =>
+ {
+ Assert.Equal(firstQuantity.Unit, result.Unit);
+ Assert.Equal(firstQuantity.Value, result.Value);
+ Assert.Equal(firstQuantity, result);
+ }, result =>
+ {
+ Assert.Equal(secondQuantity.Unit, result.Unit);
+ Assert.Equal(secondQuantity.Value, result.Value);
+ Assert.Equal(secondQuantity, result);
+ });
+ }
+
+ [Fact]
+ public virtual void TupleOfMixedValueQuantities_SerializationRoundTrips()
+ {
+ var quantities = new Tuple(new Mass(1.2, MassUnit.Milligram), new Information(2, InformationUnit.Exabyte));
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Equal(quantities.Item1.Unit, results.Item1.Unit);
+ Assert.Equal(quantities.Item1.Value, results.Item1.Value);
+ Assert.Equal(quantities.Item1, results.Item1);
+ Assert.Equal(quantities.Item2.Unit, results.Item2.Unit);
+ Assert.Equal(quantities.Item2.Value, results.Item2.Value);
+ Assert.Equal(quantities.Item2, results.Item2);
+ }
+
+ [Fact]
+ [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
+ public virtual void TupleOfDoubleAndNullQuantities_SerializationRoundTrips()
+ {
+ var quantity = new Mass(1.2, MassUnit.Milligram);
+ var quantities = new Tuple(quantity, null);
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Equal(quantity.Unit, results.Item1.Value.Unit);
+ Assert.Equal(quantity.Value, results.Item1.Value.Value);
+ Assert.Equal(quantity, results.Item1);
+ Assert.Null(results.Item2);
+ }
+
+ [Fact]
+ [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
+ public virtual void TupleOfDecimalAndNullQuantities_SerializationRoundTrips()
+ {
+ var quantity = new Information(2, InformationUnit.Exabyte);
+ var quantities = new Tuple(null, quantity);
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Null(results.Item1);
+ Assert.Equal(quantity.Unit, results.Item2.Value.Unit);
+ Assert.Equal(quantity.Value, results.Item2.Value.Value);
+ Assert.Equal(quantity, results.Item2);
+ }
+
+ [Fact]
+ public void ClassOfDoubleAndNullUnits_SerializationRoundTrips()
+ {
+ var quantity = new Mass(1.2, MassUnit.Milligram);
+ var quantities = new TestObject { Quantity = quantity, NullableQuantity = null };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Equal(quantity.Unit, results.Quantity.Unit);
+ Assert.Equal(quantity.Value, results.Quantity.Value);
+ Assert.Equal(quantity, results.Quantity);
+ Assert.Null(results.NullableQuantity);
+ }
+
+ [Fact]
+ public void ClassOfDecimalAndNullUnits_SerializationRoundTrips()
+ {
+ var quantity = new Information(2, InformationUnit.Exabyte);
+ var quantities = new TestObject { Quantity = quantity, NullableQuantity = null };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Equal(quantity.Unit, results.Quantity.Unit);
+ Assert.Equal(quantity.Value, results.Quantity.Value);
+ Assert.Equal(quantity, results.Quantity);
+ Assert.Null(results.NullableQuantity);
+ }
+
+ [Fact]
+ [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
+ public void ClassOfMixedValueQuantities_SerializationRoundTrips()
+ {
+ var doubleQuantity = new Mass(1.2, MassUnit.Milligram);
+ var decimalQuantity = new Information(2, InformationUnit.Exabyte);
+ var quantities = new TestObject
+ {
+ Quantity = doubleQuantity, NullableQuantity = doubleQuantity, DecimalQuantity = decimalQuantity
+ };
+
+ var payload = SerializeObject(quantities);
+ var results = DeserializeObject>(payload);
+
+ Assert.Equal(doubleQuantity.Unit, results.Quantity.Unit);
+ Assert.Equal(doubleQuantity.Value, results.Quantity.Value);
+ Assert.Equal(doubleQuantity, results.Quantity);
+ Assert.Equal(doubleQuantity.Unit, results.NullableQuantity.Value.Unit);
+ Assert.Equal(doubleQuantity.Value, results.NullableQuantity.Value.Value);
+ Assert.Equal(doubleQuantity, results.NullableQuantity);
+ Assert.Equal(decimalQuantity.Unit, results.DecimalQuantity.Unit);
+ Assert.Equal(decimalQuantity.Value, results.DecimalQuantity.Value);
+ Assert.Equal(decimalQuantity, results.DecimalQuantity);
+ Assert.Null(results.NullableDecimalQuantity);
+ }
+
+ [Fact]
+ public void ClassOfInterfaceQuantity_SerializationRoundTrips()
+ {
+ var quantity = new Mass(1.2, MassUnit.Milligram);
+ var quantityObject = new TestInterfaceObject { Quantity = quantity };
+
+ var payload = SerializeObject(quantityObject);
+ var result = DeserializeObject(payload);
+
+ Assert.Equal(quantity.Unit, result.Quantity.Unit);
+ Assert.Equal(quantity.Value, result.Quantity.Value);
+ Assert.Equal(quantity, result.Quantity);
+ }
+
+ [Fact]
+ public void ClassOfInterfaceDecimalQuantity_SerializationRoundTrips()
+ {
+ var quantity = new Information(2, InformationUnit.Exabyte);
+ var quantityObject = new TestInterfaceObject { Quantity = quantity };
+
+ var payload = SerializeObject(quantityObject);
+ var result = DeserializeObject(payload);
+
+ Assert.Equal(quantity.Unit, result.Quantity.Unit);
+ Assert.Equal(quantity.Value, ((IDecimalQuantity)result.Quantity).Value);
+ Assert.Equal(quantity, result.Quantity);
+ Assert.Equal("2", ((IDecimalQuantity)result.Quantity).Value.ToString(CultureInfo.InvariantCulture));
+ }
+
+ [DataContract]
+ protected class TestObject
+ where TQuantity : struct, IQuantity
+ {
+ [DataMember]
+ public TQuantity Quantity { get; set; }
+
+ [DataMember]
+ public TQuantity? NullableQuantity { get; set; }
+ }
+
+ [DataContract]
+ protected class TestObject : TestObject
+ where TDoubleQuantity : struct, IQuantity
+ where TDecimalQuantity : struct, IQuantity, IDecimalQuantity
+ {
+ [DataMember]
+ public TDecimalQuantity DecimalQuantity { get; set; }
+
+ [DataMember]
+ public TDecimalQuantity? NullableDecimalQuantity { get; set; }
+ }
+ }
+}
diff --git a/UnitsNet.Tests/Serialization/TestInterfaceObject.cs b/UnitsNet.Tests/Serialization/TestInterfaceObject.cs
new file mode 100644
index 0000000000..52c9c85b54
--- /dev/null
+++ b/UnitsNet.Tests/Serialization/TestInterfaceObject.cs
@@ -0,0 +1,24 @@
+// Licensed under MIT No Attribution, see LICENSE file at the root.
+// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
+
+using System.Runtime.Serialization;
+
+namespace UnitsNet.Tests.Serialization
+{
+ ///
+ /// A test object used for testing the serialization schema to and from an object containing a generic quantity
+ /// (see ).
+ ///
+ /// The [KnownAttributes] are required for the DataContractSerializers. You could also provide those to the
+ /// serializer settings: e.g. KnownTypes = Quantity.Infos.Select(x => x.ValueType)
+ ///
+ ///
+ [DataContract]
+ [KnownType(typeof(Mass))]
+ [KnownType(typeof(Information))]
+ public class TestInterfaceObject
+ {
+ [DataMember]
+ public IQuantity Quantity { get; set; }
+ }
+}
diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs
new file mode 100644
index 0000000000..4e8b7fb860
--- /dev/null
+++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs
@@ -0,0 +1,104 @@
+using System.IO;
+using System.Runtime.Serialization;
+using UnitsNet.Units;
+using Xunit;
+
+namespace UnitsNet.Tests.Serialization.Xml
+{
+ ///
+ /// These tests demonstrate the behavior of the DataContractSerializer (the default WCF serializer) when dealing with
+ /// quantities
+ ///
+ public class DataContractSerializerTests : SerializationTestsBase
+ {
+ private const string XmlSchema = "xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"";
+ private const string Namespace = "xmlns=\"http://schemas.datacontract.org/2004/07/UnitsNet\"";
+
+ protected override string SerializeObject(object obj)
+ {
+ var serializer = new DataContractSerializer(obj.GetType());
+ using var stream = new MemoryStream();
+ serializer.WriteObject(stream, obj);
+ stream.Position = 0;
+ using var streamReader = new StreamReader(stream);
+ return streamReader.ReadToEnd();
+ }
+
+ protected override T DeserializeObject(string xml)
+ {
+ var serializer = new DataContractSerializer(typeof(T));
+ using var stream = new MemoryStream();
+ using var writer = new StreamWriter(stream);
+ writer.Write(xml);
+ writer.Flush();
+ stream.Position = 0;
+ return (T)serializer.ReadObject(stream);
+ }
+
+ [Fact]
+ public void DoubleQuantity_SerializedWithValueAndMemberName()
+ {
+ var quantity = new Mass(1.20, MassUnit.Milligram);
+ var expectedXml = $"1.2Milligram";
+
+ var xml = SerializeObject(quantity);
+
+ Assert.Equal(expectedXml, xml);
+ }
+
+ [Fact]
+ public void DecimalQuantity_SerializedWithValueAndMemberName()
+ {
+ var quantity = new Information(1.20m, InformationUnit.Exabyte);
+ var expectedXml = $"1.20Exabyte";
+
+ var xml = SerializeObject(quantity);
+
+ Assert.Equal(expectedXml, xml);
+ }
+
+ [Fact]
+ public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndMemberName()
+ {
+ var quantity = new Mass(1E+9, MassUnit.Milligram);
+ var expectedXml = $"1000000000Milligram";
+
+ var xml = SerializeObject(quantity);
+
+ Assert.Equal(expectedXml, xml);
+ }
+
+ [Fact]
+ public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndMemberName()
+ {
+ var quantity = new Information(1E+9m, InformationUnit.Exabyte);
+ var expectedXml = $"1000000000Exabyte";
+
+ var xml = SerializeObject(quantity);
+
+ Assert.Equal(expectedXml, xml);
+ }
+
+ [Fact]
+ public void InterfaceObject_IncludesTypeInformation()
+ {
+ var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) };
+
+ var quantityNamespace = "xmlns:a=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; // there is an extra 'a' compared to Namespace
+ var expectedQuantityXml = $"1.20Exabyte";
+ var expectedXml = $"{expectedQuantityXml}";
+
+ var xml = SerializeObject(testObject);
+
+ Assert.Equal(expectedXml, xml);
+ }
+
+ [Fact]
+ public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationException()
+ {
+ var testObject = new TestInterfaceObject { Quantity = new Volume(1.2, VolumeUnit.Microliter) };
+
+ Assert.Throws(() => SerializeObject(testObject));
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
index d96ba48954..129787880a 100644
--- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration.
///
+ [DataContract]
public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AccelerationUnit? _unit;
static Acceleration()
diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
index 724c357513..a4c975d355 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals.
///
+ [DataContract]
public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AmountOfSubstanceUnit? _unit;
static AmountOfSubstance()
diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
index e0e94d123e..f4478bfd0d 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The strength of a signal expressed in decibels (dB) relative to one volt RMS.
///
+ [DataContract]
public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AmplitudeRatioUnit? _unit;
static AmplitudeRatio()
diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
index bf1c61fe2c..7025d49b06 100644
--- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.
///
+ [DataContract]
public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AngleUnit? _unit;
static Angle()
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
index 3a960cee4e..5c8f074761 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.
///
+ [DataContract]
public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ApparentEnergyUnit? _unit;
static ApparentEnergy()
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
index 6e94ff6b94..69009aed33 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.
///
+ [DataContract]
public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ApparentPowerUnit? _unit;
static ApparentPower()
diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
index 5f53c939f5..0e03c9a519 100644
--- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).
///
+ [DataContract]
public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AreaUnit? _unit;
static Area()
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
index 2470b67992..e52b05bf88 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The area density of a two-dimensional object is calculated as the mass per unit area.
///
+ [DataContract]
public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AreaDensityUnit? _unit;
static AreaDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
index 4e6a90268f..35752e8a18 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// A geometric property of an area that reflects how its points are distributed with regard to an axis.
///
+ [DataContract]
public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly AreaMomentOfInertiaUnit? _unit;
static AreaMomentOfInertia()
diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
index f095c886bc..8215bf3120 100644
--- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Bit_rate
///
+ [DataContract]
public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly decimal _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly BitRateUnit? _unit;
static BitRate()
diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
index e886171482..1db65ccd26 100644
--- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.
///
+ [DataContract]
public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly BrakeSpecificFuelConsumptionUnit? _unit;
static BrakeSpecificFuelConsumption()
diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
index 900fc72c5a..cc2bf58663 100644
--- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Capacitance
///
+ [DataContract]
public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly CapacitanceUnit? _unit;
static Capacitance()
diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
index 5921fd4154..cae873cd13 100644
--- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// A unit that represents a fractional change in size in response to a change in temperature.
///
+ [DataContract]
public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly CoefficientOfThermalExpansionUnit? _unit;
static CoefficientOfThermalExpansion()
diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
index 7e3d665f42..11b60bd3d2 100644
--- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// http://en.wikipedia.org/wiki/Density
///
+ [DataContract]
public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly DensityUnit? _unit;
static Density()
diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
index ce070f180b..770ac80d28 100644
--- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.
///
+ [DataContract]
public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly DurationUnit? _unit;
static Duration()
diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
index 2c6dc99958..54c0078e3b 100644
--- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity
///
+ [DataContract]
public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly DynamicViscosityUnit? _unit;
static DynamicViscosity()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
index 40811df6a0..24a5702c8c 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).
///
+ [DataContract]
public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricAdmittanceUnit? _unit;
static ElectricAdmittance()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
index f84af5c987..ab9d21afbb 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Electric_charge
///
+ [DataContract]
public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricChargeUnit? _unit;
static ElectricCharge()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
index 4c4c330d03..5be23b40c2 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Charge_density
///
+ [DataContract]
public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricChargeDensityUnit? _unit;
static ElectricChargeDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
index 9746739918..2e3908e2bb 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance
///
+ [DataContract]
public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricConductanceUnit? _unit;
static ElectricConductance()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
index c5ccd4fabf..510d8cf461 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity
///
+ [DataContract]
public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricConductivityUnit? _unit;
static ElectricConductivity()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
index 489946c5d4..b799cadf1d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma.
///
+ [DataContract]
public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricCurrentUnit? _unit;
static ElectricCurrent()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
index e5e8a16d78..04728cb1e4 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Current_density
///
+ [DataContract]
public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricCurrentDensityUnit? _unit;
static ElectricCurrentDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
index c8c6404315..4fec12a674 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In electromagnetism, the current gradient describes how the current changes in time.
///
+ [DataContract]
public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricCurrentGradientUnit? _unit;
static ElectricCurrentGradient()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
index 787e656472..8f1dc443e9 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Electric_field
///
+ [DataContract]
public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricFieldUnit? _unit;
static ElectricField()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
index 5dbc94dde8..c033bd06d4 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Inductance
///
+ [DataContract]
public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricInductanceUnit? _unit;
static ElectricInductance()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
index afddfa4793..3afcdacee7 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.
///
+ [DataContract]
public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricPotentialUnit? _unit;
static ElectricPotential()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
index e46cde659e..312b9f4968 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The Electric Potential of a system known to use Alternating Current.
///
+ [DataContract]
public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricPotentialAcUnit? _unit;
static ElectricPotentialAc()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
index 0a46b8907d..703973f8d7 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).
///
+ [DataContract]
public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricPotentialChangeRateUnit? _unit;
static ElectricPotentialChangeRate()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
index 829247918e..f46630a1ec 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The Electric Potential of a system known to use Direct Current.
///
+ [DataContract]
public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricPotentialDcUnit? _unit;
static ElectricPotentialDc()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
index 1faedf39f1..07f4137d6a 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.
///
+ [DataContract]
public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricResistanceUnit? _unit;
static ElectricResistance()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
index 4fa7ea828a..bb3c7e0ea5 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity
///
+ [DataContract]
public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricResistivityUnit? _unit;
static ElectricResistivity()
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
index a454e2f803..418979c96b 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Charge_density
///
+ [DataContract]
public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ElectricSurfaceChargeDensityUnit? _unit;
static ElectricSurfaceChargeDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
index 79826650e4..b19927be1e 100644
--- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used.
///
+ [DataContract]
public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly EnergyUnit? _unit;
static Energy()
diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
index 758d3c5761..f1a32e356d 100644
--- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units
///
+ [DataContract]
public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly EntropyUnit? _unit;
static Entropy()
diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
index 6b9d97b52d..54d04e2e3c 100644
--- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F.
///
+ [DataContract]
public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ForceUnit? _unit;
static Force()
diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
index 0416f069cf..86d4c8bbc4 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time).
///
+ [DataContract]
public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ForceChangeRateUnit? _unit;
static ForceChangeRate()
diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
index 7a201e4152..8160031d62 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The magnitude of force per unit length.
///
+ [DataContract]
public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly ForcePerLengthUnit? _unit;
static ForcePerLength()
diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
index b54063b594..b82b7682f2 100644
--- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The number of occurrences of a repeating event per unit time.
///
+ [DataContract]
public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly FrequencyUnit? _unit;
static Frequency()
diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs
index edbd840421..f00c7c8f37 100644
--- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Fuel_efficiency
///
+ [DataContract]
public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly FuelEfficiencyUnit? _unit;
static FuelEfficiency()
diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
index eec138226c..2139a34317 100644
--- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Heat flux is the flow of energy per unit of area per unit of time
///
+ [DataContract]
public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly HeatFluxUnit? _unit;
static HeatFlux()
diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
index f77bb8a38c..a16bc127cb 100644
--- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT)
///
+ [DataContract]
public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly HeatTransferCoefficientUnit? _unit;
static HeatTransferCoefficient()
diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
index debdace3bc..c3b01e15e0 100644
--- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Illuminance
///
+ [DataContract]
public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly IlluminanceUnit? _unit;
static Illuminance()
diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
index 9b00aaf6b8..cf438f74c5 100644
--- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.
///
+ [DataContract]
public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly decimal _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly InformationUnit? _unit;
static Information()
diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
index 8598f660af..ef2e4fae9a 100644
--- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.
///
+ [DataContract]
public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly IrradianceUnit? _unit;
static Irradiance()
diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
index 1bb699d757..a7a5eb6ad7 100644
--- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Irradiation
///
+ [DataContract]
public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly IrradiationUnit? _unit;
static Irradiation()
diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
index ff233cea8e..e49c80cf31 100644
--- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// http://en.wikipedia.org/wiki/Viscosity
///
+ [DataContract]
public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly KinematicViscosityUnit? _unit;
static KinematicViscosity()
diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
index 8ea2f60397..56a9bebf13 100644
--- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.
///
+ [DataContract]
public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LapseRateUnit? _unit;
static LapseRate()
diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs
index dd79f854a1..1f624cab7c 100644
--- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units.
///
+ [DataContract]
public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LengthUnit? _unit;
static Length()
diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs
index df2834c39e..41e28629dc 100644
--- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units.
///
+ [DataContract]
public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LevelUnit? _unit;
static Level()
diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
index 73377c2147..832fa889ee 100644
--- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// http://en.wikipedia.org/wiki/Linear_density
///
+ [DataContract]
public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LinearDensityUnit? _unit;
static LinearDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs
index 300b80acb9..913b09383b 100644
--- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// http://en.wikipedia.org/wiki/Linear_density
///
+ [DataContract]
public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LinearPowerDensityUnit? _unit;
static LinearPowerDensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs
index c7740d576a..7448398ec7 100644
--- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Luminosity
///
+ [DataContract]
public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LuminosityUnit? _unit;
static Luminosity()
diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
index 34be801626..c728d71999 100644
--- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Luminous_flux
///
+ [DataContract]
public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LuminousFluxUnit? _unit;
static LuminousFlux()
diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
index 0888243e6d..cf848bc96c 100644
--- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Luminous_intensity
///
+ [DataContract]
public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly LuminousIntensityUnit? _unit;
static LuminousIntensity()
diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
index b913f8d2ac..a5ee7c2a80 100644
--- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Magnetic_field
///
+ [DataContract]
public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MagneticFieldUnit? _unit;
static MagneticField()
diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
index ba9fc796e6..8787207610 100644
--- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Magnetic_flux
///
+ [DataContract]
public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MagneticFluxUnit? _unit;
static MagneticFlux()
diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
index 71c07739ec..b5771cbab6 100644
--- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Magnetization
///
+ [DataContract]
public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MagnetizationUnit? _unit;
static Magnetization()
diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
index 13d127043a..a6928331a4 100644
--- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg).
///
+ [DataContract]
public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassUnit? _unit;
static Mass()
diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs
index eae3b32dbd..7f4d40bcca 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry)
///
+ [DataContract]
public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassConcentrationUnit? _unit;
static MassConcentration()
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
index 3a7b8a4723..374bbfc3ea 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).
///
+ [DataContract]
public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassFlowUnit? _unit;
static MassFlow()
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
index ab03540660..2751d6a4d8 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Mass flux is the mass flow rate per unit area.
///
+ [DataContract]
public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassFluxUnit? _unit;
static MassFlux()
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs
index d56de12eea..559f282e08 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry)
///
+ [DataContract]
public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassFractionUnit? _unit;
static MassFraction()
diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
index 3ad547f78a..7332ab643b 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// A property of body reflects how its mass is distributed with regard to an axis.
///
+ [DataContract]
public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MassMomentOfInertiaUnit? _unit;
static MassMomentOfInertia()
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
index 8d6e3c571b..fb0076783f 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Molar energy is the amount of energy stored in 1 mole of a substance.
///
+ [DataContract]
public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MolarEnergyUnit? _unit;
static MolarEnergy()
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
index a27b9c4c10..fd570688ef 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.
///
+ [DataContract]
public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MolarEntropyUnit? _unit;
static MolarEntropy()
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
index 6af9df4f30..6b2f8efea1 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -34,16 +35,19 @@ namespace UnitsNet
///
/// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance.
///
+ [DataContract]
public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MolarMassUnit? _unit;
static MolarMass()
diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
index b716ceb069..b6d2a4ceee 100644
--- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Molar_concentration
///
+ [DataContract]
public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly MolarityUnit? _unit;
static Molarity()
diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
index 8734c4895d..7e286f2ce0 100644
--- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Permeability_(electromagnetism)
///
+ [DataContract]
public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///
/// The numeric value this quantity was constructed with.
///
+ [DataMember(Name = "Value", Order = 0)]
private readonly double _value;
///
/// The unit this quantity was constructed with.
///
+ [DataMember(Name = "Unit", Order = 1)]
private readonly PermeabilityUnit? _unit;
static Permeability()
diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
index 76a0c803d3..a3bbbd52d7 100644
--- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
@@ -20,6 +20,7 @@
using System;
using System.Globalization;
using System.Linq;
+using System.Runtime.Serialization;
using JetBrains.Annotations;
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
@@ -37,16 +38,19 @@ namespace UnitsNet
///
/// https://en.wikipedia.org/wiki/Permittivity
///
+ [DataContract]
public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable
{
///