diff --git a/UnitsNet.Tests/CustomCode/IrradiationTests.cs b/UnitsNet.Tests/CustomCode/IrradiationTests.cs
new file mode 100644
index 0000000000..a4f3a59497
--- /dev/null
+++ b/UnitsNet.Tests/CustomCode/IrradiationTests.cs
@@ -0,0 +1,55 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated (once) by \generate-code.bat, but will not be
+// regenerated when it already exists. The purpose of creating this file is to make
+// it easier to remember to implement all the unit conversion test cases.
+//
+// Whenever a new unit is added to this quantity and \generate-code.bat is run,
+// the base test class will get a new abstract property and cause a compile error
+// in this derived class, reminding the developer to implement the test case
+// for the new unit.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+using System;
+
+namespace UnitsNet.Tests.CustomCode
+{
+ public class IrradiationTests : IrradiationTestsBase
+ {
+ protected override double JoulesPerSquareMeterInOneJoulePerSquareMeter => 1;
+
+ protected override double WattHoursPerSquareMeterInOneJoulePerSquareMeter => 2.78E-04;
+
+ protected override double KilowattHoursPerSquareMeterInOneJoulePerSquareMeter => 2.78E-07;
+ }
+}
diff --git a/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs
new file mode 100644
index 0000000000..9f6aa3c7fc
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs
@@ -0,0 +1,191 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by \generate-code.bat.
+//
+// Changes to this file will be lost when the code is regenerated.
+// The build server regenerates the code before each build and a pre-build
+// step will regenerate the code on each local build.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using UnitsNet.Units;
+using Xunit;
+
+// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else?
+#pragma warning disable 1718
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Tests
+{
+ ///
+ /// Test of Irradiation.
+ ///
+// ReSharper disable once PartialTypeWithSinglePart
+ public abstract partial class IrradiationTestsBase
+ {
+ protected abstract double JoulesPerSquareMeterInOneJoulePerSquareMeter { get; }
+ protected abstract double KilowattHoursPerSquareMeterInOneJoulePerSquareMeter { get; }
+ protected abstract double WattHoursPerSquareMeterInOneJoulePerSquareMeter { get; }
+
+// ReSharper disable VirtualMemberNeverOverriden.Global
+ protected virtual double JoulesPerSquareMeterTolerance { get { return 1e-5; } }
+ protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1e-5; } }
+ protected virtual double WattHoursPerSquareMeterTolerance { get { return 1e-5; } }
+// ReSharper restore VirtualMemberNeverOverriden.Global
+
+ [Fact]
+ public void JoulePerSquareMeterToIrradiationUnits()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(WattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.WattHoursPerSquareMeter, WattHoursPerSquareMeterTolerance);
+ }
+
+ [Fact]
+ public void FromValueAndUnit()
+ {
+ AssertEx.EqualTolerance(1, Irradiation.From(1, IrradiationUnit.JoulePerSquareMeter).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(1, Irradiation.From(1, IrradiationUnit.KilowattHourPerSquareMeter).KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(1, Irradiation.From(1, IrradiationUnit.WattHourPerSquareMeter).WattHoursPerSquareMeter, WattHoursPerSquareMeterTolerance);
+ }
+
+ [Fact]
+ public void As()
+ {
+ var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareMeter), JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.KilowattHourPerSquareMeter), KilowattHoursPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(WattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.WattHourPerSquareMeter), WattHoursPerSquareMeterTolerance);
+ }
+
+ [Fact]
+ public void ConversionRoundTrip()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMeter(joulepersquaremeter.JoulesPerSquareMeter).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(1, Irradiation.FromKilowattHoursPerSquareMeter(joulepersquaremeter.KilowattHoursPerSquareMeter).JoulesPerSquareMeter, KilowattHoursPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(1, Irradiation.FromWattHoursPerSquareMeter(joulepersquaremeter.WattHoursPerSquareMeter).JoulesPerSquareMeter, WattHoursPerSquareMeterTolerance);
+ }
+
+ [Fact]
+ public void ArithmeticOperators()
+ {
+ Irradiation v = Irradiation.FromJoulesPerSquareMeter(1);
+ AssertEx.EqualTolerance(-1, -v.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(3)-v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(2, (v + v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(10, (v*10).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(10, (10*v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(10)/5).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance);
+ AssertEx.EqualTolerance(2, Irradiation.FromJoulesPerSquareMeter(10)/Irradiation.FromJoulesPerSquareMeter(5), JoulesPerSquareMeterTolerance);
+ }
+
+ [Fact]
+ public void ComparisonOperators()
+ {
+ Irradiation oneJoulePerSquareMeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Irradiation twoJoulesPerSquareMeter = Irradiation.FromJoulesPerSquareMeter(2);
+
+ Assert.True(oneJoulePerSquareMeter < twoJoulesPerSquareMeter);
+ Assert.True(oneJoulePerSquareMeter <= twoJoulesPerSquareMeter);
+ Assert.True(twoJoulesPerSquareMeter > oneJoulePerSquareMeter);
+ Assert.True(twoJoulesPerSquareMeter >= oneJoulePerSquareMeter);
+
+ Assert.False(oneJoulePerSquareMeter > twoJoulesPerSquareMeter);
+ Assert.False(oneJoulePerSquareMeter >= twoJoulesPerSquareMeter);
+ Assert.False(twoJoulesPerSquareMeter < oneJoulePerSquareMeter);
+ Assert.False(twoJoulesPerSquareMeter <= oneJoulePerSquareMeter);
+ }
+
+ [Fact]
+ public void CompareToIsImplemented()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.Equal(0, joulepersquaremeter.CompareTo(joulepersquaremeter));
+ Assert.True(joulepersquaremeter.CompareTo(Irradiation.Zero) > 0);
+ Assert.True(Irradiation.Zero.CompareTo(joulepersquaremeter) < 0);
+ }
+
+ [Fact]
+ public void CompareToThrowsOnTypeMismatch()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.Throws(() => joulepersquaremeter.CompareTo(new object()));
+ }
+
+ [Fact]
+ public void CompareToThrowsOnNull()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.Throws(() => joulepersquaremeter.CompareTo(null));
+ }
+
+
+ [Fact]
+ public void EqualityOperators()
+ {
+ Irradiation a = Irradiation.FromJoulesPerSquareMeter(1);
+ Irradiation b = Irradiation.FromJoulesPerSquareMeter(2);
+
+// ReSharper disable EqualExpressionComparison
+ Assert.True(a == a);
+ Assert.True(a != b);
+
+ Assert.False(a == b);
+ Assert.False(a != a);
+// ReSharper restore EqualExpressionComparison
+ }
+
+ [Fact]
+ public void EqualsIsImplemented()
+ {
+ Irradiation v = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.True(v.Equals(Irradiation.FromJoulesPerSquareMeter(1), Irradiation.FromJoulesPerSquareMeter(JoulesPerSquareMeterTolerance)));
+ Assert.False(v.Equals(Irradiation.Zero, Irradiation.FromJoulesPerSquareMeter(JoulesPerSquareMeterTolerance)));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnTypeMismatch()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.False(joulepersquaremeter.Equals(new object()));
+ }
+
+ [Fact]
+ public void EqualsReturnsFalseOnNull()
+ {
+ Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+ Assert.False(joulepersquaremeter.Equals(null));
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/Extensions/Number/NumberToIrradiationExtensions.g.cs b/UnitsNet/GeneratedCode/Extensions/Number/NumberToIrradiationExtensions.g.cs
new file mode 100644
index 0000000000..fc4b25ddba
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Extensions/Number/NumberToIrradiationExtensions.g.cs
@@ -0,0 +1,151 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by \generate-code.bat.
+//
+// Changes to this file will be lost when the code is regenerated.
+// The build server regenerates the code before each build and a pre-build
+// step will regenerate the code on each local build.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+// Windows Runtime Component does not support extension methods and method overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+namespace UnitsNet.Extensions.NumberToIrradiation
+{
+ public static class NumberToIrradiationExtensions
+ {
+ #region JoulePerSquareMeter
+
+ ///
+ public static Irradiation JoulesPerSquareMeter(this int value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation? JoulesPerSquareMeter(this int? value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation JoulesPerSquareMeter(this long value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation? JoulesPerSquareMeter(this long? value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation JoulesPerSquareMeter(this double value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation? JoulesPerSquareMeter(this double? value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation JoulesPerSquareMeter(this float value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation? JoulesPerSquareMeter(this float? value) => Irradiation.FromJoulesPerSquareMeter(value);
+
+ ///
+ public static Irradiation JoulesPerSquareMeter(this decimal value) => Irradiation.FromJoulesPerSquareMeter(Convert.ToDouble(value));
+
+ ///
+ public static Irradiation? JoulesPerSquareMeter(this decimal? value) => Irradiation.FromJoulesPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region KilowattHourPerSquareMeter
+
+ ///
+ public static Irradiation KilowattHoursPerSquareMeter(this int value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? KilowattHoursPerSquareMeter(this int? value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation KilowattHoursPerSquareMeter(this long value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? KilowattHoursPerSquareMeter(this long? value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation KilowattHoursPerSquareMeter(this double value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? KilowattHoursPerSquareMeter(this double? value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation KilowattHoursPerSquareMeter(this float value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? KilowattHoursPerSquareMeter(this float? value) => Irradiation.FromKilowattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation KilowattHoursPerSquareMeter(this decimal value) => Irradiation.FromKilowattHoursPerSquareMeter(Convert.ToDouble(value));
+
+ ///
+ public static Irradiation? KilowattHoursPerSquareMeter(this decimal? value) => Irradiation.FromKilowattHoursPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ #region WattHourPerSquareMeter
+
+ ///
+ public static Irradiation WattHoursPerSquareMeter(this int value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? WattHoursPerSquareMeter(this int? value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation WattHoursPerSquareMeter(this long value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? WattHoursPerSquareMeter(this long? value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation WattHoursPerSquareMeter(this double value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? WattHoursPerSquareMeter(this double? value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation WattHoursPerSquareMeter(this float value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation? WattHoursPerSquareMeter(this float? value) => Irradiation.FromWattHoursPerSquareMeter(value);
+
+ ///
+ public static Irradiation WattHoursPerSquareMeter(this decimal value) => Irradiation.FromWattHoursPerSquareMeter(Convert.ToDouble(value));
+
+ ///
+ public static Irradiation? WattHoursPerSquareMeter(this decimal? value) => Irradiation.FromWattHoursPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
+
+ #endregion
+
+ }
+}
+#endif
diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
new file mode 100644
index 0000000000..094ffd181f
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
@@ -0,0 +1,771 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by \generate-code.bat.
+//
+// Changes to this file will be lost when the code is regenerated.
+// The build server regenerates the code before each build and a pre-build
+// step will regenerate the code on each local build.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text.RegularExpressions;
+using System.Linq;
+using JetBrains.Annotations;
+using UnitsNet.Units;
+
+// Windows Runtime Component does not support CultureInfo type, so use culture name string instead for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+using Culture = System.String;
+#else
+using Culture = System.IFormatProvider;
+#endif
+
+// ReSharper disable once CheckNamespace
+
+namespace UnitsNet
+{
+ ///
+ /// Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.
+ ///
+ // ReSharper disable once PartialTypeWithSinglePart
+
+ // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components
+ // Public structures can't have any members other than public fields, and those fields must be value types or strings.
+ // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
+#if WINDOWS_UWP
+ public sealed partial class Irradiation
+#else
+ public partial struct Irradiation : IComparable, IComparable
+#endif
+ {
+ ///
+ /// Base unit of Irradiation.
+ ///
+ private readonly double _joulesPerSquareMeter;
+
+ // Windows Runtime Component requires a default constructor
+#if WINDOWS_UWP
+ public Irradiation() : this(0)
+ {
+ }
+#endif
+
+ public Irradiation(double joulespersquaremeter)
+ {
+ _joulesPerSquareMeter = Convert.ToDouble(joulespersquaremeter);
+ }
+
+ // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ Irradiation(long joulespersquaremeter)
+ {
+ _joulesPerSquareMeter = Convert.ToDouble(joulespersquaremeter);
+ }
+
+ // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
+ // Windows Runtime Component does not support decimal type
+#if WINDOWS_UWP
+ private
+#else
+ public
+#endif
+ Irradiation(decimal joulespersquaremeter)
+ {
+ _joulesPerSquareMeter = Convert.ToDouble(joulespersquaremeter);
+ }
+
+ #region Properties
+
+ ///
+ /// The of this quantity.
+ ///
+ public static QuantityType QuantityType => QuantityType.Irradiation;
+
+ ///
+ /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
+ ///
+ public static IrradiationUnit BaseUnit
+ {
+ get { return IrradiationUnit.JoulePerSquareMeter; }
+ }
+
+ ///
+ /// All units of measurement for the Irradiation quantity.
+ ///
+ public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().ToArray();
+
+ ///
+ /// Get Irradiation in JoulesPerSquareMeter.
+ ///
+ public double JoulesPerSquareMeter
+ {
+ get { return _joulesPerSquareMeter; }
+ }
+
+ ///
+ /// Get Irradiation in KilowattHoursPerSquareMeter.
+ ///
+ public double KilowattHoursPerSquareMeter
+ {
+ get { return (_joulesPerSquareMeter/3600d) / 1e3d; }
+ }
+
+ ///
+ /// Get Irradiation in WattHoursPerSquareMeter.
+ ///
+ public double WattHoursPerSquareMeter
+ {
+ get { return _joulesPerSquareMeter/3600d; }
+ }
+
+ #endregion
+
+ #region Static
+
+ public static Irradiation Zero
+ {
+ get { return new Irradiation(); }
+ }
+
+ ///
+ /// Get Irradiation from JoulesPerSquareMeter.
+ ///
+#if WINDOWS_UWP
+ [Windows.Foundation.Metadata.DefaultOverload]
+ public static Irradiation FromJoulesPerSquareMeter(double joulespersquaremeter)
+ {
+ double value = (double) joulespersquaremeter;
+ return new Irradiation(value);
+ }
+#else
+ public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquaremeter)
+ {
+ double value = (double) joulespersquaremeter;
+ return new Irradiation((value));
+ }
+#endif
+
+ ///
+ /// Get Irradiation from KilowattHoursPerSquareMeter.
+ ///
+#if WINDOWS_UWP
+ [Windows.Foundation.Metadata.DefaultOverload]
+ public static Irradiation FromKilowattHoursPerSquareMeter(double kilowatthourspersquaremeter)
+ {
+ double value = (double) kilowatthourspersquaremeter;
+ return new Irradiation((value*3600d) * 1e3d);
+ }
+#else
+ public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatthourspersquaremeter)
+ {
+ double value = (double) kilowatthourspersquaremeter;
+ return new Irradiation(((value*3600d) * 1e3d));
+ }
+#endif
+
+ ///
+ /// Get Irradiation from WattHoursPerSquareMeter.
+ ///
+#if WINDOWS_UWP
+ [Windows.Foundation.Metadata.DefaultOverload]
+ public static Irradiation FromWattHoursPerSquareMeter(double watthourspersquaremeter)
+ {
+ double value = (double) watthourspersquaremeter;
+ return new Irradiation(value*3600d);
+ }
+#else
+ public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthourspersquaremeter)
+ {
+ double value = (double) watthourspersquaremeter;
+ return new Irradiation((value*3600d));
+ }
+#endif
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Get nullable Irradiation from nullable JoulesPerSquareMeter.
+ ///
+ public static Irradiation? FromJoulesPerSquareMeter(QuantityValue? joulespersquaremeter)
+ {
+ if (joulespersquaremeter.HasValue)
+ {
+ return FromJoulesPerSquareMeter(joulespersquaremeter.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable Irradiation from nullable KilowattHoursPerSquareMeter.
+ ///
+ public static Irradiation? FromKilowattHoursPerSquareMeter(QuantityValue? kilowatthourspersquaremeter)
+ {
+ if (kilowatthourspersquaremeter.HasValue)
+ {
+ return FromKilowattHoursPerSquareMeter(kilowatthourspersquaremeter.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Get nullable Irradiation from nullable WattHoursPerSquareMeter.
+ ///
+ public static Irradiation? FromWattHoursPerSquareMeter(QuantityValue? watthourspersquaremeter)
+ {
+ if (watthourspersquaremeter.HasValue)
+ {
+ return FromWattHoursPerSquareMeter(watthourspersquaremeter.Value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+#endif
+
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// Irradiation unit value.
+#if WINDOWS_UWP
+ // Fix name conflict with parameter "value"
+ [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
+ public static Irradiation From(double value, IrradiationUnit fromUnit)
+#else
+ public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit)
+#endif
+ {
+ switch (fromUnit)
+ {
+ case IrradiationUnit.JoulePerSquareMeter:
+ return FromJoulesPerSquareMeter(value);
+ case IrradiationUnit.KilowattHourPerSquareMeter:
+ return FromKilowattHoursPerSquareMeter(value);
+ case IrradiationUnit.WattHourPerSquareMeter:
+ return FromWattHoursPerSquareMeter(value);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+
+ // Windows Runtime Component does not support nullable types (double?): https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// Irradiation unit value.
+ public static Irradiation? From(QuantityValue? value, IrradiationUnit fromUnit)
+ {
+ if (!value.HasValue)
+ {
+ return null;
+ }
+ switch (fromUnit)
+ {
+ case IrradiationUnit.JoulePerSquareMeter:
+ return FromJoulesPerSquareMeter(value.Value);
+ case IrradiationUnit.KilowattHourPerSquareMeter:
+ return FromKilowattHoursPerSquareMeter(value.Value);
+ case IrradiationUnit.WattHourPerSquareMeter:
+ return FromWattHoursPerSquareMeter(value.Value);
+
+ default:
+ throw new NotImplementedException("fromUnit: " + fromUnit);
+ }
+ }
+#endif
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(IrradiationUnit unit)
+ {
+ return GetAbbreviation(unit, null);
+ }
+
+ ///
+ /// Get unit abbreviation string.
+ ///
+ /// Unit to get abbreviation for.
+ /// Culture to use for localization. Defaults to Thread.CurrentUICulture.
+ /// Unit abbreviation string.
+ [UsedImplicitly]
+ public static string GetAbbreviation(IrradiationUnit unit, [CanBeNull] Culture culture)
+ {
+ return UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit);
+ }
+
+ #endregion
+
+ #region Arithmetic Operators
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static Irradiation operator -(Irradiation right)
+ {
+ return new Irradiation(-right._joulesPerSquareMeter);
+ }
+
+ public static Irradiation operator +(Irradiation left, Irradiation right)
+ {
+ return new Irradiation(left._joulesPerSquareMeter + right._joulesPerSquareMeter);
+ }
+
+ public static Irradiation operator -(Irradiation left, Irradiation right)
+ {
+ return new Irradiation(left._joulesPerSquareMeter - right._joulesPerSquareMeter);
+ }
+
+ public static Irradiation operator *(double left, Irradiation right)
+ {
+ return new Irradiation(left*right._joulesPerSquareMeter);
+ }
+
+ public static Irradiation operator *(Irradiation left, double right)
+ {
+ return new Irradiation(left._joulesPerSquareMeter*(double)right);
+ }
+
+ public static Irradiation operator /(Irradiation left, double right)
+ {
+ return new Irradiation(left._joulesPerSquareMeter/(double)right);
+ }
+
+ public static double operator /(Irradiation left, Irradiation right)
+ {
+ return Convert.ToDouble(left._joulesPerSquareMeter/right._joulesPerSquareMeter);
+ }
+#endif
+
+ #endregion
+
+ #region Equality / IComparable
+
+ public int CompareTo(object obj)
+ {
+ if (obj == null) throw new ArgumentNullException("obj");
+ if (!(obj is Irradiation)) throw new ArgumentException("Expected type Irradiation.", "obj");
+ return CompareTo((Irradiation) obj);
+ }
+
+ // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ int CompareTo(Irradiation other)
+ {
+ return _joulesPerSquareMeter.CompareTo(other._joulesPerSquareMeter);
+ }
+
+ // Windows Runtime Component does not allow operator overloads: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if !WINDOWS_UWP
+ public static bool operator <=(Irradiation left, Irradiation right)
+ {
+ return left._joulesPerSquareMeter <= right._joulesPerSquareMeter;
+ }
+
+ public static bool operator >=(Irradiation left, Irradiation right)
+ {
+ return left._joulesPerSquareMeter >= right._joulesPerSquareMeter;
+ }
+
+ public static bool operator <(Irradiation left, Irradiation right)
+ {
+ return left._joulesPerSquareMeter < right._joulesPerSquareMeter;
+ }
+
+ public static bool operator >(Irradiation left, Irradiation right)
+ {
+ return left._joulesPerSquareMeter > right._joulesPerSquareMeter;
+ }
+
+ [Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals(other, maxError) to provide the max allowed error.")]
+ public static bool operator ==(Irradiation left, Irradiation right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._joulesPerSquareMeter == right._joulesPerSquareMeter;
+ }
+
+ [Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals(other, maxError) to provide the max allowed error.")]
+ public static bool operator !=(Irradiation left, Irradiation right)
+ {
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return left._joulesPerSquareMeter != right._joulesPerSquareMeter;
+ }
+#endif
+
+ [Obsolete("It is not safe to compare equality due to using System.Double as the internal representation. It is very easy to get slightly different values due to floating point operations. Instead use Equals(other, maxError) to provide the max allowed error.")]
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ return _joulesPerSquareMeter.Equals(((Irradiation) obj)._joulesPerSquareMeter);
+ }
+
+ ///
+ /// Compare equality to another Irradiation by specifying a max allowed difference.
+ /// Note that it is advised against specifying zero difference, due to the nature
+ /// of floating point operations and using System.Double internally.
+ ///
+ /// Other quantity to compare to.
+ /// Max error allowed.
+ /// True if the difference between the two values is not greater than the specified max.
+ public bool Equals(Irradiation other, Irradiation maxError)
+ {
+ return Math.Abs(_joulesPerSquareMeter - other._joulesPerSquareMeter) <= maxError._joulesPerSquareMeter;
+ }
+
+ public override int GetHashCode()
+ {
+ return _joulesPerSquareMeter.GetHashCode();
+ }
+
+ #endregion
+
+ #region Conversion
+
+ ///
+ /// Convert to the unit representation .
+ ///
+ /// Value in new unit if successful, exception otherwise.
+ /// If conversion was not successful.
+ public double As(IrradiationUnit unit)
+ {
+ switch (unit)
+ {
+ case IrradiationUnit.JoulePerSquareMeter:
+ return JoulesPerSquareMeter;
+ case IrradiationUnit.KilowattHourPerSquareMeter:
+ return KilowattHoursPerSquareMeter;
+ case IrradiationUnit.WattHourPerSquareMeter:
+ return WattHoursPerSquareMeter;
+
+ default:
+ throw new NotImplementedException("unit: " + unit);
+ }
+ }
+
+ #endregion
+
+ #region Parsing
+
+ ///
+ /// Parse a string with one or two quantities of the format "<quantity> <unit>".
+ ///
+ /// String to parse. Typically in the form: {number} {unit}
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ ///
+ /// Expected string to have one or two pairs of quantity and unit in the format
+ /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in"
+ ///
+ ///
+ /// More than one unit is represented by the specified unit abbreviation.
+ /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
+ /// , and .
+ ///
+ ///
+ /// If anything else goes wrong, typically due to a bug or unhandled case.
+ /// We wrap exceptions in to allow you to distinguish
+ /// Units.NET exceptions from other exceptions.
+ ///
+ public static Irradiation Parse(string str)
+ {
+ return Parse(str, null);
+ }
+
+ ///
+ /// Parse a string with one or two quantities of the format "<quantity> <unit>".
+ ///
+ /// String to parse. Typically in the form: {number} {unit}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ ///
+ /// Expected string to have one or two pairs of quantity and unit in the format
+ /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in"
+ ///
+ ///
+ /// More than one unit is represented by the specified unit abbreviation.
+ /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
+ /// , and .
+ ///
+ ///
+ /// If anything else goes wrong, typically due to a bug or unhandled case.
+ /// We wrap exceptions in to allow you to distinguish
+ /// Units.NET exceptions from other exceptions.
+ ///
+ public static Irradiation Parse(string str, [CanBeNull] Culture culture)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ return QuantityParser.Parse(str, formatProvider,
+ delegate(string value, string unit, IFormatProvider formatProvider2)
+ {
+ double parsedValue = double.Parse(value, formatProvider2);
+ IrradiationUnit parsedUnit = ParseUnit(unit, formatProvider2);
+ return From(parsedValue, parsedUnit);
+ }, (x, y) => FromJoulesPerSquareMeter(x.JoulesPerSquareMeter + y.JoulesPerSquareMeter));
+ }
+
+ ///
+ /// Try to parse a string with one or two quantities of the format "<quantity> <unit>".
+ ///
+ /// String to parse. Typically in the form: {number} {unit}
+ /// Resulting unit quantity if successful.
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ public static bool TryParse([CanBeNull] string str, out Irradiation result)
+ {
+ return TryParse(str, null, out result);
+ }
+
+ ///
+ /// Try to parse a string with one or two quantities of the format "<quantity> <unit>".
+ ///
+ /// String to parse. Typically in the form: {number} {unit}
+ /// Format to use when parsing number and unit. If it is null, it defaults to for parsing the number and for parsing the unit abbreviation by culture/language.
+ /// Resulting unit quantity if successful.
+ ///
+ /// Length.Parse("5.5 m", new CultureInfo("en-US"));
+ ///
+ public static bool TryParse([CanBeNull] string str, [CanBeNull] Culture culture, out Irradiation result)
+ {
+ try
+ {
+ result = Parse(str, culture);
+ return true;
+ }
+ catch
+ {
+ result = default(Irradiation);
+ return false;
+ }
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+ public static IrradiationUnit ParseUnit(string str)
+ {
+ return ParseUnit(str, (IFormatProvider)null);
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+ public static IrradiationUnit ParseUnit(string str, [CanBeNull] string cultureName)
+ {
+ return ParseUnit(str, cultureName == null ? null : new CultureInfo(cultureName));
+ }
+
+ ///
+ /// Parse a unit string.
+ ///
+ ///
+ /// Length.ParseUnit("m", new CultureInfo("en-US"));
+ ///
+ /// The value of 'str' cannot be null.
+ /// Error parsing string.
+
+ // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
+#if WINDOWS_UWP
+ internal
+#else
+ public
+#endif
+ static IrradiationUnit ParseUnit(string str, IFormatProvider formatProvider = null)
+ {
+ if (str == null) throw new ArgumentNullException("str");
+
+ var unitSystem = UnitSystem.GetCached(formatProvider);
+ var unit = unitSystem.Parse(str.Trim());
+
+ if (unit == IrradiationUnit.Undefined)
+ {
+ var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized IrradiationUnit.");
+ newEx.Data["input"] = str;
+ newEx.Data["formatprovider"] = formatProvider?.ToString() ?? "(null)";
+ throw newEx;
+ }
+
+ return unit;
+ }
+
+ #endregion
+
+ ///
+ /// Set the default unit used by ToString(). Default is JoulePerSquareMeter
+ ///
+ public static IrradiationUnit ToStringDefaultUnit { get; set; } = IrradiationUnit.JoulePerSquareMeter;
+
+ ///
+ /// Get default string representation of value and unit.
+ ///
+ /// String representation.
+ public override string ToString()
+ {
+ return ToString(ToStringDefaultUnit);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using current UI culture and two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// String representation.
+ public string ToString(IrradiationUnit unit)
+ {
+ return ToString(unit, null, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit. Using two significant digits after radix.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// String representation.
+ public string ToString(IrradiationUnit unit, [CanBeNull] Culture culture)
+ {
+ return ToString(unit, culture, 2);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Unit representation to use.
+ /// Culture to use for localization and number formatting.
+ /// The number of significant digits after the radix point.
+ /// String representation.
+ [UsedImplicitly]
+ public string ToString(IrradiationUnit unit, [CanBeNull] Culture culture, int significantDigitsAfterRadix)
+ {
+ double value = As(unit);
+ string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
+ return ToString(unit, culture, format);
+ }
+
+ ///
+ /// Get string representation of value and unit.
+ ///
+ /// Culture to use for localization and number formatting.
+ /// Unit representation to use.
+ /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively."
+ /// Arguments for string format. Value and unit are implictly included as arguments 0 and 1.
+ /// String representation.
+ [UsedImplicitly]
+ public string ToString(IrradiationUnit unit, [CanBeNull] Culture culture, [NotNull] string format,
+ [NotNull] params object[] args)
+ {
+ if (format == null) throw new ArgumentNullException(nameof(format));
+ if (args == null) throw new ArgumentNullException(nameof(args));
+
+ // Windows Runtime Component does not support CultureInfo type, so use culture name string for public methods instead: https://msdn.microsoft.com/en-us/library/br230301.aspx
+#if WINDOWS_UWP
+ IFormatProvider formatProvider = culture == null ? null : new CultureInfo(culture);
+#else
+ IFormatProvider formatProvider = culture;
+#endif
+ double value = As(unit);
+ object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
+ return string.Format(formatProvider, format, formatArgs);
+ }
+
+ ///
+ /// Represents the largest possible value of Irradiation
+ ///
+ public static Irradiation MaxValue
+ {
+ get
+ {
+ return new Irradiation(double.MaxValue);
+ }
+ }
+
+ ///
+ /// Represents the smallest possible value of Irradiation
+ ///
+ public static Irradiation MinValue
+ {
+ get
+ {
+ return new Irradiation(double.MinValue);
+ }
+ }
+ }
+}
diff --git a/UnitsNet/GeneratedCode/QuantityType.g.cs b/UnitsNet/GeneratedCode/QuantityType.g.cs
index b448775995..1750054f33 100644
--- a/UnitsNet/GeneratedCode/QuantityType.g.cs
+++ b/UnitsNet/GeneratedCode/QuantityType.g.cs
@@ -77,6 +77,7 @@ public enum QuantityType
Frequency,
Information,
Irradiance,
+ Irradiation,
KinematicViscosity,
LapseRate,
Length,
diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
index 72a21fed9a..f16161f5de 100644
--- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
+++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs
@@ -1576,6 +1576,25 @@ private static readonly ReadOnlyCollection DefaultLocalization
new AbbreviationsForCulture("en-US", "W/m²"),
}),
}),
+ new UnitLocalization(typeof (IrradiationUnit),
+ new[]
+ {
+ new CulturesForEnumValue((int) IrradiationUnit.JoulePerSquareMeter,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "J/m²"),
+ }),
+ new CulturesForEnumValue((int) IrradiationUnit.KilowattHourPerSquareMeter,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "kWh/m²"),
+ }),
+ new CulturesForEnumValue((int) IrradiationUnit.WattHourPerSquareMeter,
+ new[]
+ {
+ new AbbreviationsForCulture("en-US", "Wh/m²"),
+ }),
+ }),
new UnitLocalization(typeof (KinematicViscosityUnit),
new[]
{
diff --git a/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs
new file mode 100644
index 0000000000..0ee88e037b
--- /dev/null
+++ b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs
@@ -0,0 +1,49 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by \generate-code.bat.
+//
+// Changes to this file will be lost when the code is regenerated.
+// The build server regenerates the code before each build and a pre-build
+// step will regenerate the code on each local build.
+//
+// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
+//
+// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
+// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
+// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
+//
+//
+//------------------------------------------------------------------------------
+
+// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
+// https://github.com/angularsen/UnitsNet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+// ReSharper disable once CheckNamespace
+namespace UnitsNet.Units
+{
+ public enum IrradiationUnit
+ {
+ Undefined = 0,
+ JoulePerSquareMeter,
+ KilowattHourPerSquareMeter,
+ WattHourPerSquareMeter,
+ }
+}
diff --git a/UnitsNet/UnitDefinitions/Irradiation.json b/UnitsNet/UnitDefinitions/Irradiation.json
new file mode 100644
index 0000000000..8d1c97706e
--- /dev/null
+++ b/UnitsNet/UnitDefinitions/Irradiation.json
@@ -0,0 +1,33 @@
+{
+ "Name": "Irradiation",
+ "BaseUnit": "JoulePerSquareMeter",
+ "XmlDoc": "Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.",
+ "XmlDocRemarks": "https://en.wikipedia.org/wiki/Irradiation",
+ "Units": [
+ {
+ "SingularName": "JoulePerSquareMeter",
+ "PluralName": "JoulesPerSquareMeter",
+ "FromUnitToBaseFunc": "x",
+ "FromBaseToUnitFunc": "x",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "J/m²" ]
+ }
+ ]
+ },
+ {
+ "SingularName": "WattHourPerSquareMeter",
+ "PluralName": "WattHoursPerSquareMeter",
+ "FromUnitToBaseFunc": "x*3600d",
+ "FromBaseToUnitFunc": "x/3600d",
+ "Prefixes": [ "Kilo" ],
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "Wh/m²" ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file