diff --git a/.gitattributes b/.gitattributes
index 443c437442..72b8ab0ea9 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -20,27 +20,9 @@
*.filters text eol=crlf
*.vcxitems text eol=crlf
-
-#*.sln merge=binary
-#*.csproj merge=binary
-#*.vbproj merge=binary
-#*.vcxproj merge=binary
-#*.vcproj merge=binary
-#*.dbproj merge=binary
-#*.fsproj merge=binary
-#*.lsproj merge=binary
-#*.wixproj merge=binary
-#*.modelproj merge=binary
-#*.sqlproj merge=binary
-#*.wwaproj merge=binary
-
-#*.xproj merge=binary
-#*.props merge=binary
-#*.filters merge=binary
-#*.vcxitems merge=binary
-
# C#
-*.cs diff=csharp
+*.cs diff=csharp
+*.g.cs linguist-generated
# Powershell
*.ps1 text eol=crlf
diff --git a/Build/Test.ps1 b/Build/Test.ps1
new file mode 100644
index 0000000000..9458d0934b
--- /dev/null
+++ b/Build/Test.ps1
@@ -0,0 +1,17 @@
+$root = Resolve-Path $PSScriptRoot/..
+
+[int]$exitCode = 0
+
+# When this change is made available, we can possibly simplify below with: `dotnet test MySolution.sln`
+# Run tests only for test projects by smadala · Pull Request #1745 · Microsoft/vstest
+# https://github.com/Microsoft/vstest/pull/1745
+Get-ChildItem -Path $root -Recurse -Filter "*Tests*.csproj" | % {
+ $projectFilePath = $_.FullName
+ $projectName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
+ $reportFilePath = [IO.Path]::GetFullPath("$root/TestResults/$projectName.xml")
+ dotnet test $projectFilePath --logger "trx;LogFileName=$reportFilePath"
+ if ($LASTEXITCODE) { $exitCode = $LASTEXITCODE }
+}
+
+Write-Host -ForegroundColor Green "All tests run."
+exit $exitCode
\ No newline at end of file
diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1
index 25183af774..549b9adca0 100644
--- a/Build/build-functions.psm1
+++ b/Build/build-functions.psm1
@@ -28,7 +28,14 @@ function Update-GeneratedCode {
function Start-Build([boolean] $skipUWP = $false) {
write-host -foreground blue "Start-Build...`n---"
- dotnet build --configuration Release "$root\UnitsNet.sln"
+
+ $fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
+
+ $appVeyorLoggerDll = "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ $appVeyorLoggerNetCoreDll = "C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
+ $appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerNetCoreDll") { "/logger:$appVeyorLoggerNetCoreDll" } else { "" }
+
+ dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }
if ($skipUWP -eq $true)
@@ -37,11 +44,14 @@ function Start-Build([boolean] $skipUWP = $false) {
}
else
{
+ $fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log"
+ $appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }
+
# dontnet CLI does not support WindowsRuntimeComponent project type yet
# msbuild does not auto-restore nugets for this project type
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore
- & "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release
+ & "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }
}
@@ -56,7 +66,7 @@ function Start-Tests {
)
# Parent dir must exist before xunit tries to write files to it
- new-item -type directory $testReportDir 1> $null
+ new-item -type directory -force $testReportDir 1> $null
write-host -foreground blue "Run tests...`n---"
foreach ($projectPath in $projectPaths) {
@@ -68,7 +78,7 @@ function Start-Tests {
# https://github.com/xunit/xunit/issues/1216
push-location $projectDir
# -nobuild <-- this gives an error, but might want to use this to avoid extra builds
- dotnet xunit -configuration Release -framework netcoreapp1.1 -xml $reportFile -nobuild
+ dotnet xunit -configuration Release -framework netcoreapp2.0 -xml $reportFile -nobuild
if ($lastexitcode -ne 0) { exit 1 }
pop-location
}
@@ -79,9 +89,7 @@ function Start-Tests {
function Start-PackNugets {
$projectPaths = @(
"UnitsNet\UnitsNet.csproj",
- "UnitsNet\UnitsNet.Signed.csproj",
- "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj",
- "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj"
+ "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
)
write-host -foreground blue "Pack nugets...`n---"
@@ -91,7 +99,7 @@ function Start-PackNugets {
}
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
- & $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" -Symbols
+ & $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
write-host -foreground blue "Pack nugets...END`n"
}
diff --git a/Build/clean.bat b/Build/clean.bat
deleted file mode 100644
index 30744fa48f..0000000000
--- a/Build/clean.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@echo off
-SET scriptdir=%~dp0
-call powershell -NoProfile %scriptdir%\clean.ps1
-if %errorlevel% neq 0 exit /b %errorlevel%
\ No newline at end of file
diff --git a/Build/clean.ps1 b/Build/clean.ps1
index dd6b04a8ef..e1d6b46077 100644
--- a/Build/clean.ps1
+++ b/Build/clean.ps1
@@ -1,8 +1,27 @@
+# Don't allow using undeclared variables
+Set-Strictmode -version latest
+
$root = "$PSScriptRoot\.."
-$artifactsDir = "$root\Artifacts"
-if (test-path $artifactsDir) {
- write-host -foreground blue "Delete Artifacts dir"
- rm -r -fo $artifactsDir -ErrorAction Continue
+Write-Host -Foreground Blue "Delete dirs: bin, obj"
+
+[int]$deleteCount = 0
+[array]$failedToDeleteDirs = @()
+Get-ChildItem $root -Include bin,obj -Recurse -Force | %{
+ Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $_.FullName
+ if ($?) { $deleteCount++ }
+ else {
+ $failedToDeleteDirs += $_
+ }
}
-write-host -foreground blue "Delete dirs: bin, obj"
-ls $root -inc bin,obj -r -fo | ri -r -fo -ErrorAction SilentlyContinue
\ No newline at end of file
+
+Write-Host -Foreground Green "Deleted $deleteCount folders."
+
+if ($failedToDeleteDirs) {
+ $failCount = $failedToDeleteDirs.Count
+ Write-Host ""
+ Write-Host -Foreground Red "Failed to delete $failCount dirs:"
+ $failedToDeleteDirs | %{
+ Write-Host -Foreground Red $_.FullName
+ }
+ exit /B 1
+}
\ No newline at end of file
diff --git a/Build/set-version-UnitsNet.Serialization.JsonNet.ps1 b/Build/set-version-UnitsNet.Serialization.JsonNet.ps1
index 572399b01e..02628dda90 100644
--- a/Build/set-version-UnitsNet.Serialization.JsonNet.ps1
+++ b/Build/set-version-UnitsNet.Serialization.JsonNet.ps1
@@ -48,12 +48,12 @@ Import-Module "$PSScriptRoot\set-version.psm1"
$root = Resolve-Path "$PSScriptRoot\.."
$paramSet = $PsCmdlet.ParameterSetName
-$commonPropsFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Common.props"
-$versionFiles = @($commonPropsFile)
+$projFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
+$versionFiles = @($projFile)
$projectName = "JsonNet"
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
-$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
+$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
-Set-ProjectVersion $commonPropsFile $newVersion
-Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
\ No newline at end of file
+Set-ProjectVersion $projFile $newVersion
+Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
diff --git a/Build/set-version-UnitsNet.ps1 b/Build/set-version-UnitsNet.ps1
index fe378565f5..4f75f49cde 100644
--- a/Build/set-version-UnitsNet.ps1
+++ b/Build/set-version-UnitsNet.ps1
@@ -50,16 +50,16 @@ Import-Module "$PSScriptRoot\set-version.psm1"
$root = Resolve-Path "$PSScriptRoot\.."
$paramSet = $PsCmdlet.ParameterSetName
-$commonPropsFile = "$root\UnitsNet\UnitsNet.Common.props"
+$projFile = "$root\UnitsNet\UnitsNet.csproj"
$winrtAssemblyInfoFile = "$root\UnitsNet\Properties\AssemblyInfo.WindowsRuntimeComponent.cs"
$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec"
-$versionFiles = @($commonPropsFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
+$versionFiles = @($projFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
$projectName = "UnitsNet"
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
-$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
+$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
-Set-ProjectVersion $commonPropsFile $newVersion
+Set-ProjectVersion $projFile $newVersion
Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion
Set-NuspecVersion $winrtNuspecFile $newVersion
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
diff --git a/Build/set-version.psm1 b/Build/set-version.psm1
index 523aa60c8f..0626a343e5 100644
--- a/Build/set-version.psm1
+++ b/Build/set-version.psm1
@@ -43,11 +43,15 @@ function Invoke-CommitAndTagVersion(
}
function Set-ProjectVersion([string] $file, [string] $version) {
- Write-Host "$file -> $version"
+ $assemblyVersion = $version -replace "(\d+)(?:\.\d+)+.*", '$1.0.0.0'
+ Write-Host "$file -> $version (AssemblyVersion $assemblyVersion)"
(Get-Content $file) -replace '.*?', "$version" | Set-Content $file
+ (Get-Content $file) -replace '.*?', "$assemblyVersion" | Set-Content $file
}
function Set-AssemblyInfoVersion([string] $file, [string] $version) {
+ # Strip out any suffix: "4.0.0-alpha1" => "4.0.0"
+ $version = $version.Split('-')[0]
Write-Host "$file -> $version"
(Get-Content $file) -replace 'Assembly(File)?Version\(".*?"\)', "Assembly`$1Version(`"$version`")" | Set-Content $file
}
@@ -107,7 +111,7 @@ function BumpSuffix([string] $oldSuffix) {
# Example:
# -alpha => -alpha2
# -alpha1 => -alpha2
- $match = [regex]::Match($oldSuffix, '^-(\w+)(\d+)?$');
+ $match = [regex]::Match($oldSuffix, '^-([a-zA-Z]+)(\d+)?$');
$oldSuffix = $match.Groups[1].Value
$numberGroup = $match.Groups[2]
@@ -150,4 +154,4 @@ function Resolve-Error ($ErrorRecord=$Error[0])
}
}
-export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
\ No newline at end of file
+export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
diff --git a/Common/GeneratedCode/Quantities/Acceleration.Common.g.cs b/Common/GeneratedCode/Quantities/Acceleration.Common.g.cs
deleted file mode 100644
index 57f6cdbb3e..0000000000
--- a/Common/GeneratedCode/Quantities/Acceleration.Common.g.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Acceleration : IQuantity
-#else
- public partial struct Acceleration : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AccelerationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Acceleration()
- {
- BaseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit MeterPerSecondSquared.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Acceleration(double meterspersecondsquared)
- {
- _value = Convert.ToDouble(meterspersecondsquared);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Acceleration(double numericValue, AccelerationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterPerSecondSquared.
- ///
- /// Value assuming base unit MeterPerSecondSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Acceleration(long meterspersecondsquared) : this(Convert.ToDouble(meterspersecondsquared), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterPerSecondSquared.
- ///
- /// Value assuming base unit MeterPerSecondSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Acceleration(decimal meterspersecondsquared) : this(Convert.ToDouble(meterspersecondsquared), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Acceleration;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AccelerationUnit BaseUnit => AccelerationUnit.MeterPerSecondSquared;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Acceleration quantity.
- ///
- public static AccelerationUnit[] Units { get; } = Enum.GetValues(typeof(AccelerationUnit)).Cast().Except(new AccelerationUnit[]{ AccelerationUnit.Undefined }).ToArray();
-
- ///
- /// Get Acceleration in CentimetersPerSecondSquared.
- ///
- public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared);
-
- ///
- /// Get Acceleration in DecimetersPerSecondSquared.
- ///
- public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared);
-
- ///
- /// Get Acceleration in FeetPerSecondSquared.
- ///
- public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared);
-
- ///
- /// Get Acceleration in InchesPerSecondSquared.
- ///
- public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared);
-
- ///
- /// Get Acceleration in KilometersPerSecondSquared.
- ///
- public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared);
-
- ///
- /// Get Acceleration in KnotsPerHour.
- ///
- public double KnotsPerHour => As(AccelerationUnit.KnotPerHour);
-
- ///
- /// Get Acceleration in KnotsPerMinute.
- ///
- public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute);
-
- ///
- /// Get Acceleration in KnotsPerSecond.
- ///
- public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond);
-
- ///
- /// Get Acceleration in MetersPerSecondSquared.
- ///
- public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared);
-
- ///
- /// Get Acceleration in MicrometersPerSecondSquared.
- ///
- public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared);
-
- ///
- /// Get Acceleration in MillimetersPerSecondSquared.
- ///
- public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared);
-
- ///
- /// Get Acceleration in NanometersPerSecondSquared.
- ///
- public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared);
-
- ///
- /// Get Acceleration in StandardGravity.
- ///
- public double StandardGravity => As(AccelerationUnit.StandardGravity);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecondSquared.
- ///
- public static Acceleration Zero => new Acceleration(0, BaseUnit);
-
- ///
- /// Get Acceleration from CentimetersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromCentimetersPerSecondSquared(double centimeterspersecondsquared)
-#else
- public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centimeterspersecondsquared)
-#endif
- {
- double value = (double) centimeterspersecondsquared;
- return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from DecimetersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromDecimetersPerSecondSquared(double decimeterspersecondsquared)
-#else
- public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimeterspersecondsquared)
-#endif
- {
- double value = (double) decimeterspersecondsquared;
- return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from FeetPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromFeetPerSecondSquared(double feetpersecondsquared)
-#else
- public static Acceleration FromFeetPerSecondSquared(QuantityValue feetpersecondsquared)
-#endif
- {
- double value = (double) feetpersecondsquared;
- return new Acceleration(value, AccelerationUnit.FootPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from InchesPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromInchesPerSecondSquared(double inchespersecondsquared)
-#else
- public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersecondsquared)
-#endif
- {
- double value = (double) inchespersecondsquared;
- return new Acceleration(value, AccelerationUnit.InchPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from KilometersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromKilometersPerSecondSquared(double kilometerspersecondsquared)
-#else
- public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilometerspersecondsquared)
-#endif
- {
- double value = (double) kilometerspersecondsquared;
- return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from KnotsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromKnotsPerHour(double knotsperhour)
-#else
- public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour)
-#endif
- {
- double value = (double) knotsperhour;
- return new Acceleration(value, AccelerationUnit.KnotPerHour);
- }
-
- ///
- /// Get Acceleration from KnotsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromKnotsPerMinute(double knotsperminute)
-#else
- public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute)
-#endif
- {
- double value = (double) knotsperminute;
- return new Acceleration(value, AccelerationUnit.KnotPerMinute);
- }
-
- ///
- /// Get Acceleration from KnotsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromKnotsPerSecond(double knotspersecond)
-#else
- public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond)
-#endif
- {
- double value = (double) knotspersecond;
- return new Acceleration(value, AccelerationUnit.KnotPerSecond);
- }
-
- ///
- /// Get Acceleration from MetersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromMetersPerSecondSquared(double meterspersecondsquared)
-#else
- public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersecondsquared)
-#endif
- {
- double value = (double) meterspersecondsquared;
- return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from MicrometersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromMicrometersPerSecondSquared(double micrometerspersecondsquared)
-#else
- public static Acceleration FromMicrometersPerSecondSquared(QuantityValue micrometerspersecondsquared)
-#endif
- {
- double value = (double) micrometerspersecondsquared;
- return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from MillimetersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromMillimetersPerSecondSquared(double millimeterspersecondsquared)
-#else
- public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millimeterspersecondsquared)
-#endif
- {
- double value = (double) millimeterspersecondsquared;
- return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from NanometersPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromNanometersPerSecondSquared(double nanometerspersecondsquared)
-#else
- public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanometerspersecondsquared)
-#endif
- {
- double value = (double) nanometerspersecondsquared;
- return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared);
- }
-
- ///
- /// Get Acceleration from StandardGravity.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Acceleration FromStandardGravity(double standardgravity)
-#else
- public static Acceleration FromStandardGravity(QuantityValue standardgravity)
-#endif
- {
- double value = (double) standardgravity;
- return new Acceleration(value, AccelerationUnit.StandardGravity);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Acceleration unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Acceleration From(double value, AccelerationUnit fromUnit)
-#else
- public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit)
-#endif
- {
- return new Acceleration((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AccelerationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Acceleration)) throw new ArgumentException("Expected type Acceleration.", nameof(obj));
-
- return CompareTo((Acceleration)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(Acceleration other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Acceleration, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Acceleration))
- return false;
-
- var objQuantity = (Acceleration)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Acceleration within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Acceleration 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.
- [Obsolete("Please use the Equals(Acceleration, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Acceleration other, Acceleration maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Acceleration.
- public override int GetHashCode()
- {
- return new { type = typeof(Acceleration), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AccelerationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Acceleration to another Acceleration with the unit representation .
- ///
- /// A Acceleration with the specified unit.
- public Acceleration ToUnit(AccelerationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Acceleration(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AccelerationUnit.CentimeterPerSecondSquared: return (_value) * 1e-2d;
- case AccelerationUnit.DecimeterPerSecondSquared: return (_value) * 1e-1d;
- case AccelerationUnit.FootPerSecondSquared: return _value*0.304800;
- case AccelerationUnit.InchPerSecondSquared: return _value*0.0254;
- case AccelerationUnit.KilometerPerSecondSquared: return (_value) * 1e3d;
- case AccelerationUnit.KnotPerHour: return _value*0.5144444444444/3600;
- case AccelerationUnit.KnotPerMinute: return _value*0.5144444444444/60;
- case AccelerationUnit.KnotPerSecond: return _value*0.5144444444444;
- case AccelerationUnit.MeterPerSecondSquared: return _value;
- case AccelerationUnit.MicrometerPerSecondSquared: return (_value) * 1e-6d;
- case AccelerationUnit.MillimeterPerSecondSquared: return (_value) * 1e-3d;
- case AccelerationUnit.NanometerPerSecondSquared: return (_value) * 1e-9d;
- case AccelerationUnit.StandardGravity: return _value*9.80665;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AccelerationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AccelerationUnit.CentimeterPerSecondSquared: return (baseUnitValue) / 1e-2d;
- case AccelerationUnit.DecimeterPerSecondSquared: return (baseUnitValue) / 1e-1d;
- case AccelerationUnit.FootPerSecondSquared: return baseUnitValue/0.304800;
- case AccelerationUnit.InchPerSecondSquared: return baseUnitValue/0.0254;
- case AccelerationUnit.KilometerPerSecondSquared: return (baseUnitValue) / 1e3d;
- case AccelerationUnit.KnotPerHour: return baseUnitValue/0.5144444444444*3600;
- case AccelerationUnit.KnotPerMinute: return baseUnitValue/0.5144444444444*60;
- case AccelerationUnit.KnotPerSecond: return baseUnitValue/0.5144444444444;
- case AccelerationUnit.MeterPerSecondSquared: return baseUnitValue;
- case AccelerationUnit.MicrometerPerSecondSquared: return (baseUnitValue) / 1e-6d;
- case AccelerationUnit.MillimeterPerSecondSquared: return (baseUnitValue) / 1e-3d;
- case AccelerationUnit.NanometerPerSecondSquared: return (baseUnitValue) / 1e-9d;
- case AccelerationUnit.StandardGravity: return baseUnitValue/9.80665;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Acceleration Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Acceleration result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AccelerationUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is MeterPerSecondSquared
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AccelerationUnit ToStringDefaultUnit { get; set; } = AccelerationUnit.MeterPerSecondSquared;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AccelerationUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Acceleration
- ///
- public static Acceleration MaxValue => new Acceleration(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Acceleration
- ///
- public static Acceleration MinValue => new Acceleration(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Acceleration.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Acceleration.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs b/Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs
deleted file mode 100644
index e1f8b61fca..0000000000
--- a/Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs
+++ /dev/null
@@ -1,784 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 AmountOfSubstance : IQuantity
-#else
- public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AmountOfSubstanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static AmountOfSubstance()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Mole.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public AmountOfSubstance(double moles)
- {
- _value = Convert.ToDouble(moles);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- AmountOfSubstance(double numericValue, AmountOfSubstanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Mole.
- ///
- /// Value assuming base unit Mole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AmountOfSubstance(long moles) : this(Convert.ToDouble(moles), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Mole.
- ///
- /// Value assuming base unit Mole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AmountOfSubstance(decimal moles) : this(Convert.ToDouble(moles), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.AmountOfSubstance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AmountOfSubstanceUnit BaseUnit => AmountOfSubstanceUnit.Mole;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the AmountOfSubstance quantity.
- ///
- public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().Except(new AmountOfSubstanceUnit[]{ AmountOfSubstanceUnit.Undefined }).ToArray();
-
- ///
- /// Get AmountOfSubstance in Centimoles.
- ///
- public double Centimoles => As(AmountOfSubstanceUnit.Centimole);
-
- ///
- /// Get AmountOfSubstance in CentipoundMoles.
- ///
- public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole);
-
- ///
- /// Get AmountOfSubstance in Decimoles.
- ///
- public double Decimoles => As(AmountOfSubstanceUnit.Decimole);
-
- ///
- /// Get AmountOfSubstance in DecipoundMoles.
- ///
- public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole);
-
- ///
- /// Get AmountOfSubstance in Kilomoles.
- ///
- public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole);
-
- ///
- /// Get AmountOfSubstance in KilopoundMoles.
- ///
- public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole);
-
- ///
- /// Get AmountOfSubstance in Megamoles.
- ///
- public double Megamoles => As(AmountOfSubstanceUnit.Megamole);
-
- ///
- /// Get AmountOfSubstance in Micromoles.
- ///
- public double Micromoles => As(AmountOfSubstanceUnit.Micromole);
-
- ///
- /// Get AmountOfSubstance in MicropoundMoles.
- ///
- public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole);
-
- ///
- /// Get AmountOfSubstance in Millimoles.
- ///
- public double Millimoles => As(AmountOfSubstanceUnit.Millimole);
-
- ///
- /// Get AmountOfSubstance in MillipoundMoles.
- ///
- public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole);
-
- ///
- /// Get AmountOfSubstance in Moles.
- ///
- public double Moles => As(AmountOfSubstanceUnit.Mole);
-
- ///
- /// Get AmountOfSubstance in Nanomoles.
- ///
- public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole);
-
- ///
- /// Get AmountOfSubstance in NanopoundMoles.
- ///
- public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole);
-
- ///
- /// Get AmountOfSubstance in PoundMoles.
- ///
- public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Mole.
- ///
- public static AmountOfSubstance Zero => new AmountOfSubstance(0, BaseUnit);
-
- ///
- /// Get AmountOfSubstance from Centimoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromCentimoles(double centimoles)
-#else
- public static AmountOfSubstance FromCentimoles(QuantityValue centimoles)
-#endif
- {
- double value = (double) centimoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole);
- }
-
- ///
- /// Get AmountOfSubstance from CentipoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromCentipoundMoles(double centipoundmoles)
-#else
- public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmoles)
-#endif
- {
- double value = (double) centipoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from Decimoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromDecimoles(double decimoles)
-#else
- public static AmountOfSubstance FromDecimoles(QuantityValue decimoles)
-#endif
- {
- double value = (double) decimoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole);
- }
-
- ///
- /// Get AmountOfSubstance from DecipoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromDecipoundMoles(double decipoundmoles)
-#else
- public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles)
-#endif
- {
- double value = (double) decipoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from Kilomoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromKilomoles(double kilomoles)
-#else
- public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles)
-#endif
- {
- double value = (double) kilomoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole);
- }
-
- ///
- /// Get AmountOfSubstance from KilopoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromKilopoundMoles(double kilopoundmoles)
-#else
- public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles)
-#endif
- {
- double value = (double) kilopoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from Megamoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMegamoles(double megamoles)
-#else
- public static AmountOfSubstance FromMegamoles(QuantityValue megamoles)
-#endif
- {
- double value = (double) megamoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole);
- }
-
- ///
- /// Get AmountOfSubstance from Micromoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMicromoles(double micromoles)
-#else
- public static AmountOfSubstance FromMicromoles(QuantityValue micromoles)
-#endif
- {
- double value = (double) micromoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole);
- }
-
- ///
- /// Get AmountOfSubstance from MicropoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMicropoundMoles(double micropoundmoles)
-#else
- public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmoles)
-#endif
- {
- double value = (double) micropoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from Millimoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMillimoles(double millimoles)
-#else
- public static AmountOfSubstance FromMillimoles(QuantityValue millimoles)
-#endif
- {
- double value = (double) millimoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole);
- }
-
- ///
- /// Get AmountOfSubstance from MillipoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMillipoundMoles(double millipoundmoles)
-#else
- public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmoles)
-#endif
- {
- double value = (double) millipoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from Moles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromMoles(double moles)
-#else
- public static AmountOfSubstance FromMoles(QuantityValue moles)
-#endif
- {
- double value = (double) moles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole);
- }
-
- ///
- /// Get AmountOfSubstance from Nanomoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromNanomoles(double nanomoles)
-#else
- public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles)
-#endif
- {
- double value = (double) nanomoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole);
- }
-
- ///
- /// Get AmountOfSubstance from NanopoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromNanopoundMoles(double nanopoundmoles)
-#else
- public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles)
-#endif
- {
- double value = (double) nanopoundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole);
- }
-
- ///
- /// Get AmountOfSubstance from PoundMoles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmountOfSubstance FromPoundMoles(double poundmoles)
-#else
- public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles)
-#endif
- {
- double value = (double) poundmoles;
- return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// AmountOfSubstance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static AmountOfSubstance From(double value, AmountOfSubstanceUnit fromUnit)
-#else
- public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit fromUnit)
-#endif
- {
- return new AmountOfSubstance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AmountOfSubstanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is AmountOfSubstance)) throw new ArgumentException("Expected type AmountOfSubstance.", nameof(obj));
-
- return CompareTo((AmountOfSubstance)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(AmountOfSubstance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(AmountOfSubstance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is AmountOfSubstance))
- return false;
-
- var objQuantity = (AmountOfSubstance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another AmountOfSubstance 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.
- [Obsolete("Please use the Equals(AmountOfSubstance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(AmountOfSubstance other, AmountOfSubstance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current AmountOfSubstance.
- public override int GetHashCode()
- {
- return new { type = typeof(AmountOfSubstance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AmountOfSubstanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation .
- ///
- /// A AmountOfSubstance with the specified unit.
- public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new AmountOfSubstance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AmountOfSubstanceUnit.Centimole: return (_value) * 1e-2d;
- case AmountOfSubstanceUnit.CentipoundMole: return (_value*453.59237) * 1e-2d;
- case AmountOfSubstanceUnit.Decimole: return (_value) * 1e-1d;
- case AmountOfSubstanceUnit.DecipoundMole: return (_value*453.59237) * 1e-1d;
- case AmountOfSubstanceUnit.Kilomole: return (_value) * 1e3d;
- case AmountOfSubstanceUnit.KilopoundMole: return (_value*453.59237) * 1e3d;
- case AmountOfSubstanceUnit.Megamole: return (_value) * 1e6d;
- case AmountOfSubstanceUnit.Micromole: return (_value) * 1e-6d;
- case AmountOfSubstanceUnit.MicropoundMole: return (_value*453.59237) * 1e-6d;
- case AmountOfSubstanceUnit.Millimole: return (_value) * 1e-3d;
- case AmountOfSubstanceUnit.MillipoundMole: return (_value*453.59237) * 1e-3d;
- case AmountOfSubstanceUnit.Mole: return _value;
- case AmountOfSubstanceUnit.Nanomole: return (_value) * 1e-9d;
- case AmountOfSubstanceUnit.NanopoundMole: return (_value*453.59237) * 1e-9d;
- case AmountOfSubstanceUnit.PoundMole: return _value*453.59237;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AmountOfSubstanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AmountOfSubstanceUnit.Centimole: return (baseUnitValue) / 1e-2d;
- case AmountOfSubstanceUnit.CentipoundMole: return (baseUnitValue/453.59237) / 1e-2d;
- case AmountOfSubstanceUnit.Decimole: return (baseUnitValue) / 1e-1d;
- case AmountOfSubstanceUnit.DecipoundMole: return (baseUnitValue/453.59237) / 1e-1d;
- case AmountOfSubstanceUnit.Kilomole: return (baseUnitValue) / 1e3d;
- case AmountOfSubstanceUnit.KilopoundMole: return (baseUnitValue/453.59237) / 1e3d;
- case AmountOfSubstanceUnit.Megamole: return (baseUnitValue) / 1e6d;
- case AmountOfSubstanceUnit.Micromole: return (baseUnitValue) / 1e-6d;
- case AmountOfSubstanceUnit.MicropoundMole: return (baseUnitValue/453.59237) / 1e-6d;
- case AmountOfSubstanceUnit.Millimole: return (baseUnitValue) / 1e-3d;
- case AmountOfSubstanceUnit.MillipoundMole: return (baseUnitValue/453.59237) / 1e-3d;
- case AmountOfSubstanceUnit.Mole: return baseUnitValue;
- case AmountOfSubstanceUnit.Nanomole: return (baseUnitValue) / 1e-9d;
- case AmountOfSubstanceUnit.NanopoundMole: return (baseUnitValue/453.59237) / 1e-9d;
- case AmountOfSubstanceUnit.PoundMole: return baseUnitValue/453.59237;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 AmountOfSubstance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 AmountOfSubstance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AmountOfSubstanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Mole
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AmountOfSubstanceUnit ToStringDefaultUnit { get; set; } = AmountOfSubstanceUnit.Mole;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AmountOfSubstanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of AmountOfSubstance
- ///
- public static AmountOfSubstance MaxValue => new AmountOfSubstance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of AmountOfSubstance
- ///
- public static AmountOfSubstance MinValue => new AmountOfSubstance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => AmountOfSubstance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => AmountOfSubstance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs b/Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs
deleted file mode 100644
index f54d41b524..0000000000
--- a/Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs
+++ /dev/null
@@ -1,552 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The strength of a signal expressed in decibels (dB) relative to one volt RMS.
- ///
- // 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 AmplitudeRatio : IQuantity
-#else
- public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AmplitudeRatioUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static AmplitudeRatio()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit DecibelVolt.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public AmplitudeRatio(double decibelvolts)
- {
- _value = Convert.ToDouble(decibelvolts);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- AmplitudeRatio(double numericValue, AmplitudeRatioUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecibelVolt.
- ///
- /// Value assuming base unit DecibelVolt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AmplitudeRatio(long decibelvolts) : this(Convert.ToDouble(decibelvolts), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecibelVolt.
- ///
- /// Value assuming base unit DecibelVolt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AmplitudeRatio(decimal decibelvolts) : this(Convert.ToDouble(decibelvolts), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.AmplitudeRatio;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AmplitudeRatioUnit BaseUnit => AmplitudeRatioUnit.DecibelVolt;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the AmplitudeRatio quantity.
- ///
- public static AmplitudeRatioUnit[] Units { get; } = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().Except(new AmplitudeRatioUnit[]{ AmplitudeRatioUnit.Undefined }).ToArray();
-
- ///
- /// Get AmplitudeRatio in DecibelMicrovolts.
- ///
- public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt);
-
- ///
- /// Get AmplitudeRatio in DecibelMillivolts.
- ///
- public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt);
-
- ///
- /// Get AmplitudeRatio in DecibelsUnloaded.
- ///
- public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded);
-
- ///
- /// Get AmplitudeRatio in DecibelVolts.
- ///
- public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit DecibelVolt.
- ///
- public static AmplitudeRatio Zero => new AmplitudeRatio(0, BaseUnit);
-
- ///
- /// Get AmplitudeRatio from DecibelMicrovolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmplitudeRatio FromDecibelMicrovolts(double decibelmicrovolts)
-#else
- public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovolts)
-#endif
- {
- double value = (double) decibelmicrovolts;
- return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt);
- }
-
- ///
- /// Get AmplitudeRatio from DecibelMillivolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmplitudeRatio FromDecibelMillivolts(double decibelmillivolts)
-#else
- public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivolts)
-#endif
- {
- double value = (double) decibelmillivolts;
- return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt);
- }
-
- ///
- /// Get AmplitudeRatio from DecibelsUnloaded.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmplitudeRatio FromDecibelsUnloaded(double decibelsunloaded)
-#else
- public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded)
-#endif
- {
- double value = (double) decibelsunloaded;
- return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded);
- }
-
- ///
- /// Get AmplitudeRatio from DecibelVolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AmplitudeRatio FromDecibelVolts(double decibelvolts)
-#else
- public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts)
-#endif
- {
- double value = (double) decibelvolts;
- return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// AmplitudeRatio unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static AmplitudeRatio From(double value, AmplitudeRatioUnit fromUnit)
-#else
- public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUnit)
-#endif
- {
- return new AmplitudeRatio((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AmplitudeRatioUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is AmplitudeRatio)) throw new ArgumentException("Expected type AmplitudeRatio.", nameof(obj));
-
- return CompareTo((AmplitudeRatio)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(AmplitudeRatio other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(AmplitudeRatio, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is AmplitudeRatio))
- return false;
-
- var objQuantity = (AmplitudeRatio)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another AmplitudeRatio 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.
- [Obsolete("Please use the Equals(AmplitudeRatio, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(AmplitudeRatio other, AmplitudeRatio maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current AmplitudeRatio.
- public override int GetHashCode()
- {
- return new { type = typeof(AmplitudeRatio), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AmplitudeRatioUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation .
- ///
- /// A AmplitudeRatio with the specified unit.
- public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new AmplitudeRatio(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AmplitudeRatioUnit.DecibelMicrovolt: return _value - 120;
- case AmplitudeRatioUnit.DecibelMillivolt: return _value - 60;
- case AmplitudeRatioUnit.DecibelUnloaded: return _value - 2.218487499;
- case AmplitudeRatioUnit.DecibelVolt: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AmplitudeRatioUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AmplitudeRatioUnit.DecibelMicrovolt: return baseUnitValue + 120;
- case AmplitudeRatioUnit.DecibelMillivolt: return baseUnitValue + 60;
- case AmplitudeRatioUnit.DecibelUnloaded: return baseUnitValue + 2.218487499;
- case AmplitudeRatioUnit.DecibelVolt: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 AmplitudeRatio Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 AmplitudeRatio result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AmplitudeRatioUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is DecibelVolt
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AmplitudeRatioUnit ToStringDefaultUnit { get; set; } = AmplitudeRatioUnit.DecibelVolt;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AmplitudeRatioUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of AmplitudeRatio
- ///
- public static AmplitudeRatio MaxValue => new AmplitudeRatio(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of AmplitudeRatio
- ///
- public static AmplitudeRatio MinValue => new AmplitudeRatio(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => AmplitudeRatio.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => AmplitudeRatio.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Angle.Common.g.cs b/Common/GeneratedCode/Quantities/Angle.Common.g.cs
deleted file mode 100644
index b46e515994..0000000000
--- a/Common/GeneratedCode/Quantities/Angle.Common.g.cs
+++ /dev/null
@@ -1,762 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Angle : IQuantity
-#else
- public partial struct Angle : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AngleUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Angle()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Degree.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Angle(double degrees)
- {
- _value = Convert.ToDouble(degrees);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Angle(double numericValue, AngleUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Degree.
- ///
- /// Value assuming base unit Degree.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Angle(long degrees) : this(Convert.ToDouble(degrees), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Degree.
- ///
- /// Value assuming base unit Degree.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Angle(decimal degrees) : this(Convert.ToDouble(degrees), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Angle;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AngleUnit BaseUnit => AngleUnit.Degree;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Angle quantity.
- ///
- public static AngleUnit[] Units { get; } = Enum.GetValues(typeof(AngleUnit)).Cast().Except(new AngleUnit[]{ AngleUnit.Undefined }).ToArray();
-
- ///
- /// Get Angle in Arcminutes.
- ///
- public double Arcminutes => As(AngleUnit.Arcminute);
-
- ///
- /// Get Angle in Arcseconds.
- ///
- public double Arcseconds => As(AngleUnit.Arcsecond);
-
- ///
- /// Get Angle in Centiradians.
- ///
- public double Centiradians => As(AngleUnit.Centiradian);
-
- ///
- /// Get Angle in Deciradians.
- ///
- public double Deciradians => As(AngleUnit.Deciradian);
-
- ///
- /// Get Angle in Degrees.
- ///
- public double Degrees => As(AngleUnit.Degree);
-
- ///
- /// Get Angle in Gradians.
- ///
- public double Gradians => As(AngleUnit.Gradian);
-
- ///
- /// Get Angle in Microdegrees.
- ///
- public double Microdegrees => As(AngleUnit.Microdegree);
-
- ///
- /// Get Angle in Microradians.
- ///
- public double Microradians => As(AngleUnit.Microradian);
-
- ///
- /// Get Angle in Millidegrees.
- ///
- public double Millidegrees => As(AngleUnit.Millidegree);
-
- ///
- /// Get Angle in Milliradians.
- ///
- public double Milliradians => As(AngleUnit.Milliradian);
-
- ///
- /// Get Angle in Nanodegrees.
- ///
- public double Nanodegrees => As(AngleUnit.Nanodegree);
-
- ///
- /// Get Angle in Nanoradians.
- ///
- public double Nanoradians => As(AngleUnit.Nanoradian);
-
- ///
- /// Get Angle in Radians.
- ///
- public double Radians => As(AngleUnit.Radian);
-
- ///
- /// Get Angle in Revolutions.
- ///
- public double Revolutions => As(AngleUnit.Revolution);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Degree.
- ///
- public static Angle Zero => new Angle(0, BaseUnit);
-
- ///
- /// Get Angle from Arcminutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromArcminutes(double arcminutes)
-#else
- public static Angle FromArcminutes(QuantityValue arcminutes)
-#endif
- {
- double value = (double) arcminutes;
- return new Angle(value, AngleUnit.Arcminute);
- }
-
- ///
- /// Get Angle from Arcseconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromArcseconds(double arcseconds)
-#else
- public static Angle FromArcseconds(QuantityValue arcseconds)
-#endif
- {
- double value = (double) arcseconds;
- return new Angle(value, AngleUnit.Arcsecond);
- }
-
- ///
- /// Get Angle from Centiradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromCentiradians(double centiradians)
-#else
- public static Angle FromCentiradians(QuantityValue centiradians)
-#endif
- {
- double value = (double) centiradians;
- return new Angle(value, AngleUnit.Centiradian);
- }
-
- ///
- /// Get Angle from Deciradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromDeciradians(double deciradians)
-#else
- public static Angle FromDeciradians(QuantityValue deciradians)
-#endif
- {
- double value = (double) deciradians;
- return new Angle(value, AngleUnit.Deciradian);
- }
-
- ///
- /// Get Angle from Degrees.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromDegrees(double degrees)
-#else
- public static Angle FromDegrees(QuantityValue degrees)
-#endif
- {
- double value = (double) degrees;
- return new Angle(value, AngleUnit.Degree);
- }
-
- ///
- /// Get Angle from Gradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromGradians(double gradians)
-#else
- public static Angle FromGradians(QuantityValue gradians)
-#endif
- {
- double value = (double) gradians;
- return new Angle(value, AngleUnit.Gradian);
- }
-
- ///
- /// Get Angle from Microdegrees.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromMicrodegrees(double microdegrees)
-#else
- public static Angle FromMicrodegrees(QuantityValue microdegrees)
-#endif
- {
- double value = (double) microdegrees;
- return new Angle(value, AngleUnit.Microdegree);
- }
-
- ///
- /// Get Angle from Microradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromMicroradians(double microradians)
-#else
- public static Angle FromMicroradians(QuantityValue microradians)
-#endif
- {
- double value = (double) microradians;
- return new Angle(value, AngleUnit.Microradian);
- }
-
- ///
- /// Get Angle from Millidegrees.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromMillidegrees(double millidegrees)
-#else
- public static Angle FromMillidegrees(QuantityValue millidegrees)
-#endif
- {
- double value = (double) millidegrees;
- return new Angle(value, AngleUnit.Millidegree);
- }
-
- ///
- /// Get Angle from Milliradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromMilliradians(double milliradians)
-#else
- public static Angle FromMilliradians(QuantityValue milliradians)
-#endif
- {
- double value = (double) milliradians;
- return new Angle(value, AngleUnit.Milliradian);
- }
-
- ///
- /// Get Angle from Nanodegrees.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromNanodegrees(double nanodegrees)
-#else
- public static Angle FromNanodegrees(QuantityValue nanodegrees)
-#endif
- {
- double value = (double) nanodegrees;
- return new Angle(value, AngleUnit.Nanodegree);
- }
-
- ///
- /// Get Angle from Nanoradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromNanoradians(double nanoradians)
-#else
- public static Angle FromNanoradians(QuantityValue nanoradians)
-#endif
- {
- double value = (double) nanoradians;
- return new Angle(value, AngleUnit.Nanoradian);
- }
-
- ///
- /// Get Angle from Radians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromRadians(double radians)
-#else
- public static Angle FromRadians(QuantityValue radians)
-#endif
- {
- double value = (double) radians;
- return new Angle(value, AngleUnit.Radian);
- }
-
- ///
- /// Get Angle from Revolutions.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Angle FromRevolutions(double revolutions)
-#else
- public static Angle FromRevolutions(QuantityValue revolutions)
-#endif
- {
- double value = (double) revolutions;
- return new Angle(value, AngleUnit.Revolution);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Angle unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Angle From(double value, AngleUnit fromUnit)
-#else
- public static Angle From(QuantityValue value, AngleUnit fromUnit)
-#endif
- {
- return new Angle((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AngleUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Angle)) throw new ArgumentException("Expected type Angle.", nameof(obj));
-
- return CompareTo((Angle)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(Angle other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Angle, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Angle))
- return false;
-
- var objQuantity = (Angle)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Angle within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Angle other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Angle 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.
- [Obsolete("Please use the Equals(Angle, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Angle other, Angle maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Angle.
- public override int GetHashCode()
- {
- return new { type = typeof(Angle), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AngleUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Angle to another Angle with the unit representation .
- ///
- /// A Angle with the specified unit.
- public Angle ToUnit(AngleUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Angle(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AngleUnit.Arcminute: return _value/60;
- case AngleUnit.Arcsecond: return _value/3600;
- case AngleUnit.Centiradian: return (_value*180/Math.PI) * 1e-2d;
- case AngleUnit.Deciradian: return (_value*180/Math.PI) * 1e-1d;
- case AngleUnit.Degree: return _value;
- case AngleUnit.Gradian: return _value*0.9;
- case AngleUnit.Microdegree: return (_value) * 1e-6d;
- case AngleUnit.Microradian: return (_value*180/Math.PI) * 1e-6d;
- case AngleUnit.Millidegree: return (_value) * 1e-3d;
- case AngleUnit.Milliradian: return (_value*180/Math.PI) * 1e-3d;
- case AngleUnit.Nanodegree: return (_value) * 1e-9d;
- case AngleUnit.Nanoradian: return (_value*180/Math.PI) * 1e-9d;
- case AngleUnit.Radian: return _value*180/Math.PI;
- case AngleUnit.Revolution: return _value*360;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AngleUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AngleUnit.Arcminute: return baseUnitValue*60;
- case AngleUnit.Arcsecond: return baseUnitValue*3600;
- case AngleUnit.Centiradian: return (baseUnitValue/180*Math.PI) / 1e-2d;
- case AngleUnit.Deciradian: return (baseUnitValue/180*Math.PI) / 1e-1d;
- case AngleUnit.Degree: return baseUnitValue;
- case AngleUnit.Gradian: return baseUnitValue/0.9;
- case AngleUnit.Microdegree: return (baseUnitValue) / 1e-6d;
- case AngleUnit.Microradian: return (baseUnitValue/180*Math.PI) / 1e-6d;
- case AngleUnit.Millidegree: return (baseUnitValue) / 1e-3d;
- case AngleUnit.Milliradian: return (baseUnitValue/180*Math.PI) / 1e-3d;
- case AngleUnit.Nanodegree: return (baseUnitValue) / 1e-9d;
- case AngleUnit.Nanoradian: return (baseUnitValue/180*Math.PI) / 1e-9d;
- case AngleUnit.Radian: return baseUnitValue/180*Math.PI;
- case AngleUnit.Revolution: return baseUnitValue/360;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Angle Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Angle result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AngleUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Degree
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AngleUnit ToStringDefaultUnit { get; set; } = AngleUnit.Degree;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AngleUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Angle
- ///
- public static Angle MaxValue => new Angle(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Angle
- ///
- public static Angle MinValue => new Angle(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Angle.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Angle.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs b/Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs
deleted file mode 100644
index 9e23d63165..0000000000
--- a/Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 ApparentEnergy : IQuantity
-#else
- public partial struct ApparentEnergy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ApparentEnergyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ApparentEnergy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltampereHour.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ApparentEnergy(double voltamperehours)
- {
- _value = Convert.ToDouble(voltamperehours);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ApparentEnergy(double numericValue, ApparentEnergyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereHour.
- ///
- /// Value assuming base unit VoltampereHour.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ApparentEnergy(long voltamperehours) : this(Convert.ToDouble(voltamperehours), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereHour.
- ///
- /// Value assuming base unit VoltampereHour.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ApparentEnergy(decimal voltamperehours) : this(Convert.ToDouble(voltamperehours), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ApparentEnergy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ApparentEnergyUnit BaseUnit => ApparentEnergyUnit.VoltampereHour;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ApparentEnergy quantity.
- ///
- public static ApparentEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().Except(new ApparentEnergyUnit[]{ ApparentEnergyUnit.Undefined }).ToArray();
-
- ///
- /// Get ApparentEnergy in KilovoltampereHours.
- ///
- public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour);
-
- ///
- /// Get ApparentEnergy in MegavoltampereHours.
- ///
- public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour);
-
- ///
- /// Get ApparentEnergy in VoltampereHours.
- ///
- public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereHour.
- ///
- public static ApparentEnergy Zero => new ApparentEnergy(0, BaseUnit);
-
- ///
- /// Get ApparentEnergy from KilovoltampereHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentEnergy FromKilovoltampereHours(double kilovoltamperehours)
-#else
- public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamperehours)
-#endif
- {
- double value = (double) kilovoltamperehours;
- return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour);
- }
-
- ///
- /// Get ApparentEnergy from MegavoltampereHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentEnergy FromMegavoltampereHours(double megavoltamperehours)
-#else
- public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamperehours)
-#endif
- {
- double value = (double) megavoltamperehours;
- return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour);
- }
-
- ///
- /// Get ApparentEnergy from VoltampereHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentEnergy FromVoltampereHours(double voltamperehours)
-#else
- public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours)
-#endif
- {
- double value = (double) voltamperehours;
- return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ApparentEnergy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit)
-#else
- public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit)
-#endif
- {
- return new ApparentEnergy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ApparentEnergyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ApparentEnergy)) throw new ArgumentException("Expected type ApparentEnergy.", nameof(obj));
-
- return CompareTo((ApparentEnergy)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(ApparentEnergy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ApparentEnergy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ApparentEnergy))
- return false;
-
- var objQuantity = (ApparentEnergy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ApparentEnergy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ApparentEnergy 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.
- [Obsolete("Please use the Equals(ApparentEnergy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ApparentEnergy other, ApparentEnergy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ApparentEnergy.
- public override int GetHashCode()
- {
- return new { type = typeof(ApparentEnergy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ApparentEnergyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation .
- ///
- /// A ApparentEnergy with the specified unit.
- public ApparentEnergy ToUnit(ApparentEnergyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ApparentEnergy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ApparentEnergyUnit.KilovoltampereHour: return (_value) * 1e3d;
- case ApparentEnergyUnit.MegavoltampereHour: return (_value) * 1e6d;
- case ApparentEnergyUnit.VoltampereHour: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ApparentEnergyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ApparentEnergyUnit.KilovoltampereHour: return (baseUnitValue) / 1e3d;
- case ApparentEnergyUnit.MegavoltampereHour: return (baseUnitValue) / 1e6d;
- case ApparentEnergyUnit.VoltampereHour: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ApparentEnergy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ApparentEnergy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ApparentEnergyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltampereHour
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ApparentEnergyUnit ToStringDefaultUnit { get; set; } = ApparentEnergyUnit.VoltampereHour;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ApparentEnergyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ApparentEnergy
- ///
- public static ApparentEnergy MaxValue => new ApparentEnergy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ApparentEnergy
- ///
- public static ApparentEnergy MinValue => new ApparentEnergy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ApparentEnergy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ApparentEnergy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs b/Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs
deleted file mode 100644
index bd44ccbe19..0000000000
--- a/Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 ApparentPower : IQuantity
-#else
- public partial struct ApparentPower : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ApparentPowerUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ApparentPower()
- {
- BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Voltampere.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ApparentPower(double voltamperes)
- {
- _value = Convert.ToDouble(voltamperes);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ApparentPower(double numericValue, ApparentPowerUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Voltampere.
- ///
- /// Value assuming base unit Voltampere.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ApparentPower(long voltamperes) : this(Convert.ToDouble(voltamperes), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Voltampere.
- ///
- /// Value assuming base unit Voltampere.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ApparentPower(decimal voltamperes) : this(Convert.ToDouble(voltamperes), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ApparentPower;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ApparentPowerUnit BaseUnit => ApparentPowerUnit.Voltampere;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ApparentPower quantity.
- ///
- public static ApparentPowerUnit[] Units { get; } = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().Except(new ApparentPowerUnit[]{ ApparentPowerUnit.Undefined }).ToArray();
-
- ///
- /// Get ApparentPower in Gigavoltamperes.
- ///
- public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere);
-
- ///
- /// Get ApparentPower in Kilovoltamperes.
- ///
- public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere);
-
- ///
- /// Get ApparentPower in Megavoltamperes.
- ///
- public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere);
-
- ///
- /// Get ApparentPower in Voltamperes.
- ///
- public double Voltamperes => As(ApparentPowerUnit.Voltampere);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Voltampere.
- ///
- public static ApparentPower Zero => new ApparentPower(0, BaseUnit);
-
- ///
- /// Get ApparentPower from Gigavoltamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentPower FromGigavoltamperes(double gigavoltamperes)
-#else
- public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes)
-#endif
- {
- double value = (double) gigavoltamperes;
- return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere);
- }
-
- ///
- /// Get ApparentPower from Kilovoltamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentPower FromKilovoltamperes(double kilovoltamperes)
-#else
- public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes)
-#endif
- {
- double value = (double) kilovoltamperes;
- return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere);
- }
-
- ///
- /// Get ApparentPower from Megavoltamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentPower FromMegavoltamperes(double megavoltamperes)
-#else
- public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes)
-#endif
- {
- double value = (double) megavoltamperes;
- return new ApparentPower(value, ApparentPowerUnit.Megavoltampere);
- }
-
- ///
- /// Get ApparentPower from Voltamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ApparentPower FromVoltamperes(double voltamperes)
-#else
- public static ApparentPower FromVoltamperes(QuantityValue voltamperes)
-#endif
- {
- double value = (double) voltamperes;
- return new ApparentPower(value, ApparentPowerUnit.Voltampere);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ApparentPower unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ApparentPower From(double value, ApparentPowerUnit fromUnit)
-#else
- public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit)
-#endif
- {
- return new ApparentPower((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ApparentPowerUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ApparentPower)) throw new ArgumentException("Expected type ApparentPower.", nameof(obj));
-
- return CompareTo((ApparentPower)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(ApparentPower other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ApparentPower, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ApparentPower))
- return false;
-
- var objQuantity = (ApparentPower)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ApparentPower within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ApparentPower 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.
- [Obsolete("Please use the Equals(ApparentPower, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ApparentPower other, ApparentPower maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ApparentPower.
- public override int GetHashCode()
- {
- return new { type = typeof(ApparentPower), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ApparentPowerUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ApparentPower to another ApparentPower with the unit representation .
- ///
- /// A ApparentPower with the specified unit.
- public ApparentPower ToUnit(ApparentPowerUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ApparentPower(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ApparentPowerUnit.Gigavoltampere: return (_value) * 1e9d;
- case ApparentPowerUnit.Kilovoltampere: return (_value) * 1e3d;
- case ApparentPowerUnit.Megavoltampere: return (_value) * 1e6d;
- case ApparentPowerUnit.Voltampere: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ApparentPowerUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ApparentPowerUnit.Gigavoltampere: return (baseUnitValue) / 1e9d;
- case ApparentPowerUnit.Kilovoltampere: return (baseUnitValue) / 1e3d;
- case ApparentPowerUnit.Megavoltampere: return (baseUnitValue) / 1e6d;
- case ApparentPowerUnit.Voltampere: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ApparentPower Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ApparentPower result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ApparentPowerUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Voltampere
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ApparentPowerUnit ToStringDefaultUnit { get; set; } = ApparentPowerUnit.Voltampere;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ApparentPowerUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ApparentPower
- ///
- public static ApparentPower MaxValue => new ApparentPower(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ApparentPower
- ///
- public static ApparentPower MinValue => new ApparentPower(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ApparentPower.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ApparentPower.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Area.Common.g.cs b/Common/GeneratedCode/Quantities/Area.Common.g.cs
deleted file mode 100644
index 1d662ccf7a..0000000000
--- a/Common/GeneratedCode/Quantities/Area.Common.g.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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).
- ///
- // 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 Area : IQuantity
-#else
- public partial struct Area : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AreaUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Area()
- {
- BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit SquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Area(double squaremeters)
- {
- _value = Convert.ToDouble(squaremeters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Area(double numericValue, AreaUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeter.
- ///
- /// Value assuming base unit SquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Area(long squaremeters) : this(Convert.ToDouble(squaremeters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeter.
- ///
- /// Value assuming base unit SquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Area(decimal squaremeters) : this(Convert.ToDouble(squaremeters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Area;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AreaUnit BaseUnit => AreaUnit.SquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Area quantity.
- ///
- public static AreaUnit[] Units { get; } = Enum.GetValues(typeof(AreaUnit)).Cast().Except(new AreaUnit[]{ AreaUnit.Undefined }).ToArray();
-
- ///
- /// Get Area in Acres.
- ///
- public double Acres => As(AreaUnit.Acre);
-
- ///
- /// Get Area in Hectares.
- ///
- public double Hectares => As(AreaUnit.Hectare);
-
- ///
- /// Get Area in SquareCentimeters.
- ///
- public double SquareCentimeters => As(AreaUnit.SquareCentimeter);
-
- ///
- /// Get Area in SquareDecimeters.
- ///
- public double SquareDecimeters => As(AreaUnit.SquareDecimeter);
-
- ///
- /// Get Area in SquareFeet.
- ///
- public double SquareFeet => As(AreaUnit.SquareFoot);
-
- ///
- /// Get Area in SquareInches.
- ///
- public double SquareInches => As(AreaUnit.SquareInch);
-
- ///
- /// Get Area in SquareKilometers.
- ///
- public double SquareKilometers => As(AreaUnit.SquareKilometer);
-
- ///
- /// Get Area in SquareMeters.
- ///
- public double SquareMeters => As(AreaUnit.SquareMeter);
-
- ///
- /// Get Area in SquareMicrometers.
- ///
- public double SquareMicrometers => As(AreaUnit.SquareMicrometer);
-
- ///
- /// Get Area in SquareMiles.
- ///
- public double SquareMiles => As(AreaUnit.SquareMile);
-
- ///
- /// Get Area in SquareMillimeters.
- ///
- public double SquareMillimeters => As(AreaUnit.SquareMillimeter);
-
- ///
- /// Get Area in SquareYards.
- ///
- public double SquareYards => As(AreaUnit.SquareYard);
-
- ///
- /// Get Area in UsSurveySquareFeet.
- ///
- public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeter.
- ///
- public static Area Zero => new Area(0, BaseUnit);
-
- ///
- /// Get Area from Acres.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromAcres(double acres)
-#else
- public static Area FromAcres(QuantityValue acres)
-#endif
- {
- double value = (double) acres;
- return new Area(value, AreaUnit.Acre);
- }
-
- ///
- /// Get Area from Hectares.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromHectares(double hectares)
-#else
- public static Area FromHectares(QuantityValue hectares)
-#endif
- {
- double value = (double) hectares;
- return new Area(value, AreaUnit.Hectare);
- }
-
- ///
- /// Get Area from SquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareCentimeters(double squarecentimeters)
-#else
- public static Area FromSquareCentimeters(QuantityValue squarecentimeters)
-#endif
- {
- double value = (double) squarecentimeters;
- return new Area(value, AreaUnit.SquareCentimeter);
- }
-
- ///
- /// Get Area from SquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareDecimeters(double squaredecimeters)
-#else
- public static Area FromSquareDecimeters(QuantityValue squaredecimeters)
-#endif
- {
- double value = (double) squaredecimeters;
- return new Area(value, AreaUnit.SquareDecimeter);
- }
-
- ///
- /// Get Area from SquareFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareFeet(double squarefeet)
-#else
- public static Area FromSquareFeet(QuantityValue squarefeet)
-#endif
- {
- double value = (double) squarefeet;
- return new Area(value, AreaUnit.SquareFoot);
- }
-
- ///
- /// Get Area from SquareInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareInches(double squareinches)
-#else
- public static Area FromSquareInches(QuantityValue squareinches)
-#endif
- {
- double value = (double) squareinches;
- return new Area(value, AreaUnit.SquareInch);
- }
-
- ///
- /// Get Area from SquareKilometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareKilometers(double squarekilometers)
-#else
- public static Area FromSquareKilometers(QuantityValue squarekilometers)
-#endif
- {
- double value = (double) squarekilometers;
- return new Area(value, AreaUnit.SquareKilometer);
- }
-
- ///
- /// Get Area from SquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareMeters(double squaremeters)
-#else
- public static Area FromSquareMeters(QuantityValue squaremeters)
-#endif
- {
- double value = (double) squaremeters;
- return new Area(value, AreaUnit.SquareMeter);
- }
-
- ///
- /// Get Area from SquareMicrometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareMicrometers(double squaremicrometers)
-#else
- public static Area FromSquareMicrometers(QuantityValue squaremicrometers)
-#endif
- {
- double value = (double) squaremicrometers;
- return new Area(value, AreaUnit.SquareMicrometer);
- }
-
- ///
- /// Get Area from SquareMiles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareMiles(double squaremiles)
-#else
- public static Area FromSquareMiles(QuantityValue squaremiles)
-#endif
- {
- double value = (double) squaremiles;
- return new Area(value, AreaUnit.SquareMile);
- }
-
- ///
- /// Get Area from SquareMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareMillimeters(double squaremillimeters)
-#else
- public static Area FromSquareMillimeters(QuantityValue squaremillimeters)
-#endif
- {
- double value = (double) squaremillimeters;
- return new Area(value, AreaUnit.SquareMillimeter);
- }
-
- ///
- /// Get Area from SquareYards.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromSquareYards(double squareyards)
-#else
- public static Area FromSquareYards(QuantityValue squareyards)
-#endif
- {
- double value = (double) squareyards;
- return new Area(value, AreaUnit.SquareYard);
- }
-
- ///
- /// Get Area from UsSurveySquareFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Area FromUsSurveySquareFeet(double ussurveysquarefeet)
-#else
- public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet)
-#endif
- {
- double value = (double) ussurveysquarefeet;
- return new Area(value, AreaUnit.UsSurveySquareFoot);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Area unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Area From(double value, AreaUnit fromUnit)
-#else
- public static Area From(QuantityValue value, AreaUnit fromUnit)
-#endif
- {
- return new Area((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AreaUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Area)) throw new ArgumentException("Expected type Area.", nameof(obj));
-
- return CompareTo((Area)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(Area other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Area, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Area))
- return false;
-
- var objQuantity = (Area)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Area within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Area other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Area 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.
- [Obsolete("Please use the Equals(Area, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Area other, Area maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Area.
- public override int GetHashCode()
- {
- return new { type = typeof(Area), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AreaUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Area to another Area with the unit representation .
- ///
- /// A Area with the specified unit.
- public Area ToUnit(AreaUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Area(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AreaUnit.Acre: return _value*4046.85642;
- case AreaUnit.Hectare: return _value*1e4;
- case AreaUnit.SquareCentimeter: return _value*1e-4;
- case AreaUnit.SquareDecimeter: return _value*1e-2;
- case AreaUnit.SquareFoot: return _value*0.092903;
- case AreaUnit.SquareInch: return _value*0.00064516;
- case AreaUnit.SquareKilometer: return _value*1e6;
- case AreaUnit.SquareMeter: return _value;
- case AreaUnit.SquareMicrometer: return _value*1e-12;
- case AreaUnit.SquareMile: return _value*2.59e6;
- case AreaUnit.SquareMillimeter: return _value*1e-6;
- case AreaUnit.SquareYard: return _value*0.836127;
- case AreaUnit.UsSurveySquareFoot: return _value*0.09290341161;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AreaUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AreaUnit.Acre: return baseUnitValue/4046.85642;
- case AreaUnit.Hectare: return baseUnitValue/1e4;
- case AreaUnit.SquareCentimeter: return baseUnitValue/1e-4;
- case AreaUnit.SquareDecimeter: return baseUnitValue/1e-2;
- case AreaUnit.SquareFoot: return baseUnitValue/0.092903;
- case AreaUnit.SquareInch: return baseUnitValue/0.00064516;
- case AreaUnit.SquareKilometer: return baseUnitValue/1e6;
- case AreaUnit.SquareMeter: return baseUnitValue;
- case AreaUnit.SquareMicrometer: return baseUnitValue/1e-12;
- case AreaUnit.SquareMile: return baseUnitValue/2.59e6;
- case AreaUnit.SquareMillimeter: return baseUnitValue/1e-6;
- case AreaUnit.SquareYard: return baseUnitValue/0.836127;
- case AreaUnit.UsSurveySquareFoot: return baseUnitValue/0.09290341161;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Area Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Area result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AreaUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is SquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AreaUnit ToStringDefaultUnit { get; set; } = AreaUnit.SquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AreaUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Area
- ///
- public static Area MaxValue => new Area(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Area
- ///
- public static Area MinValue => new Area(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Area.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Area.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/AreaDensity.Common.g.cs b/Common/GeneratedCode/Quantities/AreaDensity.Common.g.cs
deleted file mode 100644
index 87f755b0b6..0000000000
--- a/Common/GeneratedCode/Quantities/AreaDensity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The area density of a two-dimensional object is calculated as the mass per unit area.
- ///
- // 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 AreaDensity : IQuantity
-#else
- public partial struct AreaDensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AreaDensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AreaDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static AreaDensity()
- {
- BaseDimensions = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public AreaDensity(double kilogramspersquaremeter)
- {
- _value = Convert.ToDouble(kilogramspersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- AreaDensity(double numericValue, AreaDensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerSquareMeter.
- ///
- /// Value assuming base unit KilogramPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AreaDensity(long kilogramspersquaremeter) : this(Convert.ToDouble(kilogramspersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerSquareMeter.
- ///
- /// Value assuming base unit KilogramPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AreaDensity(decimal kilogramspersquaremeter) : this(Convert.ToDouble(kilogramspersquaremeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.AreaDensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AreaDensityUnit BaseUnit => AreaDensityUnit.KilogramPerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the AreaDensity quantity.
- ///
- public static AreaDensityUnit[] Units { get; } = Enum.GetValues(typeof(AreaDensityUnit)).Cast().Except(new AreaDensityUnit[]{ AreaDensityUnit.Undefined }).ToArray();
-
- ///
- /// Get AreaDensity in KilogramsPerSquareMeter.
- ///
- public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSquareMeter.
- ///
- public static AreaDensity Zero => new AreaDensity(0, BaseUnit);
-
- ///
- /// Get AreaDensity from KilogramsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaDensity FromKilogramsPerSquareMeter(double kilogramspersquaremeter)
-#else
- public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramspersquaremeter)
-#endif
- {
- double value = (double) kilogramspersquaremeter;
- return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// AreaDensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static AreaDensity From(double value, AreaDensityUnit fromUnit)
-#else
- public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit)
-#endif
- {
- return new AreaDensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AreaDensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is AreaDensity)) throw new ArgumentException("Expected type AreaDensity.", nameof(obj));
-
- return CompareTo((AreaDensity)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(AreaDensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(AreaDensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is AreaDensity))
- return false;
-
- var objQuantity = (AreaDensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another AreaDensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another AreaDensity 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.
- [Obsolete("Please use the Equals(AreaDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(AreaDensity other, AreaDensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current AreaDensity.
- public override int GetHashCode()
- {
- return new { type = typeof(AreaDensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AreaDensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this AreaDensity to another AreaDensity with the unit representation .
- ///
- /// A AreaDensity with the specified unit.
- public AreaDensity ToUnit(AreaDensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new AreaDensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AreaDensityUnit.KilogramPerSquareMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AreaDensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AreaDensityUnit.KilogramPerSquareMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 AreaDensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 AreaDensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AreaDensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AreaDensityUnit ToStringDefaultUnit { get; set; } = AreaDensityUnit.KilogramPerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AreaDensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of AreaDensity
- ///
- public static AreaDensity MaxValue => new AreaDensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of AreaDensity
- ///
- public static AreaDensity MinValue => new AreaDensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => AreaDensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => AreaDensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/AreaMomentOfInertia.Common.g.cs b/Common/GeneratedCode/Quantities/AreaMomentOfInertia.Common.g.cs
deleted file mode 100644
index 0019c55a2d..0000000000
--- a/Common/GeneratedCode/Quantities/AreaMomentOfInertia.Common.g.cs
+++ /dev/null
@@ -1,595 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// A geometric property of an area that reflects how its points are distributed with regard to an axis.
- ///
- // 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 AreaMomentOfInertia : IQuantity
-#else
- public partial struct AreaMomentOfInertia : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly AreaMomentOfInertiaUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static AreaMomentOfInertia()
- {
- BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit MeterToTheFourth.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public AreaMomentOfInertia(double meterstothefourth)
- {
- _value = Convert.ToDouble(meterstothefourth);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- AreaMomentOfInertia(double numericValue, AreaMomentOfInertiaUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterToTheFourth.
- ///
- /// Value assuming base unit MeterToTheFourth.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AreaMomentOfInertia(long meterstothefourth) : this(Convert.ToDouble(meterstothefourth), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterToTheFourth.
- ///
- /// Value assuming base unit MeterToTheFourth.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- AreaMomentOfInertia(decimal meterstothefourth) : this(Convert.ToDouble(meterstothefourth), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.AreaMomentOfInertia;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static AreaMomentOfInertiaUnit BaseUnit => AreaMomentOfInertiaUnit.MeterToTheFourth;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the AreaMomentOfInertia quantity.
- ///
- public static AreaMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().Except(new AreaMomentOfInertiaUnit[]{ AreaMomentOfInertiaUnit.Undefined }).ToArray();
-
- ///
- /// Get AreaMomentOfInertia in CentimetersToTheFourth.
- ///
- public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth);
-
- ///
- /// Get AreaMomentOfInertia in DecimetersToTheFourth.
- ///
- public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth);
-
- ///
- /// Get AreaMomentOfInertia in FeetToTheFourth.
- ///
- public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth);
-
- ///
- /// Get AreaMomentOfInertia in InchesToTheFourth.
- ///
- public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth);
-
- ///
- /// Get AreaMomentOfInertia in MetersToTheFourth.
- ///
- public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth);
-
- ///
- /// Get AreaMomentOfInertia in MillimetersToTheFourth.
- ///
- public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheFourth.
- ///
- public static AreaMomentOfInertia Zero => new AreaMomentOfInertia(0, BaseUnit);
-
- ///
- /// Get AreaMomentOfInertia from CentimetersToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromCentimetersToTheFourth(double centimeterstothefourth)
-#else
- public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centimeterstothefourth)
-#endif
- {
- double value = (double) centimeterstothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth);
- }
-
- ///
- /// Get AreaMomentOfInertia from DecimetersToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromDecimetersToTheFourth(double decimeterstothefourth)
-#else
- public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decimeterstothefourth)
-#endif
- {
- double value = (double) decimeterstothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth);
- }
-
- ///
- /// Get AreaMomentOfInertia from FeetToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromFeetToTheFourth(double feettothefourth)
-#else
- public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefourth)
-#endif
- {
- double value = (double) feettothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth);
- }
-
- ///
- /// Get AreaMomentOfInertia from InchesToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromInchesToTheFourth(double inchestothefourth)
-#else
- public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestothefourth)
-#endif
- {
- double value = (double) inchestothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth);
- }
-
- ///
- /// Get AreaMomentOfInertia from MetersToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromMetersToTheFourth(double meterstothefourth)
-#else
- public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstothefourth)
-#endif
- {
- double value = (double) meterstothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth);
- }
-
- ///
- /// Get AreaMomentOfInertia from MillimetersToTheFourth.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static AreaMomentOfInertia FromMillimetersToTheFourth(double millimeterstothefourth)
-#else
- public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue millimeterstothefourth)
-#endif
- {
- double value = (double) millimeterstothefourth;
- return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// AreaMomentOfInertia unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static AreaMomentOfInertia From(double value, AreaMomentOfInertiaUnit fromUnit)
-#else
- public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaUnit fromUnit)
-#endif
- {
- return new AreaMomentOfInertia((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(AreaMomentOfInertiaUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is AreaMomentOfInertia)) throw new ArgumentException("Expected type AreaMomentOfInertia.", nameof(obj));
-
- return CompareTo((AreaMomentOfInertia)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(AreaMomentOfInertia other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(AreaMomentOfInertia, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is AreaMomentOfInertia))
- return false;
-
- var objQuantity = (AreaMomentOfInertia)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another AreaMomentOfInertia 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.
- [Obsolete("Please use the Equals(AreaMomentOfInertia, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current AreaMomentOfInertia.
- public override int GetHashCode()
- {
- return new { type = typeof(AreaMomentOfInertia), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(AreaMomentOfInertiaUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation .
- ///
- /// A AreaMomentOfInertia with the specified unit.
- public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new AreaMomentOfInertia(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return _value/1e8;
- case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return _value/1e4;
- case AreaMomentOfInertiaUnit.FootToTheFourth: return _value*Math.Pow(0.3048, 4);
- case AreaMomentOfInertiaUnit.InchToTheFourth: return _value*Math.Pow(2.54e-2, 4);
- case AreaMomentOfInertiaUnit.MeterToTheFourth: return _value;
- case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return _value/1e12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(AreaMomentOfInertiaUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return baseUnitValue*1e8;
- case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return baseUnitValue*1e4;
- case AreaMomentOfInertiaUnit.FootToTheFourth: return baseUnitValue/Math.Pow(0.3048, 4);
- case AreaMomentOfInertiaUnit.InchToTheFourth: return baseUnitValue/Math.Pow(2.54e-2, 4);
- case AreaMomentOfInertiaUnit.MeterToTheFourth: return baseUnitValue;
- case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return baseUnitValue*1e12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 AreaMomentOfInertia Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 AreaMomentOfInertia result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static AreaMomentOfInertiaUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is MeterToTheFourth
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static AreaMomentOfInertiaUnit ToStringDefaultUnit { get; set; } = AreaMomentOfInertiaUnit.MeterToTheFourth;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(AreaMomentOfInertiaUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of AreaMomentOfInertia
- ///
- public static AreaMomentOfInertia MaxValue => new AreaMomentOfInertia(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of AreaMomentOfInertia
- ///
- public static AreaMomentOfInertia MinValue => new AreaMomentOfInertia(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => AreaMomentOfInertia.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => AreaMomentOfInertia.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/BitRate.Common.g.cs b/Common/GeneratedCode/Quantities/BitRate.Common.g.cs
deleted file mode 100644
index 23bb99ca85..0000000000
--- a/Common/GeneratedCode/Quantities/BitRate.Common.g.cs
+++ /dev/null
@@ -1,1013 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.
- ///
- // 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 BitRate : IQuantity
-#else
- public partial struct BitRate : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly decimal _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly BitRateUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public BitRateUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static BitRate()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit BitPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public BitRate(double bitspersecond)
- {
- _value = Convert.ToDecimal(bitspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- BitRate(decimal numericValue, BitRateUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit BitPerSecond.
- ///
- /// Value assuming base unit BitPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- BitRate(long bitspersecond) : this(Convert.ToDecimal(bitspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit BitPerSecond.
- ///
- /// Value assuming base unit BitPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- BitRate(decimal bitspersecond) : this(Convert.ToDecimal(bitspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.BitRate;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static BitRateUnit BaseUnit => BitRateUnit.BitPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the BitRate quantity.
- ///
- public static BitRateUnit[] Units { get; } = Enum.GetValues(typeof(BitRateUnit)).Cast().Except(new BitRateUnit[]{ BitRateUnit.Undefined }).ToArray();
-
- ///
- /// Get BitRate in BitsPerSecond.
- ///
- public double BitsPerSecond => As(BitRateUnit.BitPerSecond);
-
- ///
- /// Get BitRate in BytesPerSecond.
- ///
- public double BytesPerSecond => As(BitRateUnit.BytePerSecond);
-
- ///
- /// Get BitRate in ExabitsPerSecond.
- ///
- public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond);
-
- ///
- /// Get BitRate in ExabytesPerSecond.
- ///
- public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond);
-
- ///
- /// Get BitRate in ExbibitsPerSecond.
- ///
- public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond);
-
- ///
- /// Get BitRate in ExbibytesPerSecond.
- ///
- public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond);
-
- ///
- /// Get BitRate in GibibitsPerSecond.
- ///
- public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond);
-
- ///
- /// Get BitRate in GibibytesPerSecond.
- ///
- public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond);
-
- ///
- /// Get BitRate in GigabitsPerSecond.
- ///
- public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond);
-
- ///
- /// Get BitRate in GigabytesPerSecond.
- ///
- public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond);
-
- ///
- /// Get BitRate in KibibitsPerSecond.
- ///
- public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond);
-
- ///
- /// Get BitRate in KibibytesPerSecond.
- ///
- public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond);
-
- ///
- /// Get BitRate in KilobitsPerSecond.
- ///
- public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond);
-
- ///
- /// Get BitRate in KilobytesPerSecond.
- ///
- public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond);
-
- ///
- /// Get BitRate in MebibitsPerSecond.
- ///
- public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond);
-
- ///
- /// Get BitRate in MebibytesPerSecond.
- ///
- public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond);
-
- ///
- /// Get BitRate in MegabitsPerSecond.
- ///
- public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond);
-
- ///
- /// Get BitRate in MegabytesPerSecond.
- ///
- public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond);
-
- ///
- /// Get BitRate in PebibitsPerSecond.
- ///
- public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond);
-
- ///
- /// Get BitRate in PebibytesPerSecond.
- ///
- public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond);
-
- ///
- /// Get BitRate in PetabitsPerSecond.
- ///
- public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond);
-
- ///
- /// Get BitRate in PetabytesPerSecond.
- ///
- public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond);
-
- ///
- /// Get BitRate in TebibitsPerSecond.
- ///
- public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond);
-
- ///
- /// Get BitRate in TebibytesPerSecond.
- ///
- public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond);
-
- ///
- /// Get BitRate in TerabitsPerSecond.
- ///
- public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond);
-
- ///
- /// Get BitRate in TerabytesPerSecond.
- ///
- public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit BitPerSecond.
- ///
- public static BitRate Zero => new BitRate(0, BaseUnit);
-
- ///
- /// Get BitRate from BitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromBitsPerSecond(double bitspersecond)
-#else
- public static BitRate FromBitsPerSecond(QuantityValue bitspersecond)
-#endif
- {
- decimal value = (decimal) bitspersecond;
- return new BitRate(value, BitRateUnit.BitPerSecond);
- }
-
- ///
- /// Get BitRate from BytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromBytesPerSecond(double bytespersecond)
-#else
- public static BitRate FromBytesPerSecond(QuantityValue bytespersecond)
-#endif
- {
- decimal value = (decimal) bytespersecond;
- return new BitRate(value, BitRateUnit.BytePerSecond);
- }
-
- ///
- /// Get BitRate from ExabitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromExabitsPerSecond(double exabitspersecond)
-#else
- public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond)
-#endif
- {
- decimal value = (decimal) exabitspersecond;
- return new BitRate(value, BitRateUnit.ExabitPerSecond);
- }
-
- ///
- /// Get BitRate from ExabytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromExabytesPerSecond(double exabytespersecond)
-#else
- public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond)
-#endif
- {
- decimal value = (decimal) exabytespersecond;
- return new BitRate(value, BitRateUnit.ExabytePerSecond);
- }
-
- ///
- /// Get BitRate from ExbibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromExbibitsPerSecond(double exbibitspersecond)
-#else
- public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond)
-#endif
- {
- decimal value = (decimal) exbibitspersecond;
- return new BitRate(value, BitRateUnit.ExbibitPerSecond);
- }
-
- ///
- /// Get BitRate from ExbibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromExbibytesPerSecond(double exbibytespersecond)
-#else
- public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond)
-#endif
- {
- decimal value = (decimal) exbibytespersecond;
- return new BitRate(value, BitRateUnit.ExbibytePerSecond);
- }
-
- ///
- /// Get BitRate from GibibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromGibibitsPerSecond(double gibibitspersecond)
-#else
- public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond)
-#endif
- {
- decimal value = (decimal) gibibitspersecond;
- return new BitRate(value, BitRateUnit.GibibitPerSecond);
- }
-
- ///
- /// Get BitRate from GibibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromGibibytesPerSecond(double gibibytespersecond)
-#else
- public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond)
-#endif
- {
- decimal value = (decimal) gibibytespersecond;
- return new BitRate(value, BitRateUnit.GibibytePerSecond);
- }
-
- ///
- /// Get BitRate from GigabitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromGigabitsPerSecond(double gigabitspersecond)
-#else
- public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond)
-#endif
- {
- decimal value = (decimal) gigabitspersecond;
- return new BitRate(value, BitRateUnit.GigabitPerSecond);
- }
-
- ///
- /// Get BitRate from GigabytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromGigabytesPerSecond(double gigabytespersecond)
-#else
- public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond)
-#endif
- {
- decimal value = (decimal) gigabytespersecond;
- return new BitRate(value, BitRateUnit.GigabytePerSecond);
- }
-
- ///
- /// Get BitRate from KibibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromKibibitsPerSecond(double kibibitspersecond)
-#else
- public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond)
-#endif
- {
- decimal value = (decimal) kibibitspersecond;
- return new BitRate(value, BitRateUnit.KibibitPerSecond);
- }
-
- ///
- /// Get BitRate from KibibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromKibibytesPerSecond(double kibibytespersecond)
-#else
- public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond)
-#endif
- {
- decimal value = (decimal) kibibytespersecond;
- return new BitRate(value, BitRateUnit.KibibytePerSecond);
- }
-
- ///
- /// Get BitRate from KilobitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromKilobitsPerSecond(double kilobitspersecond)
-#else
- public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond)
-#endif
- {
- decimal value = (decimal) kilobitspersecond;
- return new BitRate(value, BitRateUnit.KilobitPerSecond);
- }
-
- ///
- /// Get BitRate from KilobytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromKilobytesPerSecond(double kilobytespersecond)
-#else
- public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond)
-#endif
- {
- decimal value = (decimal) kilobytespersecond;
- return new BitRate(value, BitRateUnit.KilobytePerSecond);
- }
-
- ///
- /// Get BitRate from MebibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromMebibitsPerSecond(double mebibitspersecond)
-#else
- public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond)
-#endif
- {
- decimal value = (decimal) mebibitspersecond;
- return new BitRate(value, BitRateUnit.MebibitPerSecond);
- }
-
- ///
- /// Get BitRate from MebibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromMebibytesPerSecond(double mebibytespersecond)
-#else
- public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond)
-#endif
- {
- decimal value = (decimal) mebibytespersecond;
- return new BitRate(value, BitRateUnit.MebibytePerSecond);
- }
-
- ///
- /// Get BitRate from MegabitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromMegabitsPerSecond(double megabitspersecond)
-#else
- public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond)
-#endif
- {
- decimal value = (decimal) megabitspersecond;
- return new BitRate(value, BitRateUnit.MegabitPerSecond);
- }
-
- ///
- /// Get BitRate from MegabytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromMegabytesPerSecond(double megabytespersecond)
-#else
- public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond)
-#endif
- {
- decimal value = (decimal) megabytespersecond;
- return new BitRate(value, BitRateUnit.MegabytePerSecond);
- }
-
- ///
- /// Get BitRate from PebibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromPebibitsPerSecond(double pebibitspersecond)
-#else
- public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond)
-#endif
- {
- decimal value = (decimal) pebibitspersecond;
- return new BitRate(value, BitRateUnit.PebibitPerSecond);
- }
-
- ///
- /// Get BitRate from PebibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromPebibytesPerSecond(double pebibytespersecond)
-#else
- public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond)
-#endif
- {
- decimal value = (decimal) pebibytespersecond;
- return new BitRate(value, BitRateUnit.PebibytePerSecond);
- }
-
- ///
- /// Get BitRate from PetabitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromPetabitsPerSecond(double petabitspersecond)
-#else
- public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond)
-#endif
- {
- decimal value = (decimal) petabitspersecond;
- return new BitRate(value, BitRateUnit.PetabitPerSecond);
- }
-
- ///
- /// Get BitRate from PetabytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromPetabytesPerSecond(double petabytespersecond)
-#else
- public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond)
-#endif
- {
- decimal value = (decimal) petabytespersecond;
- return new BitRate(value, BitRateUnit.PetabytePerSecond);
- }
-
- ///
- /// Get BitRate from TebibitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromTebibitsPerSecond(double tebibitspersecond)
-#else
- public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond)
-#endif
- {
- decimal value = (decimal) tebibitspersecond;
- return new BitRate(value, BitRateUnit.TebibitPerSecond);
- }
-
- ///
- /// Get BitRate from TebibytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromTebibytesPerSecond(double tebibytespersecond)
-#else
- public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond)
-#endif
- {
- decimal value = (decimal) tebibytespersecond;
- return new BitRate(value, BitRateUnit.TebibytePerSecond);
- }
-
- ///
- /// Get BitRate from TerabitsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromTerabitsPerSecond(double terabitspersecond)
-#else
- public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond)
-#endif
- {
- decimal value = (decimal) terabitspersecond;
- return new BitRate(value, BitRateUnit.TerabitPerSecond);
- }
-
- ///
- /// Get BitRate from TerabytesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BitRate FromTerabytesPerSecond(double terabytespersecond)
-#else
- public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond)
-#endif
- {
- decimal value = (decimal) terabytespersecond;
- return new BitRate(value, BitRateUnit.TerabytePerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// BitRate unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static BitRate From(double value, BitRateUnit fromUnit)
-#else
- public static BitRate From(QuantityValue value, BitRateUnit fromUnit)
-#endif
- {
- return new BitRate((decimal)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(BitRateUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is BitRate)) throw new ArgumentException("Expected type BitRate.", nameof(obj));
-
- return CompareTo((BitRate)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(BitRate other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is BitRate))
- return false;
-
- var objQuantity = (BitRate)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another BitRate within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another BitRate 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.
- [Obsolete("Please use the Equals(BitRate, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(BitRate other, BitRate maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current BitRate.
- public override int GetHashCode()
- {
- return new { type = typeof(BitRate), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(BitRateUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this BitRate to another BitRate with the unit representation .
- ///
- /// A BitRate with the specified unit.
- public BitRate ToUnit(BitRateUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new BitRate(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private decimal AsBaseUnit()
- {
- switch(Unit)
- {
- case BitRateUnit.BitPerSecond: return _value;
- case BitRateUnit.BytePerSecond: return _value*8m;
- case BitRateUnit.ExabitPerSecond: return (_value) * 1e18m;
- case BitRateUnit.ExabytePerSecond: return (_value*8m) * 1e18m;
- case BitRateUnit.ExbibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.ExbibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.GibibitPerSecond: return (_value) * (1024m * 1024 * 1024);
- case BitRateUnit.GibibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024);
- case BitRateUnit.GigabitPerSecond: return (_value) * 1e9m;
- case BitRateUnit.GigabytePerSecond: return (_value*8m) * 1e9m;
- case BitRateUnit.KibibitPerSecond: return (_value) * 1024m;
- case BitRateUnit.KibibytePerSecond: return (_value*8m) * 1024m;
- case BitRateUnit.KilobitPerSecond: return (_value) * 1e3m;
- case BitRateUnit.KilobytePerSecond: return (_value*8m) * 1e3m;
- case BitRateUnit.MebibitPerSecond: return (_value) * (1024m * 1024);
- case BitRateUnit.MebibytePerSecond: return (_value*8m) * (1024m * 1024);
- case BitRateUnit.MegabitPerSecond: return (_value) * 1e6m;
- case BitRateUnit.MegabytePerSecond: return (_value*8m) * 1e6m;
- case BitRateUnit.PebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.PebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.PetabitPerSecond: return (_value) * 1e15m;
- case BitRateUnit.PetabytePerSecond: return (_value*8m) * 1e15m;
- case BitRateUnit.TebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024);
- case BitRateUnit.TebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024);
- case BitRateUnit.TerabitPerSecond: return (_value) * 1e12m;
- case BitRateUnit.TerabytePerSecond: return (_value*8m) * 1e12m;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private decimal AsBaseNumericType(BitRateUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case BitRateUnit.BitPerSecond: return baseUnitValue;
- case BitRateUnit.BytePerSecond: return baseUnitValue/8m;
- case BitRateUnit.ExabitPerSecond: return (baseUnitValue) / 1e18m;
- case BitRateUnit.ExabytePerSecond: return (baseUnitValue/8m) / 1e18m;
- case BitRateUnit.ExbibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.ExbibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.GibibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024);
- case BitRateUnit.GibibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024);
- case BitRateUnit.GigabitPerSecond: return (baseUnitValue) / 1e9m;
- case BitRateUnit.GigabytePerSecond: return (baseUnitValue/8m) / 1e9m;
- case BitRateUnit.KibibitPerSecond: return (baseUnitValue) / 1024m;
- case BitRateUnit.KibibytePerSecond: return (baseUnitValue/8m) / 1024m;
- case BitRateUnit.KilobitPerSecond: return (baseUnitValue) / 1e3m;
- case BitRateUnit.KilobytePerSecond: return (baseUnitValue/8m) / 1e3m;
- case BitRateUnit.MebibitPerSecond: return (baseUnitValue) / (1024m * 1024);
- case BitRateUnit.MebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024);
- case BitRateUnit.MegabitPerSecond: return (baseUnitValue) / 1e6m;
- case BitRateUnit.MegabytePerSecond: return (baseUnitValue/8m) / 1e6m;
- case BitRateUnit.PebibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.PebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024);
- case BitRateUnit.PetabitPerSecond: return (baseUnitValue) / 1e15m;
- case BitRateUnit.PetabytePerSecond: return (baseUnitValue/8m) / 1e15m;
- case BitRateUnit.TebibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024);
- case BitRateUnit.TebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024);
- case BitRateUnit.TerabitPerSecond: return (baseUnitValue) / 1e12m;
- case BitRateUnit.TerabytePerSecond: return (baseUnitValue/8m) / 1e12m;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 BitRate Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 BitRate result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static BitRateUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is BitPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static BitRateUnit ToStringDefaultUnit { get; set; } = BitRateUnit.BitPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(BitRateUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of BitRate
- ///
- public static BitRate MaxValue => new BitRate(decimal.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of BitRate
- ///
- public static BitRate MinValue => new BitRate(decimal.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => BitRate.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => BitRate.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.Common.g.cs b/Common/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.Common.g.cs
deleted file mode 100644
index 1fd284c02c..0000000000
--- a/Common/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 BrakeSpecificFuelConsumption : IQuantity
-#else
- public partial struct BrakeSpecificFuelConsumption : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly BrakeSpecificFuelConsumptionUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static BrakeSpecificFuelConsumption()
- {
- BaseDimensions = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerJoule.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public BrakeSpecificFuelConsumption(double kilogramsperjoule)
- {
- _value = Convert.ToDouble(kilogramsperjoule);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- BrakeSpecificFuelConsumption(double numericValue, BrakeSpecificFuelConsumptionUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerJoule.
- ///
- /// Value assuming base unit KilogramPerJoule.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- BrakeSpecificFuelConsumption(long kilogramsperjoule) : this(Convert.ToDouble(kilogramsperjoule), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerJoule.
- ///
- /// Value assuming base unit KilogramPerJoule.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- BrakeSpecificFuelConsumption(decimal kilogramsperjoule) : this(Convert.ToDouble(kilogramsperjoule), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.BrakeSpecificFuelConsumption;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static BrakeSpecificFuelConsumptionUnit BaseUnit => BrakeSpecificFuelConsumptionUnit.KilogramPerJoule;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the BrakeSpecificFuelConsumption quantity.
- ///
- public static BrakeSpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().Except(new BrakeSpecificFuelConsumptionUnit[]{ BrakeSpecificFuelConsumptionUnit.Undefined }).ToArray();
-
- ///
- /// Get BrakeSpecificFuelConsumption in GramsPerKiloWattHour.
- ///
- public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour);
-
- ///
- /// Get BrakeSpecificFuelConsumption in KilogramsPerJoule.
- ///
- public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule);
-
- ///
- /// Get BrakeSpecificFuelConsumption in PoundsPerMechanicalHorsepowerHour.
- ///
- public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerJoule.
- ///
- public static BrakeSpecificFuelConsumption Zero => new BrakeSpecificFuelConsumption(0, BaseUnit);
-
- ///
- /// Get BrakeSpecificFuelConsumption from GramsPerKiloWattHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(double gramsperkilowatthour)
-#else
- public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValue gramsperkilowatthour)
-#endif
- {
- double value = (double) gramsperkilowatthour;
- return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour);
- }
-
- ///
- /// Get BrakeSpecificFuelConsumption from KilogramsPerJoule.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(double kilogramsperjoule)
-#else
- public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue kilogramsperjoule)
-#endif
- {
- double value = (double) kilogramsperjoule;
- return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule);
- }
-
- ///
- /// Get BrakeSpecificFuelConsumption from PoundsPerMechanicalHorsepowerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(double poundspermechanicalhorsepowerhour)
-#else
- public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(QuantityValue poundspermechanicalhorsepowerhour)
-#endif
- {
- double value = (double) poundspermechanicalhorsepowerhour;
- return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// BrakeSpecificFuelConsumption unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static BrakeSpecificFuelConsumption From(double value, BrakeSpecificFuelConsumptionUnit fromUnit)
-#else
- public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecificFuelConsumptionUnit fromUnit)
-#endif
- {
- return new BrakeSpecificFuelConsumption((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is BrakeSpecificFuelConsumption)) throw new ArgumentException("Expected type BrakeSpecificFuelConsumption.", nameof(obj));
-
- return CompareTo((BrakeSpecificFuelConsumption)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(BrakeSpecificFuelConsumption other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(BrakeSpecificFuelConsumption, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is BrakeSpecificFuelConsumption))
- return false;
-
- var objQuantity = (BrakeSpecificFuelConsumption)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another BrakeSpecificFuelConsumption 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.
- [Obsolete("Please use the Equals(BrakeSpecificFuelConsumption, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current BrakeSpecificFuelConsumption.
- public override int GetHashCode()
- {
- return new { type = typeof(BrakeSpecificFuelConsumption), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(BrakeSpecificFuelConsumptionUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation .
- ///
- /// A BrakeSpecificFuelConsumption with the specified unit.
- public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new BrakeSpecificFuelConsumption(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return _value/3.6e9;
- case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return _value;
- case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return _value*1.689659410672e-7;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(BrakeSpecificFuelConsumptionUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return baseUnitValue*3.6e9;
- case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return baseUnitValue;
- case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return baseUnitValue/1.689659410672e-7;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 BrakeSpecificFuelConsumption Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 BrakeSpecificFuelConsumption result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerJoule
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static BrakeSpecificFuelConsumptionUnit ToStringDefaultUnit { get; set; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(BrakeSpecificFuelConsumptionUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of BrakeSpecificFuelConsumption
- ///
- public static BrakeSpecificFuelConsumption MaxValue => new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of BrakeSpecificFuelConsumption
- ///
- public static BrakeSpecificFuelConsumption MinValue => new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => BrakeSpecificFuelConsumption.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => BrakeSpecificFuelConsumption.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Capacitance.Common.g.cs b/Common/GeneratedCode/Quantities/Capacitance.Common.g.cs
deleted file mode 100644
index 09f737ed23..0000000000
--- a/Common/GeneratedCode/Quantities/Capacitance.Common.g.cs
+++ /dev/null
@@ -1,574 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Capacitance is the ability of a body to store an electric charge.
- ///
- // 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 Capacitance : IQuantity
-#else
- public partial struct Capacitance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly CapacitanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public CapacitanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Capacitance()
- {
- BaseDimensions = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Farad.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Capacitance(double farads)
- {
- _value = Convert.ToDouble(farads);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Capacitance(double numericValue, CapacitanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Farad.
- ///
- /// Value assuming base unit Farad.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Capacitance(long farads) : this(Convert.ToDouble(farads), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Farad.
- ///
- /// Value assuming base unit Farad.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Capacitance(decimal farads) : this(Convert.ToDouble(farads), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Capacitance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static CapacitanceUnit BaseUnit => CapacitanceUnit.Farad;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Capacitance quantity.
- ///
- public static CapacitanceUnit[] Units { get; } = Enum.GetValues(typeof(CapacitanceUnit)).Cast().Except(new CapacitanceUnit[]{ CapacitanceUnit.Undefined }).ToArray();
-
- ///
- /// Get Capacitance in Farads.
- ///
- public double Farads => As(CapacitanceUnit.Farad);
-
- ///
- /// Get Capacitance in Microfarads.
- ///
- public double Microfarads => As(CapacitanceUnit.Microfarad);
-
- ///
- /// Get Capacitance in Millifarads.
- ///
- public double Millifarads => As(CapacitanceUnit.Millifarad);
-
- ///
- /// Get Capacitance in Nanofarads.
- ///
- public double Nanofarads => As(CapacitanceUnit.Nanofarad);
-
- ///
- /// Get Capacitance in Picofarads.
- ///
- public double Picofarads => As(CapacitanceUnit.Picofarad);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Farad.
- ///
- public static Capacitance Zero => new Capacitance(0, BaseUnit);
-
- ///
- /// Get Capacitance from Farads.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Capacitance FromFarads(double farads)
-#else
- public static Capacitance FromFarads(QuantityValue farads)
-#endif
- {
- double value = (double) farads;
- return new Capacitance(value, CapacitanceUnit.Farad);
- }
-
- ///
- /// Get Capacitance from Microfarads.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Capacitance FromMicrofarads(double microfarads)
-#else
- public static Capacitance FromMicrofarads(QuantityValue microfarads)
-#endif
- {
- double value = (double) microfarads;
- return new Capacitance(value, CapacitanceUnit.Microfarad);
- }
-
- ///
- /// Get Capacitance from Millifarads.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Capacitance FromMillifarads(double millifarads)
-#else
- public static Capacitance FromMillifarads(QuantityValue millifarads)
-#endif
- {
- double value = (double) millifarads;
- return new Capacitance(value, CapacitanceUnit.Millifarad);
- }
-
- ///
- /// Get Capacitance from Nanofarads.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Capacitance FromNanofarads(double nanofarads)
-#else
- public static Capacitance FromNanofarads(QuantityValue nanofarads)
-#endif
- {
- double value = (double) nanofarads;
- return new Capacitance(value, CapacitanceUnit.Nanofarad);
- }
-
- ///
- /// Get Capacitance from Picofarads.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Capacitance FromPicofarads(double picofarads)
-#else
- public static Capacitance FromPicofarads(QuantityValue picofarads)
-#endif
- {
- double value = (double) picofarads;
- return new Capacitance(value, CapacitanceUnit.Picofarad);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Capacitance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Capacitance From(double value, CapacitanceUnit fromUnit)
-#else
- public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit)
-#endif
- {
- return new Capacitance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(CapacitanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Capacitance)) throw new ArgumentException("Expected type Capacitance.", nameof(obj));
-
- return CompareTo((Capacitance)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(Capacitance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Capacitance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Capacitance))
- return false;
-
- var objQuantity = (Capacitance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Capacitance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Capacitance 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.
- [Obsolete("Please use the Equals(Capacitance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Capacitance other, Capacitance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Capacitance.
- public override int GetHashCode()
- {
- return new { type = typeof(Capacitance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(CapacitanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Capacitance to another Capacitance with the unit representation .
- ///
- /// A Capacitance with the specified unit.
- public Capacitance ToUnit(CapacitanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Capacitance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case CapacitanceUnit.Farad: return _value;
- case CapacitanceUnit.Microfarad: return (_value) * 1e-6d;
- case CapacitanceUnit.Millifarad: return (_value) * 1e-3d;
- case CapacitanceUnit.Nanofarad: return (_value) * 1e-9d;
- case CapacitanceUnit.Picofarad: return (_value) * 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(CapacitanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case CapacitanceUnit.Farad: return baseUnitValue;
- case CapacitanceUnit.Microfarad: return (baseUnitValue) / 1e-6d;
- case CapacitanceUnit.Millifarad: return (baseUnitValue) / 1e-3d;
- case CapacitanceUnit.Nanofarad: return (baseUnitValue) / 1e-9d;
- case CapacitanceUnit.Picofarad: return (baseUnitValue) / 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Capacitance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Capacitance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static CapacitanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Farad
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static CapacitanceUnit ToStringDefaultUnit { get; set; } = CapacitanceUnit.Farad;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(CapacitanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Capacitance
- ///
- public static Capacitance MaxValue => new Capacitance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Capacitance
- ///
- public static Capacitance MinValue => new Capacitance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Capacitance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Capacitance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/CoefficientOfThermalExpansion.Common.g.cs b/Common/GeneratedCode/Quantities/CoefficientOfThermalExpansion.Common.g.cs
deleted file mode 100644
index c4590533c0..0000000000
--- a/Common/GeneratedCode/Quantities/CoefficientOfThermalExpansion.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// A unit that represents a fractional change in size in response to a change in temperature.
- ///
- // 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 CoefficientOfThermalExpansion : IQuantity
-#else
- public partial struct CoefficientOfThermalExpansion : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly CoefficientOfThermalExpansionUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static CoefficientOfThermalExpansion()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 0, -1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit InverseKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public CoefficientOfThermalExpansion(double inversekelvin)
- {
- _value = Convert.ToDouble(inversekelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- CoefficientOfThermalExpansion(double numericValue, CoefficientOfThermalExpansionUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit InverseKelvin.
- ///
- /// Value assuming base unit InverseKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- CoefficientOfThermalExpansion(long inversekelvin) : this(Convert.ToDouble(inversekelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit InverseKelvin.
- ///
- /// Value assuming base unit InverseKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- CoefficientOfThermalExpansion(decimal inversekelvin) : this(Convert.ToDouble(inversekelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.CoefficientOfThermalExpansion;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static CoefficientOfThermalExpansionUnit BaseUnit => CoefficientOfThermalExpansionUnit.InverseKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the CoefficientOfThermalExpansion quantity.
- ///
- public static CoefficientOfThermalExpansionUnit[] Units { get; } = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().Except(new CoefficientOfThermalExpansionUnit[]{ CoefficientOfThermalExpansionUnit.Undefined }).ToArray();
-
- ///
- /// Get CoefficientOfThermalExpansion in InverseDegreeCelsius.
- ///
- public double InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius);
-
- ///
- /// Get CoefficientOfThermalExpansion in InverseDegreeFahrenheit.
- ///
- public double InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit);
-
- ///
- /// Get CoefficientOfThermalExpansion in InverseKelvin.
- ///
- public double InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit InverseKelvin.
- ///
- public static CoefficientOfThermalExpansion Zero => new CoefficientOfThermalExpansion(0, BaseUnit);
-
- ///
- /// Get CoefficientOfThermalExpansion from InverseDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(double inversedegreecelsius)
-#else
- public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityValue inversedegreecelsius)
-#endif
- {
- double value = (double) inversedegreecelsius;
- return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius);
- }
-
- ///
- /// Get CoefficientOfThermalExpansion from InverseDegreeFahrenheit.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(double inversedegreefahrenheit)
-#else
- public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(QuantityValue inversedegreefahrenheit)
-#endif
- {
- double value = (double) inversedegreefahrenheit;
- return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit);
- }
-
- ///
- /// Get CoefficientOfThermalExpansion from InverseKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static CoefficientOfThermalExpansion FromInverseKelvin(double inversekelvin)
-#else
- public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inversekelvin)
-#endif
- {
- double value = (double) inversekelvin;
- return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// CoefficientOfThermalExpansion unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static CoefficientOfThermalExpansion From(double value, CoefficientOfThermalExpansionUnit fromUnit)
-#else
- public static CoefficientOfThermalExpansion From(QuantityValue value, CoefficientOfThermalExpansionUnit fromUnit)
-#endif
- {
- return new CoefficientOfThermalExpansion((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is CoefficientOfThermalExpansion)) throw new ArgumentException("Expected type CoefficientOfThermalExpansion.", nameof(obj));
-
- return CompareTo((CoefficientOfThermalExpansion)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(CoefficientOfThermalExpansion other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(CoefficientOfThermalExpansion, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is CoefficientOfThermalExpansion))
- return false;
-
- var objQuantity = (CoefficientOfThermalExpansion)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another CoefficientOfThermalExpansion 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.
- [Obsolete("Please use the Equals(CoefficientOfThermalExpansion, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current CoefficientOfThermalExpansion.
- public override int GetHashCode()
- {
- return new { type = typeof(CoefficientOfThermalExpansion), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(CoefficientOfThermalExpansionUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this CoefficientOfThermalExpansion to another CoefficientOfThermalExpansion with the unit representation .
- ///
- /// A CoefficientOfThermalExpansion with the specified unit.
- public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new CoefficientOfThermalExpansion(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return _value;
- case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return _value*5/9;
- case CoefficientOfThermalExpansionUnit.InverseKelvin: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(CoefficientOfThermalExpansionUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return baseUnitValue;
- case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return baseUnitValue*9/5;
- case CoefficientOfThermalExpansionUnit.InverseKelvin: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 CoefficientOfThermalExpansion Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 CoefficientOfThermalExpansion result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static CoefficientOfThermalExpansionUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is InverseKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static CoefficientOfThermalExpansionUnit ToStringDefaultUnit { get; set; } = CoefficientOfThermalExpansionUnit.InverseKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(CoefficientOfThermalExpansionUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of CoefficientOfThermalExpansion
- ///
- public static CoefficientOfThermalExpansion MaxValue => new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of CoefficientOfThermalExpansion
- ///
- public static CoefficientOfThermalExpansion MinValue => new CoefficientOfThermalExpansion(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => CoefficientOfThermalExpansion.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => CoefficientOfThermalExpansion.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Density.Common.g.cs b/Common/GeneratedCode/Quantities/Density.Common.g.cs
deleted file mode 100644
index e6b53a129f..0000000000
--- a/Common/GeneratedCode/Quantities/Density.Common.g.cs
+++ /dev/null
@@ -1,1267 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.
- ///
- // 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 Density : IQuantity
-#else
- public partial struct Density : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly DensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public DensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Density()
- {
- BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerCubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Density(double kilogramspercubicmeter)
- {
- _value = Convert.ToDouble(kilogramspercubicmeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Density(double numericValue, DensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerCubicMeter.
- ///
- /// Value assuming base unit KilogramPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Density(long kilogramspercubicmeter) : this(Convert.ToDouble(kilogramspercubicmeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerCubicMeter.
- ///
- /// Value assuming base unit KilogramPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Density(decimal kilogramspercubicmeter) : this(Convert.ToDouble(kilogramspercubicmeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Density;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static DensityUnit BaseUnit => DensityUnit.KilogramPerCubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Density quantity.
- ///
- public static DensityUnit[] Units { get; } = Enum.GetValues(typeof(DensityUnit)).Cast().Except(new DensityUnit[]{ DensityUnit.Undefined }).ToArray();
-
- ///
- /// Get Density in CentigramsPerDeciLiter.
- ///
- public double CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter);
-
- ///
- /// Get Density in CentigramsPerLiter.
- ///
- public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter);
-
- ///
- /// Get Density in CentigramsPerMilliliter.
- ///
- public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter);
-
- ///
- /// Get Density in DecigramsPerDeciLiter.
- ///
- public double DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter);
-
- ///
- /// Get Density in DecigramsPerLiter.
- ///
- public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter);
-
- ///
- /// Get Density in DecigramsPerMilliliter.
- ///
- public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter);
-
- ///
- /// Get Density in GramsPerCubicCentimeter.
- ///
- public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter);
-
- ///
- /// Get Density in GramsPerCubicMeter.
- ///
- public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter);
-
- ///
- /// Get Density in GramsPerCubicMillimeter.
- ///
- public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter);
-
- ///
- /// Get Density in GramsPerDeciLiter.
- ///
- public double GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter);
-
- ///
- /// Get Density in GramsPerLiter.
- ///
- public double GramsPerLiter => As(DensityUnit.GramPerLiter);
-
- ///
- /// Get Density in GramsPerMilliliter.
- ///
- public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter);
-
- ///
- /// Get Density in KilogramsPerCubicCentimeter.
- ///
- public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter);
-
- ///
- /// Get Density in KilogramsPerCubicMeter.
- ///
- public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter);
-
- ///
- /// Get Density in KilogramsPerCubicMillimeter.
- ///
- public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter);
-
- ///
- /// Get Density in KilopoundsPerCubicFoot.
- ///
- public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot);
-
- ///
- /// Get Density in KilopoundsPerCubicInch.
- ///
- public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch);
-
- ///
- /// Get Density in MicrogramsPerDeciLiter.
- ///
- public double MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter);
-
- ///
- /// Get Density in MicrogramsPerLiter.
- ///
- public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter);
-
- ///
- /// Get Density in MicrogramsPerMilliliter.
- ///
- public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter);
-
- ///
- /// Get Density in MilligramsPerCubicMeter.
- ///
- public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter);
-
- ///
- /// Get Density in MilligramsPerDeciLiter.
- ///
- public double MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter);
-
- ///
- /// Get Density in MilligramsPerLiter.
- ///
- public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter);
-
- ///
- /// Get Density in MilligramsPerMilliliter.
- ///
- public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter);
-
- ///
- /// Get Density in NanogramsPerDeciLiter.
- ///
- public double NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter);
-
- ///
- /// Get Density in NanogramsPerLiter.
- ///
- public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter);
-
- ///
- /// Get Density in NanogramsPerMilliliter.
- ///
- public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter);
-
- ///
- /// Get Density in PicogramsPerDeciLiter.
- ///
- public double PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter);
-
- ///
- /// Get Density in PicogramsPerLiter.
- ///
- public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter);
-
- ///
- /// Get Density in PicogramsPerMilliliter.
- ///
- public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter);
-
- ///
- /// Get Density in PoundsPerCubicFoot.
- ///
- public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot);
-
- ///
- /// Get Density in PoundsPerCubicInch.
- ///
- public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch);
-
- ///
- /// Get Density in PoundsPerImperialGallon.
- ///
- public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon);
-
- ///
- /// Get Density in PoundsPerUSGallon.
- ///
- public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon);
-
- ///
- /// Get Density in SlugsPerCubicFoot.
- ///
- public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot);
-
- ///
- /// Get Density in TonnesPerCubicCentimeter.
- ///
- public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter);
-
- ///
- /// Get Density in TonnesPerCubicMeter.
- ///
- public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter);
-
- ///
- /// Get Density in TonnesPerCubicMillimeter.
- ///
- public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter.
- ///
- public static Density Zero => new Density(0, BaseUnit);
-
- ///
- /// Get Density from CentigramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromCentigramsPerDeciLiter(double centigramsperdeciliter)
-#else
- public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeciliter)
-#endif
- {
- double value = (double) centigramsperdeciliter;
- return new Density(value, DensityUnit.CentigramPerDeciliter);
- }
-
- ///
- /// Get Density from CentigramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromCentigramsPerLiter(double centigramsperliter)
-#else
- public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter)
-#endif
- {
- double value = (double) centigramsperliter;
- return new Density(value, DensityUnit.CentigramPerLiter);
- }
-
- ///
- /// Get Density from CentigramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromCentigramsPerMilliliter(double centigramspermilliliter)
-#else
- public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter)
-#endif
- {
- double value = (double) centigramspermilliliter;
- return new Density(value, DensityUnit.CentigramPerMilliliter);
- }
-
- ///
- /// Get Density from DecigramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromDecigramsPerDeciLiter(double decigramsperdeciliter)
-#else
- public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdeciliter)
-#endif
- {
- double value = (double) decigramsperdeciliter;
- return new Density(value, DensityUnit.DecigramPerDeciliter);
- }
-
- ///
- /// Get Density from DecigramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromDecigramsPerLiter(double decigramsperliter)
-#else
- public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter)
-#endif
- {
- double value = (double) decigramsperliter;
- return new Density(value, DensityUnit.DecigramPerLiter);
- }
-
- ///
- /// Get Density from DecigramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromDecigramsPerMilliliter(double decigramspermilliliter)
-#else
- public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter)
-#endif
- {
- double value = (double) decigramspermilliliter;
- return new Density(value, DensityUnit.DecigramPerMilliliter);
- }
-
- ///
- /// Get Density from GramsPerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerCubicCentimeter(double gramspercubiccentimeter)
-#else
- public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter)
-#endif
- {
- double value = (double) gramspercubiccentimeter;
- return new Density(value, DensityUnit.GramPerCubicCentimeter);
- }
-
- ///
- /// Get Density from GramsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerCubicMeter(double gramspercubicmeter)
-#else
- public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter)
-#endif
- {
- double value = (double) gramspercubicmeter;
- return new Density(value, DensityUnit.GramPerCubicMeter);
- }
-
- ///
- /// Get Density from GramsPerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerCubicMillimeter(double gramspercubicmillimeter)
-#else
- public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter)
-#endif
- {
- double value = (double) gramspercubicmillimeter;
- return new Density(value, DensityUnit.GramPerCubicMillimeter);
- }
-
- ///
- /// Get Density from GramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerDeciLiter(double gramsperdeciliter)
-#else
- public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter)
-#endif
- {
- double value = (double) gramsperdeciliter;
- return new Density(value, DensityUnit.GramPerDeciliter);
- }
-
- ///
- /// Get Density from GramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerLiter(double gramsperliter)
-#else
- public static Density FromGramsPerLiter(QuantityValue gramsperliter)
-#endif
- {
- double value = (double) gramsperliter;
- return new Density(value, DensityUnit.GramPerLiter);
- }
-
- ///
- /// Get Density from GramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromGramsPerMilliliter(double gramspermilliliter)
-#else
- public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter)
-#endif
- {
- double value = (double) gramspermilliliter;
- return new Density(value, DensityUnit.GramPerMilliliter);
- }
-
- ///
- /// Get Density from KilogramsPerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromKilogramsPerCubicCentimeter(double kilogramspercubiccentimeter)
-#else
- public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter)
-#endif
- {
- double value = (double) kilogramspercubiccentimeter;
- return new Density(value, DensityUnit.KilogramPerCubicCentimeter);
- }
-
- ///
- /// Get Density from KilogramsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromKilogramsPerCubicMeter(double kilogramspercubicmeter)
-#else
- public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter)
-#endif
- {
- double value = (double) kilogramspercubicmeter;
- return new Density(value, DensityUnit.KilogramPerCubicMeter);
- }
-
- ///
- /// Get Density from KilogramsPerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromKilogramsPerCubicMillimeter(double kilogramspercubicmillimeter)
-#else
- public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter)
-#endif
- {
- double value = (double) kilogramspercubicmillimeter;
- return new Density(value, DensityUnit.KilogramPerCubicMillimeter);
- }
-
- ///
- /// Get Density from KilopoundsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromKilopoundsPerCubicFoot(double kilopoundspercubicfoot)
-#else
- public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot)
-#endif
- {
- double value = (double) kilopoundspercubicfoot;
- return new Density(value, DensityUnit.KilopoundPerCubicFoot);
- }
-
- ///
- /// Get Density from KilopoundsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromKilopoundsPerCubicInch(double kilopoundspercubicinch)
-#else
- public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch)
-#endif
- {
- double value = (double) kilopoundspercubicinch;
- return new Density(value, DensityUnit.KilopoundPerCubicInch);
- }
-
- ///
- /// Get Density from MicrogramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMicrogramsPerDeciLiter(double microgramsperdeciliter)
-#else
- public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeciliter)
-#endif
- {
- double value = (double) microgramsperdeciliter;
- return new Density(value, DensityUnit.MicrogramPerDeciliter);
- }
-
- ///
- /// Get Density from MicrogramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMicrogramsPerLiter(double microgramsperliter)
-#else
- public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter)
-#endif
- {
- double value = (double) microgramsperliter;
- return new Density(value, DensityUnit.MicrogramPerLiter);
- }
-
- ///
- /// Get Density from MicrogramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMicrogramsPerMilliliter(double microgramspermilliliter)
-#else
- public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter)
-#endif
- {
- double value = (double) microgramspermilliliter;
- return new Density(value, DensityUnit.MicrogramPerMilliliter);
- }
-
- ///
- /// Get Density from MilligramsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMilligramsPerCubicMeter(double milligramspercubicmeter)
-#else
- public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter)
-#endif
- {
- double value = (double) milligramspercubicmeter;
- return new Density(value, DensityUnit.MilligramPerCubicMeter);
- }
-
- ///
- /// Get Density from MilligramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMilligramsPerDeciLiter(double milligramsperdeciliter)
-#else
- public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeciliter)
-#endif
- {
- double value = (double) milligramsperdeciliter;
- return new Density(value, DensityUnit.MilligramPerDeciliter);
- }
-
- ///
- /// Get Density from MilligramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMilligramsPerLiter(double milligramsperliter)
-#else
- public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter)
-#endif
- {
- double value = (double) milligramsperliter;
- return new Density(value, DensityUnit.MilligramPerLiter);
- }
-
- ///
- /// Get Density from MilligramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromMilligramsPerMilliliter(double milligramspermilliliter)
-#else
- public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter)
-#endif
- {
- double value = (double) milligramspermilliliter;
- return new Density(value, DensityUnit.MilligramPerMilliliter);
- }
-
- ///
- /// Get Density from NanogramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromNanogramsPerDeciLiter(double nanogramsperdeciliter)
-#else
- public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdeciliter)
-#endif
- {
- double value = (double) nanogramsperdeciliter;
- return new Density(value, DensityUnit.NanogramPerDeciliter);
- }
-
- ///
- /// Get Density from NanogramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromNanogramsPerLiter(double nanogramsperliter)
-#else
- public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter)
-#endif
- {
- double value = (double) nanogramsperliter;
- return new Density(value, DensityUnit.NanogramPerLiter);
- }
-
- ///
- /// Get Density from NanogramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromNanogramsPerMilliliter(double nanogramspermilliliter)
-#else
- public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter)
-#endif
- {
- double value = (double) nanogramspermilliliter;
- return new Density(value, DensityUnit.NanogramPerMilliliter);
- }
-
- ///
- /// Get Density from PicogramsPerDeciLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPicogramsPerDeciLiter(double picogramsperdeciliter)
-#else
- public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdeciliter)
-#endif
- {
- double value = (double) picogramsperdeciliter;
- return new Density(value, DensityUnit.PicogramPerDeciliter);
- }
-
- ///
- /// Get Density from PicogramsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPicogramsPerLiter(double picogramsperliter)
-#else
- public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter)
-#endif
- {
- double value = (double) picogramsperliter;
- return new Density(value, DensityUnit.PicogramPerLiter);
- }
-
- ///
- /// Get Density from PicogramsPerMilliliter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPicogramsPerMilliliter(double picogramspermilliliter)
-#else
- public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter)
-#endif
- {
- double value = (double) picogramspermilliliter;
- return new Density(value, DensityUnit.PicogramPerMilliliter);
- }
-
- ///
- /// Get Density from PoundsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPoundsPerCubicFoot(double poundspercubicfoot)
-#else
- public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot)
-#endif
- {
- double value = (double) poundspercubicfoot;
- return new Density(value, DensityUnit.PoundPerCubicFoot);
- }
-
- ///
- /// Get Density from PoundsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPoundsPerCubicInch(double poundspercubicinch)
-#else
- public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch)
-#endif
- {
- double value = (double) poundspercubicinch;
- return new Density(value, DensityUnit.PoundPerCubicInch);
- }
-
- ///
- /// Get Density from PoundsPerImperialGallon.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPoundsPerImperialGallon(double poundsperimperialgallon)
-#else
- public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon)
-#endif
- {
- double value = (double) poundsperimperialgallon;
- return new Density(value, DensityUnit.PoundPerImperialGallon);
- }
-
- ///
- /// Get Density from PoundsPerUSGallon.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromPoundsPerUSGallon(double poundsperusgallon)
-#else
- public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon)
-#endif
- {
- double value = (double) poundsperusgallon;
- return new Density(value, DensityUnit.PoundPerUSGallon);
- }
-
- ///
- /// Get Density from SlugsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromSlugsPerCubicFoot(double slugspercubicfoot)
-#else
- public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot)
-#endif
- {
- double value = (double) slugspercubicfoot;
- return new Density(value, DensityUnit.SlugPerCubicFoot);
- }
-
- ///
- /// Get Density from TonnesPerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromTonnesPerCubicCentimeter(double tonnespercubiccentimeter)
-#else
- public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter)
-#endif
- {
- double value = (double) tonnespercubiccentimeter;
- return new Density(value, DensityUnit.TonnePerCubicCentimeter);
- }
-
- ///
- /// Get Density from TonnesPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromTonnesPerCubicMeter(double tonnespercubicmeter)
-#else
- public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter)
-#endif
- {
- double value = (double) tonnespercubicmeter;
- return new Density(value, DensityUnit.TonnePerCubicMeter);
- }
-
- ///
- /// Get Density from TonnesPerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Density FromTonnesPerCubicMillimeter(double tonnespercubicmillimeter)
-#else
- public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter)
-#endif
- {
- double value = (double) tonnespercubicmillimeter;
- return new Density(value, DensityUnit.TonnePerCubicMillimeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Density unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Density From(double value, DensityUnit fromUnit)
-#else
- public static Density From(QuantityValue value, DensityUnit fromUnit)
-#endif
- {
- return new Density((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(DensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Density)) throw new ArgumentException("Expected type Density.", nameof(obj));
-
- return CompareTo((Density)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(Density other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Density, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Density))
- return false;
-
- var objQuantity = (Density)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Density within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Density other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Density 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.
- [Obsolete("Please use the Equals(Density, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Density other, Density maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Density.
- public override int GetHashCode()
- {
- return new { type = typeof(Density), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(DensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Density to another Density with the unit representation .
- ///
- /// A Density with the specified unit.
- public Density ToUnit(DensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Density(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case DensityUnit.CentigramPerDeciliter: return (_value/1e-1) * 1e-2d;
- case DensityUnit.CentigramPerLiter: return (_value/1) * 1e-2d;
- case DensityUnit.CentigramPerMilliliter: return (_value/1e-3) * 1e-2d;
- case DensityUnit.DecigramPerDeciliter: return (_value/1e-1) * 1e-1d;
- case DensityUnit.DecigramPerLiter: return (_value/1) * 1e-1d;
- case DensityUnit.DecigramPerMilliliter: return (_value/1e-3) * 1e-1d;
- case DensityUnit.GramPerCubicCentimeter: return _value/1e-3;
- case DensityUnit.GramPerCubicMeter: return _value/1e3;
- case DensityUnit.GramPerCubicMillimeter: return _value/1e-6;
- case DensityUnit.GramPerDeciliter: return _value/1e-1;
- case DensityUnit.GramPerLiter: return _value/1;
- case DensityUnit.GramPerMilliliter: return _value/1e-3;
- case DensityUnit.KilogramPerCubicCentimeter: return (_value/1e-3) * 1e3d;
- case DensityUnit.KilogramPerCubicMeter: return (_value/1e3) * 1e3d;
- case DensityUnit.KilogramPerCubicMillimeter: return (_value/1e-6) * 1e3d;
- case DensityUnit.KilopoundPerCubicFoot: return (_value/0.062427961) * 1e3d;
- case DensityUnit.KilopoundPerCubicInch: return (_value/3.6127298147753e-5) * 1e3d;
- case DensityUnit.MicrogramPerDeciliter: return (_value/1e-1) * 1e-6d;
- case DensityUnit.MicrogramPerLiter: return (_value/1) * 1e-6d;
- case DensityUnit.MicrogramPerMilliliter: return (_value/1e-3) * 1e-6d;
- case DensityUnit.MilligramPerCubicMeter: return (_value/1e3) * 1e-3d;
- case DensityUnit.MilligramPerDeciliter: return (_value/1e-1) * 1e-3d;
- case DensityUnit.MilligramPerLiter: return (_value/1) * 1e-3d;
- case DensityUnit.MilligramPerMilliliter: return (_value/1e-3) * 1e-3d;
- case DensityUnit.NanogramPerDeciliter: return (_value/1e-1) * 1e-9d;
- case DensityUnit.NanogramPerLiter: return (_value/1) * 1e-9d;
- case DensityUnit.NanogramPerMilliliter: return (_value/1e-3) * 1e-9d;
- case DensityUnit.PicogramPerDeciliter: return (_value/1e-1) * 1e-12d;
- case DensityUnit.PicogramPerLiter: return (_value/1) * 1e-12d;
- case DensityUnit.PicogramPerMilliliter: return (_value/1e-3) * 1e-12d;
- case DensityUnit.PoundPerCubicFoot: return _value/0.062427961;
- case DensityUnit.PoundPerCubicInch: return _value/3.6127298147753e-5;
- case DensityUnit.PoundPerImperialGallon: return _value*9.9776398e1;
- case DensityUnit.PoundPerUSGallon: return _value*1.19826427e2;
- case DensityUnit.SlugPerCubicFoot: return _value*515.378818;
- case DensityUnit.TonnePerCubicCentimeter: return _value/1e-9;
- case DensityUnit.TonnePerCubicMeter: return _value/0.001;
- case DensityUnit.TonnePerCubicMillimeter: return _value/1e-12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(DensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case DensityUnit.CentigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-2d;
- case DensityUnit.CentigramPerLiter: return (baseUnitValue*1) / 1e-2d;
- case DensityUnit.CentigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-2d;
- case DensityUnit.DecigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-1d;
- case DensityUnit.DecigramPerLiter: return (baseUnitValue*1) / 1e-1d;
- case DensityUnit.DecigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-1d;
- case DensityUnit.GramPerCubicCentimeter: return baseUnitValue*1e-3;
- case DensityUnit.GramPerCubicMeter: return baseUnitValue*1e3;
- case DensityUnit.GramPerCubicMillimeter: return baseUnitValue*1e-6;
- case DensityUnit.GramPerDeciliter: return baseUnitValue*1e-1;
- case DensityUnit.GramPerLiter: return baseUnitValue*1;
- case DensityUnit.GramPerMilliliter: return baseUnitValue*1e-3;
- case DensityUnit.KilogramPerCubicCentimeter: return (baseUnitValue*1e-3) / 1e3d;
- case DensityUnit.KilogramPerCubicMeter: return (baseUnitValue*1e3) / 1e3d;
- case DensityUnit.KilogramPerCubicMillimeter: return (baseUnitValue*1e-6) / 1e3d;
- case DensityUnit.KilopoundPerCubicFoot: return (baseUnitValue*0.062427961) / 1e3d;
- case DensityUnit.KilopoundPerCubicInch: return (baseUnitValue*3.6127298147753e-5) / 1e3d;
- case DensityUnit.MicrogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-6d;
- case DensityUnit.MicrogramPerLiter: return (baseUnitValue*1) / 1e-6d;
- case DensityUnit.MicrogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-6d;
- case DensityUnit.MilligramPerCubicMeter: return (baseUnitValue*1e3) / 1e-3d;
- case DensityUnit.MilligramPerDeciliter: return (baseUnitValue*1e-1) / 1e-3d;
- case DensityUnit.MilligramPerLiter: return (baseUnitValue*1) / 1e-3d;
- case DensityUnit.MilligramPerMilliliter: return (baseUnitValue*1e-3) / 1e-3d;
- case DensityUnit.NanogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-9d;
- case DensityUnit.NanogramPerLiter: return (baseUnitValue*1) / 1e-9d;
- case DensityUnit.NanogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-9d;
- case DensityUnit.PicogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-12d;
- case DensityUnit.PicogramPerLiter: return (baseUnitValue*1) / 1e-12d;
- case DensityUnit.PicogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-12d;
- case DensityUnit.PoundPerCubicFoot: return baseUnitValue*0.062427961;
- case DensityUnit.PoundPerCubicInch: return baseUnitValue*3.6127298147753e-5;
- case DensityUnit.PoundPerImperialGallon: return baseUnitValue/9.9776398e1;
- case DensityUnit.PoundPerUSGallon: return baseUnitValue/1.19826427e2;
- case DensityUnit.SlugPerCubicFoot: return baseUnitValue*0.00194032033;
- case DensityUnit.TonnePerCubicCentimeter: return baseUnitValue*1e-9;
- case DensityUnit.TonnePerCubicMeter: return baseUnitValue*0.001;
- case DensityUnit.TonnePerCubicMillimeter: return baseUnitValue*1e-12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Density Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Density result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static DensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerCubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static DensityUnit ToStringDefaultUnit { get; set; } = DensityUnit.KilogramPerCubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(DensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Density
- ///
- public static Density MaxValue => new Density(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Density
- ///
- public static Density MinValue => new Density(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Density.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Density.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Duration.Common.g.cs b/Common/GeneratedCode/Quantities/Duration.Common.g.cs
deleted file mode 100644
index dba1146018..0000000000
--- a/Common/GeneratedCode/Quantities/Duration.Common.g.cs
+++ /dev/null
@@ -1,725 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Duration : IQuantity
-#else
- public partial struct Duration : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly DurationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public DurationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Duration()
- {
- BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Second.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Duration(double seconds)
- {
- _value = Convert.ToDouble(seconds);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Duration(double numericValue, DurationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Second.
- ///
- /// Value assuming base unit Second.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Duration(long seconds) : this(Convert.ToDouble(seconds), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Second.
- ///
- /// Value assuming base unit Second.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Duration(decimal seconds) : this(Convert.ToDouble(seconds), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Duration;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static DurationUnit BaseUnit => DurationUnit.Second;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Duration quantity.
- ///
- public static DurationUnit[] Units { get; } = Enum.GetValues(typeof(DurationUnit)).Cast().Except(new DurationUnit[]{ DurationUnit.Undefined }).ToArray();
-
- ///
- /// Get Duration in Days.
- ///
- public double Days => As(DurationUnit.Day);
-
- ///
- /// Get Duration in Hours.
- ///
- public double Hours => As(DurationUnit.Hour);
-
- ///
- /// Get Duration in Microseconds.
- ///
- public double Microseconds => As(DurationUnit.Microsecond);
-
- ///
- /// Get Duration in Milliseconds.
- ///
- public double Milliseconds => As(DurationUnit.Millisecond);
-
- ///
- /// Get Duration in Minutes.
- ///
- public double Minutes => As(DurationUnit.Minute);
-
- ///
- /// Get Duration in Months.
- ///
- [System.Obsolete("Use Month30 instead, which makes it clear that this is an approximate unit based on 30 days per month. The duration of a month varies, but the Gregorian solar calendar has 365.2425/12 = 30.44 days on average.")]
- public double Months => As(DurationUnit.Month);
-
- ///
- /// Get Duration in Months30.
- ///
- public double Months30 => As(DurationUnit.Month30);
-
- ///
- /// Get Duration in Nanoseconds.
- ///
- public double Nanoseconds => As(DurationUnit.Nanosecond);
-
- ///
- /// Get Duration in Seconds.
- ///
- public double Seconds => As(DurationUnit.Second);
-
- ///
- /// Get Duration in Weeks.
- ///
- public double Weeks => As(DurationUnit.Week);
-
- ///
- /// Get Duration in Years.
- ///
- [System.Obsolete("Use Year365 instead, which makes it clear that this is an approximate unit based on 365 days per year. The duration of a year varies due to corrections such as leap years, since a Gregorian solar calendar has 365.2425 days.")]
- public double Years => As(DurationUnit.Year);
-
- ///
- /// Get Duration in Years365.
- ///
- public double Years365 => As(DurationUnit.Year365);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Second.
- ///
- public static Duration Zero => new Duration(0, BaseUnit);
-
- ///
- /// Get Duration from Days.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromDays(double days)
-#else
- public static Duration FromDays(QuantityValue days)
-#endif
- {
- double value = (double) days;
- return new Duration(value, DurationUnit.Day);
- }
-
- ///
- /// Get Duration from Hours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromHours(double hours)
-#else
- public static Duration FromHours(QuantityValue hours)
-#endif
- {
- double value = (double) hours;
- return new Duration(value, DurationUnit.Hour);
- }
-
- ///
- /// Get Duration from Microseconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromMicroseconds(double microseconds)
-#else
- public static Duration FromMicroseconds(QuantityValue microseconds)
-#endif
- {
- double value = (double) microseconds;
- return new Duration(value, DurationUnit.Microsecond);
- }
-
- ///
- /// Get Duration from Milliseconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromMilliseconds(double milliseconds)
-#else
- public static Duration FromMilliseconds(QuantityValue milliseconds)
-#endif
- {
- double value = (double) milliseconds;
- return new Duration(value, DurationUnit.Millisecond);
- }
-
- ///
- /// Get Duration from Minutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromMinutes(double minutes)
-#else
- public static Duration FromMinutes(QuantityValue minutes)
-#endif
- {
- double value = (double) minutes;
- return new Duration(value, DurationUnit.Minute);
- }
-
- ///
- /// Get Duration from Months.
- ///
- [System.Obsolete("Use Month30 instead, which makes it clear that this is an approximate unit based on 30 days per month. The duration of a month varies, but the Gregorian solar calendar has 365.2425/12 = 30.44 days on average.")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromMonths(double months)
-#else
- public static Duration FromMonths(QuantityValue months)
-#endif
- {
- double value = (double) months;
- return new Duration(value, DurationUnit.Month);
- }
-
- ///
- /// Get Duration from Months30.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromMonths30(double months30)
-#else
- public static Duration FromMonths30(QuantityValue months30)
-#endif
- {
- double value = (double) months30;
- return new Duration(value, DurationUnit.Month30);
- }
-
- ///
- /// Get Duration from Nanoseconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromNanoseconds(double nanoseconds)
-#else
- public static Duration FromNanoseconds(QuantityValue nanoseconds)
-#endif
- {
- double value = (double) nanoseconds;
- return new Duration(value, DurationUnit.Nanosecond);
- }
-
- ///
- /// Get Duration from Seconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromSeconds(double seconds)
-#else
- public static Duration FromSeconds(QuantityValue seconds)
-#endif
- {
- double value = (double) seconds;
- return new Duration(value, DurationUnit.Second);
- }
-
- ///
- /// Get Duration from Weeks.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromWeeks(double weeks)
-#else
- public static Duration FromWeeks(QuantityValue weeks)
-#endif
- {
- double value = (double) weeks;
- return new Duration(value, DurationUnit.Week);
- }
-
- ///
- /// Get Duration from Years.
- ///
- [System.Obsolete("Use Year365 instead, which makes it clear that this is an approximate unit based on 365 days per year. The duration of a year varies due to corrections such as leap years, since a Gregorian solar calendar has 365.2425 days.")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromYears(double years)
-#else
- public static Duration FromYears(QuantityValue years)
-#endif
- {
- double value = (double) years;
- return new Duration(value, DurationUnit.Year);
- }
-
- ///
- /// Get Duration from Years365.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Duration FromYears365(double years365)
-#else
- public static Duration FromYears365(QuantityValue years365)
-#endif
- {
- double value = (double) years365;
- return new Duration(value, DurationUnit.Year365);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Duration unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Duration From(double value, DurationUnit fromUnit)
-#else
- public static Duration From(QuantityValue value, DurationUnit fromUnit)
-#endif
- {
- return new Duration((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(DurationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Duration)) throw new ArgumentException("Expected type Duration.", nameof(obj));
-
- return CompareTo((Duration)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(Duration other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Duration, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Duration))
- return false;
-
- var objQuantity = (Duration)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Duration within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Duration other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Duration 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.
- [Obsolete("Please use the Equals(Duration, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Duration other, Duration maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Duration.
- public override int GetHashCode()
- {
- return new { type = typeof(Duration), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(DurationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Duration to another Duration with the unit representation .
- ///
- /// A Duration with the specified unit.
- public Duration ToUnit(DurationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Duration(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case DurationUnit.Day: return _value*24*3600;
- case DurationUnit.Hour: return _value*3600;
- case DurationUnit.Microsecond: return (_value) * 1e-6d;
- case DurationUnit.Millisecond: return (_value) * 1e-3d;
- case DurationUnit.Minute: return _value*60;
- case DurationUnit.Month: return _value*30*24*3600;
- case DurationUnit.Month30: return _value*30*24*3600;
- case DurationUnit.Nanosecond: return (_value) * 1e-9d;
- case DurationUnit.Second: return _value;
- case DurationUnit.Week: return _value*7*24*3600;
- case DurationUnit.Year: return _value*365*24*3600;
- case DurationUnit.Year365: return _value*365*24*3600;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(DurationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case DurationUnit.Day: return baseUnitValue/(24*3600);
- case DurationUnit.Hour: return baseUnitValue/3600;
- case DurationUnit.Microsecond: return (baseUnitValue) / 1e-6d;
- case DurationUnit.Millisecond: return (baseUnitValue) / 1e-3d;
- case DurationUnit.Minute: return baseUnitValue/60;
- case DurationUnit.Month: return baseUnitValue/(30*24*3600);
- case DurationUnit.Month30: return baseUnitValue/(30*24*3600);
- case DurationUnit.Nanosecond: return (baseUnitValue) / 1e-9d;
- case DurationUnit.Second: return baseUnitValue;
- case DurationUnit.Week: return baseUnitValue/(7*24*3600);
- case DurationUnit.Year: return baseUnitValue/(365*24*3600);
- case DurationUnit.Year365: return baseUnitValue/(365*24*3600);
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Duration Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Duration result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static DurationUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Second
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static DurationUnit ToStringDefaultUnit { get; set; } = DurationUnit.Second;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(DurationUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Duration
- ///
- public static Duration MaxValue => new Duration(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Duration
- ///
- public static Duration MinValue => new Duration(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Duration.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Duration.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/DynamicViscosity.Common.g.cs b/Common/GeneratedCode/Quantities/DynamicViscosity.Common.g.cs
deleted file mode 100644
index 778279d582..0000000000
--- a/Common/GeneratedCode/Quantities/DynamicViscosity.Common.g.cs
+++ /dev/null
@@ -1,595 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds
- ///
- // 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 DynamicViscosity : IQuantity
-#else
- public partial struct DynamicViscosity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly DynamicViscosityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static DynamicViscosity()
- {
- BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonSecondPerMeterSquared.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public DynamicViscosity(double newtonsecondspermetersquared)
- {
- _value = Convert.ToDouble(newtonsecondspermetersquared);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- DynamicViscosity(double numericValue, DynamicViscosityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonSecondPerMeterSquared.
- ///
- /// Value assuming base unit NewtonSecondPerMeterSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- DynamicViscosity(long newtonsecondspermetersquared) : this(Convert.ToDouble(newtonsecondspermetersquared), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonSecondPerMeterSquared.
- ///
- /// Value assuming base unit NewtonSecondPerMeterSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- DynamicViscosity(decimal newtonsecondspermetersquared) : this(Convert.ToDouble(newtonsecondspermetersquared), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.DynamicViscosity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static DynamicViscosityUnit BaseUnit => DynamicViscosityUnit.NewtonSecondPerMeterSquared;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the DynamicViscosity quantity.
- ///
- public static DynamicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().Except(new DynamicViscosityUnit[]{ DynamicViscosityUnit.Undefined }).ToArray();
-
- ///
- /// Get DynamicViscosity in Centipoise.
- ///
- public double Centipoise => As(DynamicViscosityUnit.Centipoise);
-
- ///
- /// Get DynamicViscosity in MicropascalSeconds.
- ///
- public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond);
-
- ///
- /// Get DynamicViscosity in MillipascalSeconds.
- ///
- public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond);
-
- ///
- /// Get DynamicViscosity in NewtonSecondsPerMeterSquared.
- ///
- public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared);
-
- ///
- /// Get DynamicViscosity in PascalSeconds.
- ///
- public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond);
-
- ///
- /// Get DynamicViscosity in Poise.
- ///
- public double Poise => As(DynamicViscosityUnit.Poise);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared.
- ///
- public static DynamicViscosity Zero => new DynamicViscosity(0, BaseUnit);
-
- ///
- /// Get DynamicViscosity from Centipoise.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromCentipoise(double centipoise)
-#else
- public static DynamicViscosity FromCentipoise(QuantityValue centipoise)
-#endif
- {
- double value = (double) centipoise;
- return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise);
- }
-
- ///
- /// Get DynamicViscosity from MicropascalSeconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromMicropascalSeconds(double micropascalseconds)
-#else
- public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascalseconds)
-#endif
- {
- double value = (double) micropascalseconds;
- return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond);
- }
-
- ///
- /// Get DynamicViscosity from MillipascalSeconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromMillipascalSeconds(double millipascalseconds)
-#else
- public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascalseconds)
-#endif
- {
- double value = (double) millipascalseconds;
- return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond);
- }
-
- ///
- /// Get DynamicViscosity from NewtonSecondsPerMeterSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromNewtonSecondsPerMeterSquared(double newtonsecondspermetersquared)
-#else
- public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue newtonsecondspermetersquared)
-#endif
- {
- double value = (double) newtonsecondspermetersquared;
- return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared);
- }
-
- ///
- /// Get DynamicViscosity from PascalSeconds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromPascalSeconds(double pascalseconds)
-#else
- public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds)
-#endif
- {
- double value = (double) pascalseconds;
- return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond);
- }
-
- ///
- /// Get DynamicViscosity from Poise.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static DynamicViscosity FromPoise(double poise)
-#else
- public static DynamicViscosity FromPoise(QuantityValue poise)
-#endif
- {
- double value = (double) poise;
- return new DynamicViscosity(value, DynamicViscosityUnit.Poise);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// DynamicViscosity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static DynamicViscosity From(double value, DynamicViscosityUnit fromUnit)
-#else
- public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fromUnit)
-#endif
- {
- return new DynamicViscosity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(DynamicViscosityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is DynamicViscosity)) throw new ArgumentException("Expected type DynamicViscosity.", nameof(obj));
-
- return CompareTo((DynamicViscosity)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(DynamicViscosity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(DynamicViscosity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is DynamicViscosity))
- return false;
-
- var objQuantity = (DynamicViscosity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another DynamicViscosity 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.
- [Obsolete("Please use the Equals(DynamicViscosity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(DynamicViscosity other, DynamicViscosity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current DynamicViscosity.
- public override int GetHashCode()
- {
- return new { type = typeof(DynamicViscosity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(DynamicViscosityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation .
- ///
- /// A DynamicViscosity with the specified unit.
- public DynamicViscosity ToUnit(DynamicViscosityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new DynamicViscosity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case DynamicViscosityUnit.Centipoise: return (_value/10) * 1e-2d;
- case DynamicViscosityUnit.MicropascalSecond: return (_value) * 1e-6d;
- case DynamicViscosityUnit.MillipascalSecond: return (_value) * 1e-3d;
- case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return _value;
- case DynamicViscosityUnit.PascalSecond: return _value;
- case DynamicViscosityUnit.Poise: return _value/10;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(DynamicViscosityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case DynamicViscosityUnit.Centipoise: return (baseUnitValue*10) / 1e-2d;
- case DynamicViscosityUnit.MicropascalSecond: return (baseUnitValue) / 1e-6d;
- case DynamicViscosityUnit.MillipascalSecond: return (baseUnitValue) / 1e-3d;
- case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return baseUnitValue;
- case DynamicViscosityUnit.PascalSecond: return baseUnitValue;
- case DynamicViscosityUnit.Poise: return baseUnitValue*10;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 DynamicViscosity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 DynamicViscosity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static DynamicViscosityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonSecondPerMeterSquared
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static DynamicViscosityUnit ToStringDefaultUnit { get; set; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(DynamicViscosityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of DynamicViscosity
- ///
- public static DynamicViscosity MaxValue => new DynamicViscosity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of DynamicViscosity
- ///
- public static DynamicViscosity MinValue => new DynamicViscosity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => DynamicViscosity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => DynamicViscosity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricAdmittance.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricAdmittance.Common.g.cs
deleted file mode 100644
index 5f7caa94c2..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricAdmittance.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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).
- ///
- // 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 ElectricAdmittance : IQuantity
-#else
- public partial struct ElectricAdmittance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricAdmittanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricAdmittance()
- {
- BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Siemens.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricAdmittance(double siemens)
- {
- _value = Convert.ToDouble(siemens);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricAdmittance(double numericValue, ElectricAdmittanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Siemens.
- ///
- /// Value assuming base unit Siemens.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricAdmittance(long siemens) : this(Convert.ToDouble(siemens), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Siemens.
- ///
- /// Value assuming base unit Siemens.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricAdmittance(decimal siemens) : this(Convert.ToDouble(siemens), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricAdmittance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricAdmittanceUnit BaseUnit => ElectricAdmittanceUnit.Siemens;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricAdmittance quantity.
- ///
- public static ElectricAdmittanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().Except(new ElectricAdmittanceUnit[]{ ElectricAdmittanceUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricAdmittance in Microsiemens.
- ///
- public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens);
-
- ///
- /// Get ElectricAdmittance in Millisiemens.
- ///
- public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens);
-
- ///
- /// Get ElectricAdmittance in Nanosiemens.
- ///
- public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens);
-
- ///
- /// Get ElectricAdmittance in Siemens.
- ///
- public double Siemens => As(ElectricAdmittanceUnit.Siemens);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Siemens.
- ///
- public static ElectricAdmittance Zero => new ElectricAdmittance(0, BaseUnit);
-
- ///
- /// Get ElectricAdmittance from Microsiemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricAdmittance FromMicrosiemens(double microsiemens)
-#else
- public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens)
-#endif
- {
- double value = (double) microsiemens;
- return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens);
- }
-
- ///
- /// Get ElectricAdmittance from Millisiemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricAdmittance FromMillisiemens(double millisiemens)
-#else
- public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens)
-#endif
- {
- double value = (double) millisiemens;
- return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens);
- }
-
- ///
- /// Get ElectricAdmittance from Nanosiemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricAdmittance FromNanosiemens(double nanosiemens)
-#else
- public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens)
-#endif
- {
- double value = (double) nanosiemens;
- return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens);
- }
-
- ///
- /// Get ElectricAdmittance from Siemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricAdmittance FromSiemens(double siemens)
-#else
- public static ElectricAdmittance FromSiemens(QuantityValue siemens)
-#endif
- {
- double value = (double) siemens;
- return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricAdmittance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricAdmittance From(double value, ElectricAdmittanceUnit fromUnit)
-#else
- public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUnit fromUnit)
-#endif
- {
- return new ElectricAdmittance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricAdmittanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricAdmittance)) throw new ArgumentException("Expected type ElectricAdmittance.", nameof(obj));
-
- return CompareTo((ElectricAdmittance)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(ElectricAdmittance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricAdmittance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricAdmittance))
- return false;
-
- var objQuantity = (ElectricAdmittance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricAdmittance 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.
- [Obsolete("Please use the Equals(ElectricAdmittance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricAdmittance other, ElectricAdmittance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricAdmittance.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricAdmittance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricAdmittanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation .
- ///
- /// A ElectricAdmittance with the specified unit.
- public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricAdmittance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricAdmittanceUnit.Microsiemens: return (_value) * 1e-6d;
- case ElectricAdmittanceUnit.Millisiemens: return (_value) * 1e-3d;
- case ElectricAdmittanceUnit.Nanosiemens: return (_value) * 1e-9d;
- case ElectricAdmittanceUnit.Siemens: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricAdmittanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricAdmittanceUnit.Microsiemens: return (baseUnitValue) / 1e-6d;
- case ElectricAdmittanceUnit.Millisiemens: return (baseUnitValue) / 1e-3d;
- case ElectricAdmittanceUnit.Nanosiemens: return (baseUnitValue) / 1e-9d;
- case ElectricAdmittanceUnit.Siemens: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricAdmittance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricAdmittance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricAdmittanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Siemens
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricAdmittanceUnit ToStringDefaultUnit { get; set; } = ElectricAdmittanceUnit.Siemens;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricAdmittanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricAdmittance
- ///
- public static ElectricAdmittance MaxValue => new ElectricAdmittance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricAdmittance
- ///
- public static ElectricAdmittance MinValue => new ElectricAdmittance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricAdmittance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricAdmittance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricCharge.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricCharge.Common.g.cs
deleted file mode 100644
index f354e89637..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricCharge.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field.
- ///
- // 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 ElectricCharge : IQuantity
-#else
- public partial struct ElectricCharge : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricChargeUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricChargeUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricCharge()
- {
- BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Coulomb.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricCharge(double coulombs)
- {
- _value = Convert.ToDouble(coulombs);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricCharge(double numericValue, ElectricChargeUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Coulomb.
- ///
- /// Value assuming base unit Coulomb.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCharge(long coulombs) : this(Convert.ToDouble(coulombs), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Coulomb.
- ///
- /// Value assuming base unit Coulomb.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCharge(decimal coulombs) : this(Convert.ToDouble(coulombs), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricCharge;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricChargeUnit BaseUnit => ElectricChargeUnit.Coulomb;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricCharge quantity.
- ///
- public static ElectricChargeUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().Except(new ElectricChargeUnit[]{ ElectricChargeUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricCharge in Coulombs.
- ///
- public double Coulombs => As(ElectricChargeUnit.Coulomb);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Coulomb.
- ///
- public static ElectricCharge Zero => new ElectricCharge(0, BaseUnit);
-
- ///
- /// Get ElectricCharge from Coulombs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCharge FromCoulombs(double coulombs)
-#else
- public static ElectricCharge FromCoulombs(QuantityValue coulombs)
-#endif
- {
- double value = (double) coulombs;
- return new ElectricCharge(value, ElectricChargeUnit.Coulomb);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricCharge unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricCharge From(double value, ElectricChargeUnit fromUnit)
-#else
- public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUnit)
-#endif
- {
- return new ElectricCharge((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricChargeUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricCharge)) throw new ArgumentException("Expected type ElectricCharge.", nameof(obj));
-
- return CompareTo((ElectricCharge)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(ElectricCharge other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricCharge, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricCharge))
- return false;
-
- var objQuantity = (ElectricCharge)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricCharge within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricCharge 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.
- [Obsolete("Please use the Equals(ElectricCharge, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricCharge other, ElectricCharge maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricCharge.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricCharge), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricChargeUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricCharge to another ElectricCharge with the unit representation .
- ///
- /// A ElectricCharge with the specified unit.
- public ElectricCharge ToUnit(ElectricChargeUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricCharge(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricChargeUnit.Coulomb: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricChargeUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricChargeUnit.Coulomb: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricCharge Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricCharge result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricChargeUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Coulomb
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricChargeUnit ToStringDefaultUnit { get; set; } = ElectricChargeUnit.Coulomb;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricChargeUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricCharge
- ///
- public static ElectricCharge MaxValue => new ElectricCharge(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricCharge
- ///
- public static ElectricCharge MinValue => new ElectricCharge(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricCharge.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricCharge.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricChargeDensity.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricChargeDensity.Common.g.cs
deleted file mode 100644
index 48c8f01208..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricChargeDensity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In electromagnetism, charge density is a measure of the amount of electric charge per unit length, surface area, or volume.
- ///
- // 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 ElectricChargeDensity : IQuantity
-#else
- public partial struct ElectricChargeDensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricChargeDensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricChargeDensity()
- {
- BaseDimensions = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit CoulombPerCubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricChargeDensity(double coulombspercubicmeter)
- {
- _value = Convert.ToDouble(coulombspercubicmeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricChargeDensity(double numericValue, ElectricChargeDensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CoulombPerCubicMeter.
- ///
- /// Value assuming base unit CoulombPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricChargeDensity(long coulombspercubicmeter) : this(Convert.ToDouble(coulombspercubicmeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CoulombPerCubicMeter.
- ///
- /// Value assuming base unit CoulombPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricChargeDensity(decimal coulombspercubicmeter) : this(Convert.ToDouble(coulombspercubicmeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricChargeDensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricChargeDensityUnit BaseUnit => ElectricChargeDensityUnit.CoulombPerCubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricChargeDensity quantity.
- ///
- public static ElectricChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().Except(new ElectricChargeDensityUnit[]{ ElectricChargeDensityUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricChargeDensity in CoulombsPerCubicMeter.
- ///
- public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerCubicMeter.
- ///
- public static ElectricChargeDensity Zero => new ElectricChargeDensity(0, BaseUnit);
-
- ///
- /// Get ElectricChargeDensity from CoulombsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricChargeDensity FromCoulombsPerCubicMeter(double coulombspercubicmeter)
-#else
- public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coulombspercubicmeter)
-#endif
- {
- double value = (double) coulombspercubicmeter;
- return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricChargeDensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricChargeDensity From(double value, ElectricChargeDensityUnit fromUnit)
-#else
- public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDensityUnit fromUnit)
-#endif
- {
- return new ElectricChargeDensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricChargeDensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricChargeDensity)) throw new ArgumentException("Expected type ElectricChargeDensity.", nameof(obj));
-
- return CompareTo((ElectricChargeDensity)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(ElectricChargeDensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricChargeDensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricChargeDensity))
- return false;
-
- var objQuantity = (ElectricChargeDensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricChargeDensity 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.
- [Obsolete("Please use the Equals(ElectricChargeDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricChargeDensity other, ElectricChargeDensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricChargeDensity.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricChargeDensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricChargeDensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation .
- ///
- /// A ElectricChargeDensity with the specified unit.
- public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricChargeDensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricChargeDensityUnit.CoulombPerCubicMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricChargeDensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricChargeDensityUnit.CoulombPerCubicMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricChargeDensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricChargeDensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricChargeDensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is CoulombPerCubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricChargeDensityUnit ToStringDefaultUnit { get; set; } = ElectricChargeDensityUnit.CoulombPerCubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricChargeDensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricChargeDensity
- ///
- public static ElectricChargeDensity MaxValue => new ElectricChargeDensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricChargeDensity
- ///
- public static ElectricChargeDensity MinValue => new ElectricChargeDensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricChargeDensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricChargeDensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricConductance.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricConductance.Common.g.cs
deleted file mode 100644
index c752bc7ba2..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricConductance.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.
- ///
- // 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 ElectricConductance : IQuantity
-#else
- public partial struct ElectricConductance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricConductanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricConductance()
- {
- BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Siemens.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricConductance(double siemens)
- {
- _value = Convert.ToDouble(siemens);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricConductance(double numericValue, ElectricConductanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Siemens.
- ///
- /// Value assuming base unit Siemens.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricConductance(long siemens) : this(Convert.ToDouble(siemens), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Siemens.
- ///
- /// Value assuming base unit Siemens.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricConductance(decimal siemens) : this(Convert.ToDouble(siemens), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricConductance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricConductanceUnit BaseUnit => ElectricConductanceUnit.Siemens;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricConductance quantity.
- ///
- public static ElectricConductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().Except(new ElectricConductanceUnit[]{ ElectricConductanceUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricConductance in Microsiemens.
- ///
- public double Microsiemens => As(ElectricConductanceUnit.Microsiemens);
-
- ///
- /// Get ElectricConductance in Millisiemens.
- ///
- public double Millisiemens => As(ElectricConductanceUnit.Millisiemens);
-
- ///
- /// Get ElectricConductance in Siemens.
- ///
- public double Siemens => As(ElectricConductanceUnit.Siemens);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Siemens.
- ///
- public static ElectricConductance Zero => new ElectricConductance(0, BaseUnit);
-
- ///
- /// Get ElectricConductance from Microsiemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricConductance FromMicrosiemens(double microsiemens)
-#else
- public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens)
-#endif
- {
- double value = (double) microsiemens;
- return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens);
- }
-
- ///
- /// Get ElectricConductance from Millisiemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricConductance FromMillisiemens(double millisiemens)
-#else
- public static ElectricConductance FromMillisiemens(QuantityValue millisiemens)
-#endif
- {
- double value = (double) millisiemens;
- return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens);
- }
-
- ///
- /// Get ElectricConductance from Siemens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricConductance FromSiemens(double siemens)
-#else
- public static ElectricConductance FromSiemens(QuantityValue siemens)
-#endif
- {
- double value = (double) siemens;
- return new ElectricConductance(value, ElectricConductanceUnit.Siemens);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricConductance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricConductance From(double value, ElectricConductanceUnit fromUnit)
-#else
- public static ElectricConductance From(QuantityValue value, ElectricConductanceUnit fromUnit)
-#endif
- {
- return new ElectricConductance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricConductanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricConductance)) throw new ArgumentException("Expected type ElectricConductance.", nameof(obj));
-
- return CompareTo((ElectricConductance)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(ElectricConductance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricConductance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricConductance))
- return false;
-
- var objQuantity = (ElectricConductance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricConductance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricConductance 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.
- [Obsolete("Please use the Equals(ElectricConductance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricConductance other, ElectricConductance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricConductance.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricConductance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricConductanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricConductance to another ElectricConductance with the unit representation .
- ///
- /// A ElectricConductance with the specified unit.
- public ElectricConductance ToUnit(ElectricConductanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricConductance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricConductanceUnit.Microsiemens: return (_value) * 1e-6d;
- case ElectricConductanceUnit.Millisiemens: return (_value) * 1e-3d;
- case ElectricConductanceUnit.Siemens: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricConductanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricConductanceUnit.Microsiemens: return (baseUnitValue) / 1e-6d;
- case ElectricConductanceUnit.Millisiemens: return (baseUnitValue) / 1e-3d;
- case ElectricConductanceUnit.Siemens: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricConductance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricConductance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricConductanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Siemens
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricConductanceUnit ToStringDefaultUnit { get; set; } = ElectricConductanceUnit.Siemens;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricConductanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricConductance
- ///
- public static ElectricConductance MaxValue => new ElectricConductance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricConductance
- ///
- public static ElectricConductance MinValue => new ElectricConductance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricConductance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricConductance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricConductivity.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricConductivity.Common.g.cs
deleted file mode 100644
index 68bcf5d0ab..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricConductivity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current.
- ///
- // 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 ElectricConductivity : IQuantity
-#else
- public partial struct ElectricConductivity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricConductivityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricConductivity()
- {
- BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit SiemensPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricConductivity(double siemenspermeter)
- {
- _value = Convert.ToDouble(siemenspermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricConductivity(double numericValue, ElectricConductivityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SiemensPerMeter.
- ///
- /// Value assuming base unit SiemensPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricConductivity(long siemenspermeter) : this(Convert.ToDouble(siemenspermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SiemensPerMeter.
- ///
- /// Value assuming base unit SiemensPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricConductivity(decimal siemenspermeter) : this(Convert.ToDouble(siemenspermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricConductivity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricConductivityUnit BaseUnit => ElectricConductivityUnit.SiemensPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricConductivity quantity.
- ///
- public static ElectricConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().Except(new ElectricConductivityUnit[]{ ElectricConductivityUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricConductivity in SiemensPerMeter.
- ///
- public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerMeter.
- ///
- public static ElectricConductivity Zero => new ElectricConductivity(0, BaseUnit);
-
- ///
- /// Get ElectricConductivity from SiemensPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricConductivity FromSiemensPerMeter(double siemenspermeter)
-#else
- public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemenspermeter)
-#endif
- {
- double value = (double) siemenspermeter;
- return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricConductivity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricConductivity From(double value, ElectricConductivityUnit fromUnit)
-#else
- public static ElectricConductivity From(QuantityValue value, ElectricConductivityUnit fromUnit)
-#endif
- {
- return new ElectricConductivity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricConductivityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricConductivity)) throw new ArgumentException("Expected type ElectricConductivity.", nameof(obj));
-
- return CompareTo((ElectricConductivity)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(ElectricConductivity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricConductivity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricConductivity))
- return false;
-
- var objQuantity = (ElectricConductivity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricConductivity 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.
- [Obsolete("Please use the Equals(ElectricConductivity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricConductivity other, ElectricConductivity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricConductivity.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricConductivity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricConductivityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation .
- ///
- /// A ElectricConductivity with the specified unit.
- public ElectricConductivity ToUnit(ElectricConductivityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricConductivity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricConductivityUnit.SiemensPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricConductivityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricConductivityUnit.SiemensPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricConductivity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricConductivity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricConductivityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is SiemensPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricConductivityUnit ToStringDefaultUnit { get; set; } = ElectricConductivityUnit.SiemensPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricConductivityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricConductivity
- ///
- public static ElectricConductivity MaxValue => new ElectricConductivity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricConductivity
- ///
- public static ElectricConductivity MinValue => new ElectricConductivity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricConductivity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricConductivity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricCurrent.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricCurrent.Common.g.cs
deleted file mode 100644
index 1313103839..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricCurrent.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 ElectricCurrent : IQuantity
-#else
- public partial struct ElectricCurrent : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricCurrentUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricCurrent()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Ampere.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricCurrent(double amperes)
- {
- _value = Convert.ToDouble(amperes);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricCurrent(double numericValue, ElectricCurrentUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Ampere.
- ///
- /// Value assuming base unit Ampere.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrent(long amperes) : this(Convert.ToDouble(amperes), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Ampere.
- ///
- /// Value assuming base unit Ampere.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrent(decimal amperes) : this(Convert.ToDouble(amperes), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricCurrent;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricCurrentUnit BaseUnit => ElectricCurrentUnit.Ampere;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricCurrent quantity.
- ///
- public static ElectricCurrentUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().Except(new ElectricCurrentUnit[]{ ElectricCurrentUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricCurrent in Amperes.
- ///
- public double Amperes => As(ElectricCurrentUnit.Ampere);
-
- ///
- /// Get ElectricCurrent in Centiamperes.
- ///
- public double Centiamperes => As(ElectricCurrentUnit.Centiampere);
-
- ///
- /// Get ElectricCurrent in Kiloamperes.
- ///
- public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere);
-
- ///
- /// Get ElectricCurrent in Megaamperes.
- ///
- public double Megaamperes => As(ElectricCurrentUnit.Megaampere);
-
- ///
- /// Get ElectricCurrent in Microamperes.
- ///
- public double Microamperes => As(ElectricCurrentUnit.Microampere);
-
- ///
- /// Get ElectricCurrent in Milliamperes.
- ///
- public double Milliamperes => As(ElectricCurrentUnit.Milliampere);
-
- ///
- /// Get ElectricCurrent in Nanoamperes.
- ///
- public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere);
-
- ///
- /// Get ElectricCurrent in Picoamperes.
- ///
- public double Picoamperes => As(ElectricCurrentUnit.Picoampere);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Ampere.
- ///
- public static ElectricCurrent Zero => new ElectricCurrent(0, BaseUnit);
-
- ///
- /// Get ElectricCurrent from Amperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromAmperes(double amperes)
-#else
- public static ElectricCurrent FromAmperes(QuantityValue amperes)
-#endif
- {
- double value = (double) amperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Ampere);
- }
-
- ///
- /// Get ElectricCurrent from Centiamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromCentiamperes(double centiamperes)
-#else
- public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes)
-#endif
- {
- double value = (double) centiamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere);
- }
-
- ///
- /// Get ElectricCurrent from Kiloamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromKiloamperes(double kiloamperes)
-#else
- public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes)
-#endif
- {
- double value = (double) kiloamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere);
- }
-
- ///
- /// Get ElectricCurrent from Megaamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromMegaamperes(double megaamperes)
-#else
- public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes)
-#endif
- {
- double value = (double) megaamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere);
- }
-
- ///
- /// Get ElectricCurrent from Microamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromMicroamperes(double microamperes)
-#else
- public static ElectricCurrent FromMicroamperes(QuantityValue microamperes)
-#endif
- {
- double value = (double) microamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Microampere);
- }
-
- ///
- /// Get ElectricCurrent from Milliamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromMilliamperes(double milliamperes)
-#else
- public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes)
-#endif
- {
- double value = (double) milliamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere);
- }
-
- ///
- /// Get ElectricCurrent from Nanoamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromNanoamperes(double nanoamperes)
-#else
- public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes)
-#endif
- {
- double value = (double) nanoamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere);
- }
-
- ///
- /// Get ElectricCurrent from Picoamperes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrent FromPicoamperes(double picoamperes)
-#else
- public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes)
-#endif
- {
- double value = (double) picoamperes;
- return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricCurrent unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricCurrent From(double value, ElectricCurrentUnit fromUnit)
-#else
- public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit fromUnit)
-#endif
- {
- return new ElectricCurrent((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricCurrentUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricCurrent)) throw new ArgumentException("Expected type ElectricCurrent.", nameof(obj));
-
- return CompareTo((ElectricCurrent)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(ElectricCurrent other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricCurrent, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricCurrent))
- return false;
-
- var objQuantity = (ElectricCurrent)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricCurrent 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.
- [Obsolete("Please use the Equals(ElectricCurrent, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricCurrent other, ElectricCurrent maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricCurrent.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricCurrent), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricCurrentUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation .
- ///
- /// A ElectricCurrent with the specified unit.
- public ElectricCurrent ToUnit(ElectricCurrentUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricCurrent(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricCurrentUnit.Ampere: return _value;
- case ElectricCurrentUnit.Centiampere: return (_value) * 1e-2d;
- case ElectricCurrentUnit.Kiloampere: return (_value) * 1e3d;
- case ElectricCurrentUnit.Megaampere: return (_value) * 1e6d;
- case ElectricCurrentUnit.Microampere: return (_value) * 1e-6d;
- case ElectricCurrentUnit.Milliampere: return (_value) * 1e-3d;
- case ElectricCurrentUnit.Nanoampere: return (_value) * 1e-9d;
- case ElectricCurrentUnit.Picoampere: return (_value) * 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricCurrentUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricCurrentUnit.Ampere: return baseUnitValue;
- case ElectricCurrentUnit.Centiampere: return (baseUnitValue) / 1e-2d;
- case ElectricCurrentUnit.Kiloampere: return (baseUnitValue) / 1e3d;
- case ElectricCurrentUnit.Megaampere: return (baseUnitValue) / 1e6d;
- case ElectricCurrentUnit.Microampere: return (baseUnitValue) / 1e-6d;
- case ElectricCurrentUnit.Milliampere: return (baseUnitValue) / 1e-3d;
- case ElectricCurrentUnit.Nanoampere: return (baseUnitValue) / 1e-9d;
- case ElectricCurrentUnit.Picoampere: return (baseUnitValue) / 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricCurrent Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricCurrent result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricCurrentUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Ampere
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricCurrentUnit ToStringDefaultUnit { get; set; } = ElectricCurrentUnit.Ampere;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricCurrentUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricCurrent
- ///
- public static ElectricCurrent MaxValue => new ElectricCurrent(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricCurrent
- ///
- public static ElectricCurrent MinValue => new ElectricCurrent(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricCurrent.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricCurrent.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricCurrentDensity.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricCurrentDensity.Common.g.cs
deleted file mode 100644
index 068d588b5e..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricCurrentDensity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In electromagnetism, current density is the electric current per unit area of cross section.
- ///
- // 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 ElectricCurrentDensity : IQuantity
-#else
- public partial struct ElectricCurrentDensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricCurrentDensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricCurrentDensity()
- {
- BaseDimensions = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit AmperePerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricCurrentDensity(double amperespersquaremeter)
- {
- _value = Convert.ToDouble(amperespersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricCurrentDensity(double numericValue, ElectricCurrentDensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerSquareMeter.
- ///
- /// Value assuming base unit AmperePerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrentDensity(long amperespersquaremeter) : this(Convert.ToDouble(amperespersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerSquareMeter.
- ///
- /// Value assuming base unit AmperePerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrentDensity(decimal amperespersquaremeter) : this(Convert.ToDouble(amperespersquaremeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricCurrentDensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricCurrentDensityUnit BaseUnit => ElectricCurrentDensityUnit.AmperePerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricCurrentDensity quantity.
- ///
- public static ElectricCurrentDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().Except(new ElectricCurrentDensityUnit[]{ ElectricCurrentDensityUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricCurrentDensity in AmperesPerSquareMeter.
- ///
- public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSquareMeter.
- ///
- public static ElectricCurrentDensity Zero => new ElectricCurrentDensity(0, BaseUnit);
-
- ///
- /// Get ElectricCurrentDensity from AmperesPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrentDensity FromAmperesPerSquareMeter(double amperespersquaremeter)
-#else
- public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amperespersquaremeter)
-#endif
- {
- double value = (double) amperespersquaremeter;
- return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricCurrentDensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricCurrentDensity From(double value, ElectricCurrentDensityUnit fromUnit)
-#else
- public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDensityUnit fromUnit)
-#endif
- {
- return new ElectricCurrentDensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricCurrentDensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricCurrentDensity)) throw new ArgumentException("Expected type ElectricCurrentDensity.", nameof(obj));
-
- return CompareTo((ElectricCurrentDensity)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(ElectricCurrentDensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricCurrentDensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricCurrentDensity))
- return false;
-
- var objQuantity = (ElectricCurrentDensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricCurrentDensity 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.
- [Obsolete("Please use the Equals(ElectricCurrentDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricCurrentDensity.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricCurrentDensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricCurrentDensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation .
- ///
- /// A ElectricCurrentDensity with the specified unit.
- public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricCurrentDensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricCurrentDensityUnit.AmperePerSquareMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricCurrentDensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricCurrentDensityUnit.AmperePerSquareMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricCurrentDensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricCurrentDensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricCurrentDensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is AmperePerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricCurrentDensityUnit ToStringDefaultUnit { get; set; } = ElectricCurrentDensityUnit.AmperePerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricCurrentDensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricCurrentDensity
- ///
- public static ElectricCurrentDensity MaxValue => new ElectricCurrentDensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricCurrentDensity
- ///
- public static ElectricCurrentDensity MinValue => new ElectricCurrentDensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricCurrentDensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricCurrentDensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricCurrentGradient.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricCurrentGradient.Common.g.cs
deleted file mode 100644
index 1880db6d86..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricCurrentGradient.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In electromagnetism, the current gradient describes how the current changes in time.
- ///
- // 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 ElectricCurrentGradient : IQuantity
-#else
- public partial struct ElectricCurrentGradient : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricCurrentGradientUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricCurrentGradient()
- {
- BaseDimensions = new BaseDimensions(0, 0, -1, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit AmperePerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricCurrentGradient(double amperespersecond)
- {
- _value = Convert.ToDouble(amperespersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricCurrentGradient(double numericValue, ElectricCurrentGradientUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerSecond.
- ///
- /// Value assuming base unit AmperePerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrentGradient(long amperespersecond) : this(Convert.ToDouble(amperespersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerSecond.
- ///
- /// Value assuming base unit AmperePerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricCurrentGradient(decimal amperespersecond) : this(Convert.ToDouble(amperespersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricCurrentGradient;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricCurrentGradientUnit BaseUnit => ElectricCurrentGradientUnit.AmperePerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricCurrentGradient quantity.
- ///
- public static ElectricCurrentGradientUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().Except(new ElectricCurrentGradientUnit[]{ ElectricCurrentGradientUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricCurrentGradient in AmperesPerSecond.
- ///
- public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSecond.
- ///
- public static ElectricCurrentGradient Zero => new ElectricCurrentGradient(0, BaseUnit);
-
- ///
- /// Get ElectricCurrentGradient from AmperesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricCurrentGradient FromAmperesPerSecond(double amperespersecond)
-#else
- public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperespersecond)
-#endif
- {
- double value = (double) amperespersecond;
- return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricCurrentGradient unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricCurrentGradient From(double value, ElectricCurrentGradientUnit fromUnit)
-#else
- public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentGradientUnit fromUnit)
-#endif
- {
- return new ElectricCurrentGradient((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricCurrentGradientUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricCurrentGradient)) throw new ArgumentException("Expected type ElectricCurrentGradient.", nameof(obj));
-
- return CompareTo((ElectricCurrentGradient)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(ElectricCurrentGradient other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricCurrentGradient, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricCurrentGradient))
- return false;
-
- var objQuantity = (ElectricCurrentGradient)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricCurrentGradient 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.
- [Obsolete("Please use the Equals(ElectricCurrentGradient, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricCurrentGradient.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricCurrentGradient), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricCurrentGradientUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation .
- ///
- /// A ElectricCurrentGradient with the specified unit.
- public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricCurrentGradient(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricCurrentGradientUnit.AmperePerSecond: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricCurrentGradientUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricCurrentGradientUnit.AmperePerSecond: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricCurrentGradient Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricCurrentGradient result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricCurrentGradientUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is AmperePerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricCurrentGradientUnit ToStringDefaultUnit { get; set; } = ElectricCurrentGradientUnit.AmperePerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricCurrentGradientUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricCurrentGradient
- ///
- public static ElectricCurrentGradient MaxValue => new ElectricCurrentGradient(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricCurrentGradient
- ///
- public static ElectricCurrentGradient MinValue => new ElectricCurrentGradient(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricCurrentGradient.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricCurrentGradient.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricField.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricField.Common.g.cs
deleted file mode 100644
index e6df7eee3b..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricField.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// An electric field is a force field that surrounds electric charges that attracts or repels other electric charges.
- ///
- // 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 ElectricField : IQuantity
-#else
- public partial struct ElectricField : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricFieldUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricField()
- {
- BaseDimensions = new BaseDimensions(1, 1, -3, -1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricField(double voltspermeter)
- {
- _value = Convert.ToDouble(voltspermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricField(double numericValue, ElectricFieldUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltPerMeter.
- ///
- /// Value assuming base unit VoltPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricField(long voltspermeter) : this(Convert.ToDouble(voltspermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltPerMeter.
- ///
- /// Value assuming base unit VoltPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricField(decimal voltspermeter) : this(Convert.ToDouble(voltspermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricField;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricFieldUnit BaseUnit => ElectricFieldUnit.VoltPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricField quantity.
- ///
- public static ElectricFieldUnit[] Units { get; } = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().Except(new ElectricFieldUnit[]{ ElectricFieldUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricField in VoltsPerMeter.
- ///
- public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerMeter.
- ///
- public static ElectricField Zero => new ElectricField(0, BaseUnit);
-
- ///
- /// Get ElectricField from VoltsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricField FromVoltsPerMeter(double voltspermeter)
-#else
- public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter)
-#endif
- {
- double value = (double) voltspermeter;
- return new ElectricField(value, ElectricFieldUnit.VoltPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricField unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricField From(double value, ElectricFieldUnit fromUnit)
-#else
- public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit)
-#endif
- {
- return new ElectricField((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricFieldUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricField)) throw new ArgumentException("Expected type ElectricField.", nameof(obj));
-
- return CompareTo((ElectricField)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(ElectricField other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricField, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricField))
- return false;
-
- var objQuantity = (ElectricField)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricField within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricField 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.
- [Obsolete("Please use the Equals(ElectricField, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricField other, ElectricField maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricField.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricField), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricFieldUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricField to another ElectricField with the unit representation .
- ///
- /// A ElectricField with the specified unit.
- public ElectricField ToUnit(ElectricFieldUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricField(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricFieldUnit.VoltPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricFieldUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricFieldUnit.VoltPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricField Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricField result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricFieldUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricFieldUnit ToStringDefaultUnit { get; set; } = ElectricFieldUnit.VoltPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricFieldUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricField
- ///
- public static ElectricField MaxValue => new ElectricField(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricField
- ///
- public static ElectricField MinValue => new ElectricField(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricField.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricField.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricInductance.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricInductance.Common.g.cs
deleted file mode 100644
index 06827b5895..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricInductance.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Inductance is a property of an electrical conductor which opposes a change in current.
- ///
- // 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 ElectricInductance : IQuantity
-#else
- public partial struct ElectricInductance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricInductanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricInductance()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Henry.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricInductance(double henries)
- {
- _value = Convert.ToDouble(henries);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricInductance(double numericValue, ElectricInductanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Henry.
- ///
- /// Value assuming base unit Henry.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricInductance(long henries) : this(Convert.ToDouble(henries), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Henry.
- ///
- /// Value assuming base unit Henry.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricInductance(decimal henries) : this(Convert.ToDouble(henries), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricInductance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricInductanceUnit BaseUnit => ElectricInductanceUnit.Henry;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricInductance quantity.
- ///
- public static ElectricInductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().Except(new ElectricInductanceUnit[]{ ElectricInductanceUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricInductance in Henries.
- ///
- public double Henries => As(ElectricInductanceUnit.Henry);
-
- ///
- /// Get ElectricInductance in Microhenries.
- ///
- public double Microhenries => As(ElectricInductanceUnit.Microhenry);
-
- ///
- /// Get ElectricInductance in Millihenries.
- ///
- public double Millihenries => As(ElectricInductanceUnit.Millihenry);
-
- ///
- /// Get ElectricInductance in Nanohenries.
- ///
- public double Nanohenries => As(ElectricInductanceUnit.Nanohenry);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Henry.
- ///
- public static ElectricInductance Zero => new ElectricInductance(0, BaseUnit);
-
- ///
- /// Get ElectricInductance from Henries.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricInductance FromHenries(double henries)
-#else
- public static ElectricInductance FromHenries(QuantityValue henries)
-#endif
- {
- double value = (double) henries;
- return new ElectricInductance(value, ElectricInductanceUnit.Henry);
- }
-
- ///
- /// Get ElectricInductance from Microhenries.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricInductance FromMicrohenries(double microhenries)
-#else
- public static ElectricInductance FromMicrohenries(QuantityValue microhenries)
-#endif
- {
- double value = (double) microhenries;
- return new ElectricInductance(value, ElectricInductanceUnit.Microhenry);
- }
-
- ///
- /// Get ElectricInductance from Millihenries.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricInductance FromMillihenries(double millihenries)
-#else
- public static ElectricInductance FromMillihenries(QuantityValue millihenries)
-#endif
- {
- double value = (double) millihenries;
- return new ElectricInductance(value, ElectricInductanceUnit.Millihenry);
- }
-
- ///
- /// Get ElectricInductance from Nanohenries.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricInductance FromNanohenries(double nanohenries)
-#else
- public static ElectricInductance FromNanohenries(QuantityValue nanohenries)
-#endif
- {
- double value = (double) nanohenries;
- return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricInductance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricInductance From(double value, ElectricInductanceUnit fromUnit)
-#else
- public static ElectricInductance From(QuantityValue value, ElectricInductanceUnit fromUnit)
-#endif
- {
- return new ElectricInductance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricInductanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricInductance)) throw new ArgumentException("Expected type ElectricInductance.", nameof(obj));
-
- return CompareTo((ElectricInductance)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(ElectricInductance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricInductance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricInductance))
- return false;
-
- var objQuantity = (ElectricInductance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricInductance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricInductance 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.
- [Obsolete("Please use the Equals(ElectricInductance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricInductance other, ElectricInductance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricInductance.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricInductance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricInductanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricInductance to another ElectricInductance with the unit representation .
- ///
- /// A ElectricInductance with the specified unit.
- public ElectricInductance ToUnit(ElectricInductanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricInductance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricInductanceUnit.Henry: return _value;
- case ElectricInductanceUnit.Microhenry: return (_value) * 1e-6d;
- case ElectricInductanceUnit.Millihenry: return (_value) * 1e-3d;
- case ElectricInductanceUnit.Nanohenry: return (_value) * 1e-9d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricInductanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricInductanceUnit.Henry: return baseUnitValue;
- case ElectricInductanceUnit.Microhenry: return (baseUnitValue) / 1e-6d;
- case ElectricInductanceUnit.Millihenry: return (baseUnitValue) / 1e-3d;
- case ElectricInductanceUnit.Nanohenry: return (baseUnitValue) / 1e-9d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricInductance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricInductance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricInductanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Henry
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricInductanceUnit ToStringDefaultUnit { get; set; } = ElectricInductanceUnit.Henry;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricInductanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricInductance
- ///
- public static ElectricInductance MaxValue => new ElectricInductance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricInductance
- ///
- public static ElectricInductance MinValue => new ElectricInductance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricInductance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricInductance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricPotential.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricPotential.Common.g.cs
deleted file mode 100644
index 147102a30b..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricPotential.Common.g.cs
+++ /dev/null
@@ -1,574 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 ElectricPotential : IQuantity
-#else
- public partial struct ElectricPotential : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricPotentialUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricPotential()
- {
- BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Volt.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricPotential(double volts)
- {
- _value = Convert.ToDouble(volts);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricPotential(double numericValue, ElectricPotentialUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Volt.
- ///
- /// Value assuming base unit Volt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotential(long volts) : this(Convert.ToDouble(volts), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Volt.
- ///
- /// Value assuming base unit Volt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotential(decimal volts) : this(Convert.ToDouble(volts), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricPotential;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricPotentialUnit BaseUnit => ElectricPotentialUnit.Volt;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricPotential quantity.
- ///
- public static ElectricPotentialUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().Except(new ElectricPotentialUnit[]{ ElectricPotentialUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricPotential in Kilovolts.
- ///
- public double Kilovolts => As(ElectricPotentialUnit.Kilovolt);
-
- ///
- /// Get ElectricPotential in Megavolts.
- ///
- public double Megavolts => As(ElectricPotentialUnit.Megavolt);
-
- ///
- /// Get ElectricPotential in Microvolts.
- ///
- public double Microvolts => As(ElectricPotentialUnit.Microvolt);
-
- ///
- /// Get ElectricPotential in Millivolts.
- ///
- public double Millivolts => As(ElectricPotentialUnit.Millivolt);
-
- ///
- /// Get ElectricPotential in Volts.
- ///
- public double Volts => As(ElectricPotentialUnit.Volt);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Volt.
- ///
- public static ElectricPotential Zero => new ElectricPotential(0, BaseUnit);
-
- ///
- /// Get ElectricPotential from Kilovolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotential FromKilovolts(double kilovolts)
-#else
- public static ElectricPotential FromKilovolts(QuantityValue kilovolts)
-#endif
- {
- double value = (double) kilovolts;
- return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt);
- }
-
- ///
- /// Get ElectricPotential from Megavolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotential FromMegavolts(double megavolts)
-#else
- public static ElectricPotential FromMegavolts(QuantityValue megavolts)
-#endif
- {
- double value = (double) megavolts;
- return new ElectricPotential(value, ElectricPotentialUnit.Megavolt);
- }
-
- ///
- /// Get ElectricPotential from Microvolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotential FromMicrovolts(double microvolts)
-#else
- public static ElectricPotential FromMicrovolts(QuantityValue microvolts)
-#endif
- {
- double value = (double) microvolts;
- return new ElectricPotential(value, ElectricPotentialUnit.Microvolt);
- }
-
- ///
- /// Get ElectricPotential from Millivolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotential FromMillivolts(double millivolts)
-#else
- public static ElectricPotential FromMillivolts(QuantityValue millivolts)
-#endif
- {
- double value = (double) millivolts;
- return new ElectricPotential(value, ElectricPotentialUnit.Millivolt);
- }
-
- ///
- /// Get ElectricPotential from Volts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotential FromVolts(double volts)
-#else
- public static ElectricPotential FromVolts(QuantityValue volts)
-#endif
- {
- double value = (double) volts;
- return new ElectricPotential(value, ElectricPotentialUnit.Volt);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricPotential unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricPotential From(double value, ElectricPotentialUnit fromUnit)
-#else
- public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit fromUnit)
-#endif
- {
- return new ElectricPotential((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricPotentialUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricPotential)) throw new ArgumentException("Expected type ElectricPotential.", nameof(obj));
-
- return CompareTo((ElectricPotential)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(ElectricPotential other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricPotential, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricPotential))
- return false;
-
- var objQuantity = (ElectricPotential)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricPotential within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricPotential 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.
- [Obsolete("Please use the Equals(ElectricPotential, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricPotential other, ElectricPotential maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricPotential.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricPotential), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricPotentialUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricPotential to another ElectricPotential with the unit representation .
- ///
- /// A ElectricPotential with the specified unit.
- public ElectricPotential ToUnit(ElectricPotentialUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricPotential(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricPotentialUnit.Kilovolt: return (_value) * 1e3d;
- case ElectricPotentialUnit.Megavolt: return (_value) * 1e6d;
- case ElectricPotentialUnit.Microvolt: return (_value) * 1e-6d;
- case ElectricPotentialUnit.Millivolt: return (_value) * 1e-3d;
- case ElectricPotentialUnit.Volt: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricPotentialUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricPotentialUnit.Kilovolt: return (baseUnitValue) / 1e3d;
- case ElectricPotentialUnit.Megavolt: return (baseUnitValue) / 1e6d;
- case ElectricPotentialUnit.Microvolt: return (baseUnitValue) / 1e-6d;
- case ElectricPotentialUnit.Millivolt: return (baseUnitValue) / 1e-3d;
- case ElectricPotentialUnit.Volt: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricPotential Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricPotential result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricPotentialUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Volt
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricPotentialUnit ToStringDefaultUnit { get; set; } = ElectricPotentialUnit.Volt;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricPotentialUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricPotential
- ///
- public static ElectricPotential MaxValue => new ElectricPotential(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricPotential
- ///
- public static ElectricPotential MinValue => new ElectricPotential(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricPotential.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricPotential.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricPotentialAc.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricPotentialAc.Common.g.cs
deleted file mode 100644
index 3a0da333ad..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricPotentialAc.Common.g.cs
+++ /dev/null
@@ -1,573 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The Electric Potential of a system known to use Alternating Current.
- ///
- // 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 ElectricPotentialAc : IQuantity
-#else
- public partial struct ElectricPotentialAc : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricPotentialAcUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricPotentialAc()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltAc.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricPotentialAc(double voltsac)
- {
- _value = Convert.ToDouble(voltsac);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricPotentialAc(double numericValue, ElectricPotentialAcUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltAc.
- ///
- /// Value assuming base unit VoltAc.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotentialAc(long voltsac) : this(Convert.ToDouble(voltsac), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltAc.
- ///
- /// Value assuming base unit VoltAc.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotentialAc(decimal voltsac) : this(Convert.ToDouble(voltsac), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricPotentialAc;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricPotentialAcUnit BaseUnit => ElectricPotentialAcUnit.VoltAc;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricPotentialAc quantity.
- ///
- public static ElectricPotentialAcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().Except(new ElectricPotentialAcUnit[]{ ElectricPotentialAcUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricPotentialAc in KilovoltsAc.
- ///
- public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc);
-
- ///
- /// Get ElectricPotentialAc in MegavoltsAc.
- ///
- public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc);
-
- ///
- /// Get ElectricPotentialAc in MicrovoltsAc.
- ///
- public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc);
-
- ///
- /// Get ElectricPotentialAc in MillivoltsAc.
- ///
- public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc);
-
- ///
- /// Get ElectricPotentialAc in VoltsAc.
- ///
- public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltAc.
- ///
- public static ElectricPotentialAc Zero => new ElectricPotentialAc(0, BaseUnit);
-
- ///
- /// Get ElectricPotentialAc from KilovoltsAc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialAc FromKilovoltsAc(double kilovoltsac)
-#else
- public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac)
-#endif
- {
- double value = (double) kilovoltsac;
- return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc);
- }
-
- ///
- /// Get ElectricPotentialAc from MegavoltsAc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialAc FromMegavoltsAc(double megavoltsac)
-#else
- public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac)
-#endif
- {
- double value = (double) megavoltsac;
- return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc);
- }
-
- ///
- /// Get ElectricPotentialAc from MicrovoltsAc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialAc FromMicrovoltsAc(double microvoltsac)
-#else
- public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac)
-#endif
- {
- double value = (double) microvoltsac;
- return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc);
- }
-
- ///
- /// Get ElectricPotentialAc from MillivoltsAc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialAc FromMillivoltsAc(double millivoltsac)
-#else
- public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac)
-#endif
- {
- double value = (double) millivoltsac;
- return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc);
- }
-
- ///
- /// Get ElectricPotentialAc from VoltsAc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialAc FromVoltsAc(double voltsac)
-#else
- public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac)
-#endif
- {
- double value = (double) voltsac;
- return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricPotentialAc unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricPotentialAc From(double value, ElectricPotentialAcUnit fromUnit)
-#else
- public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcUnit fromUnit)
-#endif
- {
- return new ElectricPotentialAc((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricPotentialAcUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricPotentialAc)) throw new ArgumentException("Expected type ElectricPotentialAc.", nameof(obj));
-
- return CompareTo((ElectricPotentialAc)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(ElectricPotentialAc other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricPotentialAc, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricPotentialAc))
- return false;
-
- var objQuantity = (ElectricPotentialAc)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricPotentialAc within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricPotentialAc 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.
- [Obsolete("Please use the Equals(ElectricPotentialAc, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricPotentialAc other, ElectricPotentialAc maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricPotentialAc.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricPotentialAc), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricPotentialAcUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricPotentialAc to another ElectricPotentialAc with the unit representation .
- ///
- /// A ElectricPotentialAc with the specified unit.
- public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricPotentialAc(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricPotentialAcUnit.KilovoltAc: return (_value) * 1e3d;
- case ElectricPotentialAcUnit.MegavoltAc: return (_value) * 1e6d;
- case ElectricPotentialAcUnit.MicrovoltAc: return (_value) * 1e-6d;
- case ElectricPotentialAcUnit.MillivoltAc: return (_value) * 1e-3d;
- case ElectricPotentialAcUnit.VoltAc: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricPotentialAcUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricPotentialAcUnit.KilovoltAc: return (baseUnitValue) / 1e3d;
- case ElectricPotentialAcUnit.MegavoltAc: return (baseUnitValue) / 1e6d;
- case ElectricPotentialAcUnit.MicrovoltAc: return (baseUnitValue) / 1e-6d;
- case ElectricPotentialAcUnit.MillivoltAc: return (baseUnitValue) / 1e-3d;
- case ElectricPotentialAcUnit.VoltAc: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricPotentialAc Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricPotentialAc result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricPotentialAcUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltAc
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricPotentialAcUnit ToStringDefaultUnit { get; set; } = ElectricPotentialAcUnit.VoltAc;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricPotentialAcUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricPotentialAc
- ///
- public static ElectricPotentialAc MaxValue => new ElectricPotentialAc(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricPotentialAc
- ///
- public static ElectricPotentialAc MinValue => new ElectricPotentialAc(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricPotentialAc.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricPotentialAc.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricPotentialDc.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricPotentialDc.Common.g.cs
deleted file mode 100644
index ad022b884c..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricPotentialDc.Common.g.cs
+++ /dev/null
@@ -1,573 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The Electric Potential of a system known to use Direct Current.
- ///
- // 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 ElectricPotentialDc : IQuantity
-#else
- public partial struct ElectricPotentialDc : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricPotentialDcUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricPotentialDc()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltDc.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricPotentialDc(double voltsdc)
- {
- _value = Convert.ToDouble(voltsdc);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricPotentialDc(double numericValue, ElectricPotentialDcUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltDc.
- ///
- /// Value assuming base unit VoltDc.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotentialDc(long voltsdc) : this(Convert.ToDouble(voltsdc), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltDc.
- ///
- /// Value assuming base unit VoltDc.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricPotentialDc(decimal voltsdc) : this(Convert.ToDouble(voltsdc), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricPotentialDc;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricPotentialDcUnit BaseUnit => ElectricPotentialDcUnit.VoltDc;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricPotentialDc quantity.
- ///
- public static ElectricPotentialDcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().Except(new ElectricPotentialDcUnit[]{ ElectricPotentialDcUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricPotentialDc in KilovoltsDc.
- ///
- public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc);
-
- ///
- /// Get ElectricPotentialDc in MegavoltsDc.
- ///
- public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc);
-
- ///
- /// Get ElectricPotentialDc in MicrovoltsDc.
- ///
- public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc);
-
- ///
- /// Get ElectricPotentialDc in MillivoltsDc.
- ///
- public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc);
-
- ///
- /// Get ElectricPotentialDc in VoltsDc.
- ///
- public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltDc.
- ///
- public static ElectricPotentialDc Zero => new ElectricPotentialDc(0, BaseUnit);
-
- ///
- /// Get ElectricPotentialDc from KilovoltsDc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialDc FromKilovoltsDc(double kilovoltsdc)
-#else
- public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc)
-#endif
- {
- double value = (double) kilovoltsdc;
- return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc);
- }
-
- ///
- /// Get ElectricPotentialDc from MegavoltsDc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialDc FromMegavoltsDc(double megavoltsdc)
-#else
- public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc)
-#endif
- {
- double value = (double) megavoltsdc;
- return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc);
- }
-
- ///
- /// Get ElectricPotentialDc from MicrovoltsDc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialDc FromMicrovoltsDc(double microvoltsdc)
-#else
- public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc)
-#endif
- {
- double value = (double) microvoltsdc;
- return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc);
- }
-
- ///
- /// Get ElectricPotentialDc from MillivoltsDc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialDc FromMillivoltsDc(double millivoltsdc)
-#else
- public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc)
-#endif
- {
- double value = (double) millivoltsdc;
- return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc);
- }
-
- ///
- /// Get ElectricPotentialDc from VoltsDc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricPotentialDc FromVoltsDc(double voltsdc)
-#else
- public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc)
-#endif
- {
- double value = (double) voltsdc;
- return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricPotentialDc unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricPotentialDc From(double value, ElectricPotentialDcUnit fromUnit)
-#else
- public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcUnit fromUnit)
-#endif
- {
- return new ElectricPotentialDc((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricPotentialDcUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricPotentialDc)) throw new ArgumentException("Expected type ElectricPotentialDc.", nameof(obj));
-
- return CompareTo((ElectricPotentialDc)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(ElectricPotentialDc other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricPotentialDc, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricPotentialDc))
- return false;
-
- var objQuantity = (ElectricPotentialDc)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricPotentialDc within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricPotentialDc 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.
- [Obsolete("Please use the Equals(ElectricPotentialDc, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricPotentialDc other, ElectricPotentialDc maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricPotentialDc.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricPotentialDc), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricPotentialDcUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricPotentialDc to another ElectricPotentialDc with the unit representation .
- ///
- /// A ElectricPotentialDc with the specified unit.
- public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricPotentialDc(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricPotentialDcUnit.KilovoltDc: return (_value) * 1e3d;
- case ElectricPotentialDcUnit.MegavoltDc: return (_value) * 1e6d;
- case ElectricPotentialDcUnit.MicrovoltDc: return (_value) * 1e-6d;
- case ElectricPotentialDcUnit.MillivoltDc: return (_value) * 1e-3d;
- case ElectricPotentialDcUnit.VoltDc: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricPotentialDcUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricPotentialDcUnit.KilovoltDc: return (baseUnitValue) / 1e3d;
- case ElectricPotentialDcUnit.MegavoltDc: return (baseUnitValue) / 1e6d;
- case ElectricPotentialDcUnit.MicrovoltDc: return (baseUnitValue) / 1e-6d;
- case ElectricPotentialDcUnit.MillivoltDc: return (baseUnitValue) / 1e-3d;
- case ElectricPotentialDcUnit.VoltDc: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricPotentialDc Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricPotentialDc result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricPotentialDcUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltDc
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricPotentialDcUnit ToStringDefaultUnit { get; set; } = ElectricPotentialDcUnit.VoltDc;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricPotentialDcUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricPotentialDc
- ///
- public static ElectricPotentialDc MaxValue => new ElectricPotentialDc(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricPotentialDc
- ///
- public static ElectricPotentialDc MinValue => new ElectricPotentialDc(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricPotentialDc.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricPotentialDc.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricResistance.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricResistance.Common.g.cs
deleted file mode 100644
index c11fbc7cda..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricResistance.Common.g.cs
+++ /dev/null
@@ -1,574 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.
- ///
- // 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 ElectricResistance : IQuantity
-#else
- public partial struct ElectricResistance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricResistanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricResistance()
- {
- BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Ohm.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricResistance(double ohms)
- {
- _value = Convert.ToDouble(ohms);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricResistance(double numericValue, ElectricResistanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Ohm.
- ///
- /// Value assuming base unit Ohm.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricResistance(long ohms) : this(Convert.ToDouble(ohms), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Ohm.
- ///
- /// Value assuming base unit Ohm.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricResistance(decimal ohms) : this(Convert.ToDouble(ohms), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricResistance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricResistanceUnit BaseUnit => ElectricResistanceUnit.Ohm;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricResistance quantity.
- ///
- public static ElectricResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().Except(new ElectricResistanceUnit[]{ ElectricResistanceUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricResistance in Gigaohms.
- ///
- public double Gigaohms => As(ElectricResistanceUnit.Gigaohm);
-
- ///
- /// Get ElectricResistance in Kiloohms.
- ///
- public double Kiloohms => As(ElectricResistanceUnit.Kiloohm);
-
- ///
- /// Get ElectricResistance in Megaohms.
- ///
- public double Megaohms => As(ElectricResistanceUnit.Megaohm);
-
- ///
- /// Get ElectricResistance in Milliohms.
- ///
- public double Milliohms => As(ElectricResistanceUnit.Milliohm);
-
- ///
- /// Get ElectricResistance in Ohms.
- ///
- public double Ohms => As(ElectricResistanceUnit.Ohm);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Ohm.
- ///
- public static ElectricResistance Zero => new ElectricResistance(0, BaseUnit);
-
- ///
- /// Get ElectricResistance from Gigaohms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistance FromGigaohms(double gigaohms)
-#else
- public static ElectricResistance FromGigaohms(QuantityValue gigaohms)
-#endif
- {
- double value = (double) gigaohms;
- return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm);
- }
-
- ///
- /// Get ElectricResistance from Kiloohms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistance FromKiloohms(double kiloohms)
-#else
- public static ElectricResistance FromKiloohms(QuantityValue kiloohms)
-#endif
- {
- double value = (double) kiloohms;
- return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm);
- }
-
- ///
- /// Get ElectricResistance from Megaohms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistance FromMegaohms(double megaohms)
-#else
- public static ElectricResistance FromMegaohms(QuantityValue megaohms)
-#endif
- {
- double value = (double) megaohms;
- return new ElectricResistance(value, ElectricResistanceUnit.Megaohm);
- }
-
- ///
- /// Get ElectricResistance from Milliohms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistance FromMilliohms(double milliohms)
-#else
- public static ElectricResistance FromMilliohms(QuantityValue milliohms)
-#endif
- {
- double value = (double) milliohms;
- return new ElectricResistance(value, ElectricResistanceUnit.Milliohm);
- }
-
- ///
- /// Get ElectricResistance from Ohms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistance FromOhms(double ohms)
-#else
- public static ElectricResistance FromOhms(QuantityValue ohms)
-#endif
- {
- double value = (double) ohms;
- return new ElectricResistance(value, ElectricResistanceUnit.Ohm);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricResistance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricResistance From(double value, ElectricResistanceUnit fromUnit)
-#else
- public static ElectricResistance From(QuantityValue value, ElectricResistanceUnit fromUnit)
-#endif
- {
- return new ElectricResistance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricResistanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricResistance)) throw new ArgumentException("Expected type ElectricResistance.", nameof(obj));
-
- return CompareTo((ElectricResistance)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(ElectricResistance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricResistance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricResistance))
- return false;
-
- var objQuantity = (ElectricResistance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricResistance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricResistance 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.
- [Obsolete("Please use the Equals(ElectricResistance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricResistance other, ElectricResistance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricResistance.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricResistance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricResistanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricResistance to another ElectricResistance with the unit representation .
- ///
- /// A ElectricResistance with the specified unit.
- public ElectricResistance ToUnit(ElectricResistanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricResistance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricResistanceUnit.Gigaohm: return (_value) * 1e9d;
- case ElectricResistanceUnit.Kiloohm: return (_value) * 1e3d;
- case ElectricResistanceUnit.Megaohm: return (_value) * 1e6d;
- case ElectricResistanceUnit.Milliohm: return (_value) * 1e-3d;
- case ElectricResistanceUnit.Ohm: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricResistanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricResistanceUnit.Gigaohm: return (baseUnitValue) / 1e9d;
- case ElectricResistanceUnit.Kiloohm: return (baseUnitValue) / 1e3d;
- case ElectricResistanceUnit.Megaohm: return (baseUnitValue) / 1e6d;
- case ElectricResistanceUnit.Milliohm: return (baseUnitValue) / 1e-3d;
- case ElectricResistanceUnit.Ohm: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricResistance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricResistance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricResistanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Ohm
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricResistanceUnit ToStringDefaultUnit { get; set; } = ElectricResistanceUnit.Ohm;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricResistanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricResistance
- ///
- public static ElectricResistance MaxValue => new ElectricResistance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricResistance
- ///
- public static ElectricResistance MinValue => new ElectricResistance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricResistance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricResistance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ElectricResistivity.Common.g.cs b/Common/GeneratedCode/Quantities/ElectricResistivity.Common.g.cs
deleted file mode 100644
index 87b6d9e513..0000000000
--- a/Common/GeneratedCode/Quantities/ElectricResistivity.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current.
- ///
- // 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 ElectricResistivity : IQuantity
-#else
- public partial struct ElectricResistivity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ElectricResistivityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ElectricResistivity()
- {
- BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit OhmMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ElectricResistivity(double ohmmeters)
- {
- _value = Convert.ToDouble(ohmmeters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ElectricResistivity(double numericValue, ElectricResistivityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit OhmMeter.
- ///
- /// Value assuming base unit OhmMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricResistivity(long ohmmeters) : this(Convert.ToDouble(ohmmeters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit OhmMeter.
- ///
- /// Value assuming base unit OhmMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ElectricResistivity(decimal ohmmeters) : this(Convert.ToDouble(ohmmeters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ElectricResistivity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ElectricResistivityUnit BaseUnit => ElectricResistivityUnit.OhmMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ElectricResistivity quantity.
- ///
- public static ElectricResistivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().Except(new ElectricResistivityUnit[]{ ElectricResistivityUnit.Undefined }).ToArray();
-
- ///
- /// Get ElectricResistivity in MicroohmMeters.
- ///
- public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter);
-
- ///
- /// Get ElectricResistivity in MilliohmMeters.
- ///
- public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter);
-
- ///
- /// Get ElectricResistivity in NanoohmMeters.
- ///
- public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter);
-
- ///
- /// Get ElectricResistivity in OhmMeters.
- ///
- public double OhmMeters => As(ElectricResistivityUnit.OhmMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit OhmMeter.
- ///
- public static ElectricResistivity Zero => new ElectricResistivity(0, BaseUnit);
-
- ///
- /// Get ElectricResistivity from MicroohmMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistivity FromMicroohmMeters(double microohmmeters)
-#else
- public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeters)
-#endif
- {
- double value = (double) microohmmeters;
- return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter);
- }
-
- ///
- /// Get ElectricResistivity from MilliohmMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistivity FromMilliohmMeters(double milliohmmeters)
-#else
- public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeters)
-#endif
- {
- double value = (double) milliohmmeters;
- return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter);
- }
-
- ///
- /// Get ElectricResistivity from NanoohmMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistivity FromNanoohmMeters(double nanoohmmeters)
-#else
- public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters)
-#endif
- {
- double value = (double) nanoohmmeters;
- return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter);
- }
-
- ///
- /// Get ElectricResistivity from OhmMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ElectricResistivity FromOhmMeters(double ohmmeters)
-#else
- public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters)
-#endif
- {
- double value = (double) ohmmeters;
- return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ElectricResistivity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ElectricResistivity From(double value, ElectricResistivityUnit fromUnit)
-#else
- public static ElectricResistivity From(QuantityValue value, ElectricResistivityUnit fromUnit)
-#endif
- {
- return new ElectricResistivity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ElectricResistivityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ElectricResistivity)) throw new ArgumentException("Expected type ElectricResistivity.", nameof(obj));
-
- return CompareTo((ElectricResistivity)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(ElectricResistivity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ElectricResistivity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ElectricResistivity))
- return false;
-
- var objQuantity = (ElectricResistivity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ElectricResistivity 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.
- [Obsolete("Please use the Equals(ElectricResistivity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ElectricResistivity other, ElectricResistivity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ElectricResistivity.
- public override int GetHashCode()
- {
- return new { type = typeof(ElectricResistivity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ElectricResistivityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation .
- ///
- /// A ElectricResistivity with the specified unit.
- public ElectricResistivity ToUnit(ElectricResistivityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ElectricResistivity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ElectricResistivityUnit.MicroohmMeter: return (_value) * 1e-6d;
- case ElectricResistivityUnit.MilliohmMeter: return (_value) * 1e-3d;
- case ElectricResistivityUnit.NanoohmMeter: return (_value) * 1e-9d;
- case ElectricResistivityUnit.OhmMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ElectricResistivityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ElectricResistivityUnit.MicroohmMeter: return (baseUnitValue) / 1e-6d;
- case ElectricResistivityUnit.MilliohmMeter: return (baseUnitValue) / 1e-3d;
- case ElectricResistivityUnit.NanoohmMeter: return (baseUnitValue) / 1e-9d;
- case ElectricResistivityUnit.OhmMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ElectricResistivity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ElectricResistivity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ElectricResistivityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is OhmMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ElectricResistivityUnit ToStringDefaultUnit { get; set; } = ElectricResistivityUnit.OhmMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ElectricResistivityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ElectricResistivity
- ///
- public static ElectricResistivity MaxValue => new ElectricResistivity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ElectricResistivity
- ///
- public static ElectricResistivity MinValue => new ElectricResistivity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ElectricResistivity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ElectricResistivity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Energy.Common.g.cs b/Common/GeneratedCode/Quantities/Energy.Common.g.cs
deleted file mode 100644
index 5d6a49f4b2..0000000000
--- a/Common/GeneratedCode/Quantities/Energy.Common.g.cs
+++ /dev/null
@@ -1,931 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Energy : IQuantity
-#else
- public partial struct Energy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly EnergyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public EnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Energy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Joule.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Energy(double joules)
- {
- _value = Convert.ToDouble(joules);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Energy(double numericValue, EnergyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Joule.
- ///
- /// Value assuming base unit Joule.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Energy(long joules) : this(Convert.ToDouble(joules), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Joule.
- ///
- /// Value assuming base unit Joule.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Energy(decimal joules) : this(Convert.ToDouble(joules), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Energy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static EnergyUnit BaseUnit => EnergyUnit.Joule;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Energy quantity.
- ///
- public static EnergyUnit[] Units { get; } = Enum.GetValues(typeof(EnergyUnit)).Cast().Except(new EnergyUnit[]{ EnergyUnit.Undefined }).ToArray();
-
- ///
- /// Get Energy in BritishThermalUnits.
- ///
- public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit);
-
- ///
- /// Get Energy in Calories.
- ///
- public double Calories => As(EnergyUnit.Calorie);
-
- ///
- /// Get Energy in DecathermsEc.
- ///
- public double DecathermsEc => As(EnergyUnit.DecathermEc);
-
- ///
- /// Get Energy in DecathermsImperial.
- ///
- public double DecathermsImperial => As(EnergyUnit.DecathermImperial);
-
- ///
- /// Get Energy in DecathermsUs.
- ///
- public double DecathermsUs => As(EnergyUnit.DecathermUs);
-
- ///
- /// Get Energy in ElectronVolts.
- ///
- public double ElectronVolts => As(EnergyUnit.ElectronVolt);
-
- ///
- /// Get Energy in Ergs.
- ///
- public double Ergs => As(EnergyUnit.Erg);
-
- ///
- /// Get Energy in FootPounds.
- ///
- public double FootPounds => As(EnergyUnit.FootPound);
-
- ///
- /// Get Energy in GigabritishThermalUnits.
- ///
- public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit);
-
- ///
- /// Get Energy in GigawattHours.
- ///
- public double GigawattHours => As(EnergyUnit.GigawattHour);
-
- ///
- /// Get Energy in Joules.
- ///
- public double Joules => As(EnergyUnit.Joule);
-
- ///
- /// Get Energy in KilobritishThermalUnits.
- ///
- public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit);
-
- ///
- /// Get Energy in Kilocalories.
- ///
- public double Kilocalories => As(EnergyUnit.Kilocalorie);
-
- ///
- /// Get Energy in Kilojoules.
- ///
- public double Kilojoules => As(EnergyUnit.Kilojoule);
-
- ///
- /// Get Energy in KilowattHours.
- ///
- public double KilowattHours => As(EnergyUnit.KilowattHour);
-
- ///
- /// Get Energy in MegabritishThermalUnits.
- ///
- public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit);
-
- ///
- /// Get Energy in Megajoules.
- ///
- public double Megajoules => As(EnergyUnit.Megajoule);
-
- ///
- /// Get Energy in MegawattHours.
- ///
- public double MegawattHours => As(EnergyUnit.MegawattHour);
-
- ///
- /// Get Energy in ThermsEc.
- ///
- public double ThermsEc => As(EnergyUnit.ThermEc);
-
- ///
- /// Get Energy in ThermsImperial.
- ///
- public double ThermsImperial => As(EnergyUnit.ThermImperial);
-
- ///
- /// Get Energy in ThermsUs.
- ///
- public double ThermsUs => As(EnergyUnit.ThermUs);
-
- ///
- /// Get Energy in WattHours.
- ///
- public double WattHours => As(EnergyUnit.WattHour);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Joule.
- ///
- public static Energy Zero => new Energy(0, BaseUnit);
-
- ///
- /// Get Energy from BritishThermalUnits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromBritishThermalUnits(double britishthermalunits)
-#else
- public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits)
-#endif
- {
- double value = (double) britishthermalunits;
- return new Energy(value, EnergyUnit.BritishThermalUnit);
- }
-
- ///
- /// Get Energy from Calories.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromCalories(double calories)
-#else
- public static Energy FromCalories(QuantityValue calories)
-#endif
- {
- double value = (double) calories;
- return new Energy(value, EnergyUnit.Calorie);
- }
-
- ///
- /// Get Energy from DecathermsEc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromDecathermsEc(double decathermsec)
-#else
- public static Energy FromDecathermsEc(QuantityValue decathermsec)
-#endif
- {
- double value = (double) decathermsec;
- return new Energy(value, EnergyUnit.DecathermEc);
- }
-
- ///
- /// Get Energy from DecathermsImperial.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromDecathermsImperial(double decathermsimperial)
-#else
- public static Energy FromDecathermsImperial(QuantityValue decathermsimperial)
-#endif
- {
- double value = (double) decathermsimperial;
- return new Energy(value, EnergyUnit.DecathermImperial);
- }
-
- ///
- /// Get Energy from DecathermsUs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromDecathermsUs(double decathermsus)
-#else
- public static Energy FromDecathermsUs(QuantityValue decathermsus)
-#endif
- {
- double value = (double) decathermsus;
- return new Energy(value, EnergyUnit.DecathermUs);
- }
-
- ///
- /// Get Energy from ElectronVolts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromElectronVolts(double electronvolts)
-#else
- public static Energy FromElectronVolts(QuantityValue electronvolts)
-#endif
- {
- double value = (double) electronvolts;
- return new Energy(value, EnergyUnit.ElectronVolt);
- }
-
- ///
- /// Get Energy from Ergs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromErgs(double ergs)
-#else
- public static Energy FromErgs(QuantityValue ergs)
-#endif
- {
- double value = (double) ergs;
- return new Energy(value, EnergyUnit.Erg);
- }
-
- ///
- /// Get Energy from FootPounds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromFootPounds(double footpounds)
-#else
- public static Energy FromFootPounds(QuantityValue footpounds)
-#endif
- {
- double value = (double) footpounds;
- return new Energy(value, EnergyUnit.FootPound);
- }
-
- ///
- /// Get Energy from GigabritishThermalUnits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromGigabritishThermalUnits(double gigabritishthermalunits)
-#else
- public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishthermalunits)
-#endif
- {
- double value = (double) gigabritishthermalunits;
- return new Energy(value, EnergyUnit.GigabritishThermalUnit);
- }
-
- ///
- /// Get Energy from GigawattHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromGigawattHours(double gigawatthours)
-#else
- public static Energy FromGigawattHours(QuantityValue gigawatthours)
-#endif
- {
- double value = (double) gigawatthours;
- return new Energy(value, EnergyUnit.GigawattHour);
- }
-
- ///
- /// Get Energy from Joules.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromJoules(double joules)
-#else
- public static Energy FromJoules(QuantityValue joules)
-#endif
- {
- double value = (double) joules;
- return new Energy(value, EnergyUnit.Joule);
- }
-
- ///
- /// Get Energy from KilobritishThermalUnits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromKilobritishThermalUnits(double kilobritishthermalunits)
-#else
- public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishthermalunits)
-#endif
- {
- double value = (double) kilobritishthermalunits;
- return new Energy(value, EnergyUnit.KilobritishThermalUnit);
- }
-
- ///
- /// Get Energy from Kilocalories.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromKilocalories(double kilocalories)
-#else
- public static Energy FromKilocalories(QuantityValue kilocalories)
-#endif
- {
- double value = (double) kilocalories;
- return new Energy(value, EnergyUnit.Kilocalorie);
- }
-
- ///
- /// Get Energy from Kilojoules.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromKilojoules(double kilojoules)
-#else
- public static Energy FromKilojoules(QuantityValue kilojoules)
-#endif
- {
- double value = (double) kilojoules;
- return new Energy(value, EnergyUnit.Kilojoule);
- }
-
- ///
- /// Get Energy from KilowattHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromKilowattHours(double kilowatthours)
-#else
- public static Energy FromKilowattHours(QuantityValue kilowatthours)
-#endif
- {
- double value = (double) kilowatthours;
- return new Energy(value, EnergyUnit.KilowattHour);
- }
-
- ///
- /// Get Energy from MegabritishThermalUnits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromMegabritishThermalUnits(double megabritishthermalunits)
-#else
- public static Energy FromMegabritishThermalUnits(QuantityValue megabritishthermalunits)
-#endif
- {
- double value = (double) megabritishthermalunits;
- return new Energy(value, EnergyUnit.MegabritishThermalUnit);
- }
-
- ///
- /// Get Energy from Megajoules.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromMegajoules(double megajoules)
-#else
- public static Energy FromMegajoules(QuantityValue megajoules)
-#endif
- {
- double value = (double) megajoules;
- return new Energy(value, EnergyUnit.Megajoule);
- }
-
- ///
- /// Get Energy from MegawattHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromMegawattHours(double megawatthours)
-#else
- public static Energy FromMegawattHours(QuantityValue megawatthours)
-#endif
- {
- double value = (double) megawatthours;
- return new Energy(value, EnergyUnit.MegawattHour);
- }
-
- ///
- /// Get Energy from ThermsEc.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromThermsEc(double thermsec)
-#else
- public static Energy FromThermsEc(QuantityValue thermsec)
-#endif
- {
- double value = (double) thermsec;
- return new Energy(value, EnergyUnit.ThermEc);
- }
-
- ///
- /// Get Energy from ThermsImperial.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromThermsImperial(double thermsimperial)
-#else
- public static Energy FromThermsImperial(QuantityValue thermsimperial)
-#endif
- {
- double value = (double) thermsimperial;
- return new Energy(value, EnergyUnit.ThermImperial);
- }
-
- ///
- /// Get Energy from ThermsUs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromThermsUs(double thermsus)
-#else
- public static Energy FromThermsUs(QuantityValue thermsus)
-#endif
- {
- double value = (double) thermsus;
- return new Energy(value, EnergyUnit.ThermUs);
- }
-
- ///
- /// Get Energy from WattHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Energy FromWattHours(double watthours)
-#else
- public static Energy FromWattHours(QuantityValue watthours)
-#endif
- {
- double value = (double) watthours;
- return new Energy(value, EnergyUnit.WattHour);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Energy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Energy From(double value, EnergyUnit fromUnit)
-#else
- public static Energy From(QuantityValue value, EnergyUnit fromUnit)
-#endif
- {
- return new Energy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(EnergyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Energy)) throw new ArgumentException("Expected type Energy.", nameof(obj));
-
- return CompareTo((Energy)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(Energy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Energy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Energy))
- return false;
-
- var objQuantity = (Energy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Energy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Energy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Energy 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.
- [Obsolete("Please use the Equals(Energy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Energy other, Energy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Energy.
- public override int GetHashCode()
- {
- return new { type = typeof(Energy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(EnergyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Energy to another Energy with the unit representation .
- ///
- /// A Energy with the specified unit.
- public Energy ToUnit(EnergyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Energy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case EnergyUnit.BritishThermalUnit: return _value*1055.05585262;
- case EnergyUnit.Calorie: return _value*4.184;
- case EnergyUnit.DecathermEc: return (_value*1.05505585262e8) * 1e1d;
- case EnergyUnit.DecathermImperial: return (_value*1.05505585257348e8) * 1e1d;
- case EnergyUnit.DecathermUs: return (_value*1.054804e8) * 1e1d;
- case EnergyUnit.ElectronVolt: return _value*1.602176565e-19;
- case EnergyUnit.Erg: return _value*1e-7;
- case EnergyUnit.FootPound: return _value*1.355817948;
- case EnergyUnit.GigabritishThermalUnit: return (_value*1055.05585262) * 1e9d;
- case EnergyUnit.GigawattHour: return (_value*3600d) * 1e9d;
- case EnergyUnit.Joule: return _value;
- case EnergyUnit.KilobritishThermalUnit: return (_value*1055.05585262) * 1e3d;
- case EnergyUnit.Kilocalorie: return (_value*4.184) * 1e3d;
- case EnergyUnit.Kilojoule: return (_value) * 1e3d;
- case EnergyUnit.KilowattHour: return (_value*3600d) * 1e3d;
- case EnergyUnit.MegabritishThermalUnit: return (_value*1055.05585262) * 1e6d;
- case EnergyUnit.Megajoule: return (_value) * 1e6d;
- case EnergyUnit.MegawattHour: return (_value*3600d) * 1e6d;
- case EnergyUnit.ThermEc: return _value*1.05505585262e8;
- case EnergyUnit.ThermImperial: return _value*1.05505585257348e8;
- case EnergyUnit.ThermUs: return _value*1.054804e8;
- case EnergyUnit.WattHour: return _value*3600d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(EnergyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case EnergyUnit.BritishThermalUnit: return baseUnitValue/1055.05585262;
- case EnergyUnit.Calorie: return baseUnitValue/4.184;
- case EnergyUnit.DecathermEc: return (baseUnitValue/1.05505585262e8) / 1e1d;
- case EnergyUnit.DecathermImperial: return (baseUnitValue/1.05505585257348e8) / 1e1d;
- case EnergyUnit.DecathermUs: return (baseUnitValue/1.054804e8) / 1e1d;
- case EnergyUnit.ElectronVolt: return baseUnitValue/1.602176565e-19;
- case EnergyUnit.Erg: return baseUnitValue/1e-7;
- case EnergyUnit.FootPound: return baseUnitValue/1.355817948;
- case EnergyUnit.GigabritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e9d;
- case EnergyUnit.GigawattHour: return (baseUnitValue/3600d) / 1e9d;
- case EnergyUnit.Joule: return baseUnitValue;
- case EnergyUnit.KilobritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e3d;
- case EnergyUnit.Kilocalorie: return (baseUnitValue/4.184) / 1e3d;
- case EnergyUnit.Kilojoule: return (baseUnitValue) / 1e3d;
- case EnergyUnit.KilowattHour: return (baseUnitValue/3600d) / 1e3d;
- case EnergyUnit.MegabritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e6d;
- case EnergyUnit.Megajoule: return (baseUnitValue) / 1e6d;
- case EnergyUnit.MegawattHour: return (baseUnitValue/3600d) / 1e6d;
- case EnergyUnit.ThermEc: return baseUnitValue/1.05505585262e8;
- case EnergyUnit.ThermImperial: return baseUnitValue/1.05505585257348e8;
- case EnergyUnit.ThermUs: return baseUnitValue/1.054804e8;
- case EnergyUnit.WattHour: return baseUnitValue/3600d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Energy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Energy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static EnergyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Joule
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static EnergyUnit ToStringDefaultUnit { get; set; } = EnergyUnit.Joule;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(EnergyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Energy
- ///
- public static Energy MaxValue => new Energy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Energy
- ///
- public static Energy MinValue => new Energy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Energy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Energy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Entropy.Common.g.cs b/Common/GeneratedCode/Quantities/Entropy.Common.g.cs
deleted file mode 100644
index 8917943faa..0000000000
--- a/Common/GeneratedCode/Quantities/Entropy.Common.g.cs
+++ /dev/null
@@ -1,616 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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
- ///
- // 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 Entropy : IQuantity
-#else
- public partial struct Entropy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly EntropyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public EntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Entropy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Entropy(double joulesperkelvin)
- {
- _value = Convert.ToDouble(joulesperkelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Entropy(double numericValue, EntropyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKelvin.
- ///
- /// Value assuming base unit JoulePerKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Entropy(long joulesperkelvin) : this(Convert.ToDouble(joulesperkelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKelvin.
- ///
- /// Value assuming base unit JoulePerKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Entropy(decimal joulesperkelvin) : this(Convert.ToDouble(joulesperkelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Entropy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static EntropyUnit BaseUnit => EntropyUnit.JoulePerKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Entropy quantity.
- ///
- public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().Except(new EntropyUnit[]{ EntropyUnit.Undefined }).ToArray();
-
- ///
- /// Get Entropy in CaloriesPerKelvin.
- ///
- public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin);
-
- ///
- /// Get Entropy in JoulesPerDegreeCelsius.
- ///
- public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius);
-
- ///
- /// Get Entropy in JoulesPerKelvin.
- ///
- public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin);
-
- ///
- /// Get Entropy in KilocaloriesPerKelvin.
- ///
- public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin);
-
- ///
- /// Get Entropy in KilojoulesPerDegreeCelsius.
- ///
- public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius);
-
- ///
- /// Get Entropy in KilojoulesPerKelvin.
- ///
- public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin);
-
- ///
- /// Get Entropy in MegajoulesPerKelvin.
- ///
- public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKelvin.
- ///
- public static Entropy Zero => new Entropy(0, BaseUnit);
-
- ///
- /// Get Entropy from CaloriesPerKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromCaloriesPerKelvin(double caloriesperkelvin)
-#else
- public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin)
-#endif
- {
- double value = (double) caloriesperkelvin;
- return new Entropy(value, EntropyUnit.CaloriePerKelvin);
- }
-
- ///
- /// Get Entropy from JoulesPerDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromJoulesPerDegreeCelsius(double joulesperdegreecelsius)
-#else
- public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreecelsius)
-#endif
- {
- double value = (double) joulesperdegreecelsius;
- return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius);
- }
-
- ///
- /// Get Entropy from JoulesPerKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromJoulesPerKelvin(double joulesperkelvin)
-#else
- public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin)
-#endif
- {
- double value = (double) joulesperkelvin;
- return new Entropy(value, EntropyUnit.JoulePerKelvin);
- }
-
- ///
- /// Get Entropy from KilocaloriesPerKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromKilocaloriesPerKelvin(double kilocaloriesperkelvin)
-#else
- public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkelvin)
-#endif
- {
- double value = (double) kilocaloriesperkelvin;
- return new Entropy(value, EntropyUnit.KilocaloriePerKelvin);
- }
-
- ///
- /// Get Entropy from KilojoulesPerDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromKilojoulesPerDegreeCelsius(double kilojoulesperdegreecelsius)
-#else
- public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesperdegreecelsius)
-#endif
- {
- double value = (double) kilojoulesperdegreecelsius;
- return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius);
- }
-
- ///
- /// Get Entropy from KilojoulesPerKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromKilojoulesPerKelvin(double kilojoulesperkelvin)
-#else
- public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin)
-#endif
- {
- double value = (double) kilojoulesperkelvin;
- return new Entropy(value, EntropyUnit.KilojoulePerKelvin);
- }
-
- ///
- /// Get Entropy from MegajoulesPerKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Entropy FromMegajoulesPerKelvin(double megajoulesperkelvin)
-#else
- public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin)
-#endif
- {
- double value = (double) megajoulesperkelvin;
- return new Entropy(value, EntropyUnit.MegajoulePerKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Entropy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Entropy From(double value, EntropyUnit fromUnit)
-#else
- public static Entropy From(QuantityValue value, EntropyUnit fromUnit)
-#endif
- {
- return new Entropy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(EntropyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Entropy)) throw new ArgumentException("Expected type Entropy.", nameof(obj));
-
- return CompareTo((Entropy)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(Entropy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Entropy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Entropy))
- return false;
-
- var objQuantity = (Entropy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Entropy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Entropy 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.
- [Obsolete("Please use the Equals(Entropy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Entropy other, Entropy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Entropy.
- public override int GetHashCode()
- {
- return new { type = typeof(Entropy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(EntropyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Entropy to another Entropy with the unit representation .
- ///
- /// A Entropy with the specified unit.
- public Entropy ToUnit(EntropyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Entropy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case EntropyUnit.CaloriePerKelvin: return _value*4.184;
- case EntropyUnit.JoulePerDegreeCelsius: return _value;
- case EntropyUnit.JoulePerKelvin: return _value;
- case EntropyUnit.KilocaloriePerKelvin: return (_value*4.184) * 1e3d;
- case EntropyUnit.KilojoulePerDegreeCelsius: return (_value) * 1e3d;
- case EntropyUnit.KilojoulePerKelvin: return (_value) * 1e3d;
- case EntropyUnit.MegajoulePerKelvin: return (_value) * 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(EntropyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case EntropyUnit.CaloriePerKelvin: return baseUnitValue/4.184;
- case EntropyUnit.JoulePerDegreeCelsius: return baseUnitValue;
- case EntropyUnit.JoulePerKelvin: return baseUnitValue;
- case EntropyUnit.KilocaloriePerKelvin: return (baseUnitValue/4.184) / 1e3d;
- case EntropyUnit.KilojoulePerDegreeCelsius: return (baseUnitValue) / 1e3d;
- case EntropyUnit.KilojoulePerKelvin: return (baseUnitValue) / 1e3d;
- case EntropyUnit.MegajoulePerKelvin: return (baseUnitValue) / 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Entropy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Entropy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static EntropyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static EntropyUnit ToStringDefaultUnit { get; set; } = EntropyUnit.JoulePerKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(EntropyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Entropy
- ///
- public static Entropy MaxValue => new Entropy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Entropy
- ///
- public static Entropy MinValue => new Entropy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Entropy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Entropy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Flow.Common.g.cs b/Common/GeneratedCode/Quantities/Flow.Common.g.cs
deleted file mode 100644
index c09adf53bc..0000000000
--- a/Common/GeneratedCode/Quantities/Flow.Common.g.cs
+++ /dev/null
@@ -1,1010 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.
- ///
- // ReSharper disable once PartialTypeWithSinglePart
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-
- // 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 Flow : IQuantity
-#else
- public partial struct Flow : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly FlowUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public FlowUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Flow()
- {
- BaseDimensions = new BaseDimensions(3, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit CubicMeterPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Flow(double cubicmeterspersecond)
- {
- _value = Convert.ToDouble(cubicmeterspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Flow(double numericValue, FlowUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerSecond.
- ///
- /// Value assuming base unit CubicMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Flow(long cubicmeterspersecond) : this(Convert.ToDouble(cubicmeterspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerSecond.
- ///
- /// Value assuming base unit CubicMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Flow(decimal cubicmeterspersecond) : this(Convert.ToDouble(cubicmeterspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Flow;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static FlowUnit BaseUnit => FlowUnit.CubicMeterPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Flow quantity.
- ///
- public static FlowUnit[] Units { get; } = Enum.GetValues(typeof(FlowUnit)).Cast().Except(new FlowUnit[]{ FlowUnit.Undefined }).ToArray();
-
- ///
- /// Get Flow in CentilitersPerMinute.
- ///
- public double CentilitersPerMinute => As(FlowUnit.CentilitersPerMinute);
-
- ///
- /// Get Flow in CubicDecimetersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicDecimetersPerMinute => As(FlowUnit.CubicDecimeterPerMinute);
-
- ///
- /// Get Flow in CubicFeetPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicFeetPerHour => As(FlowUnit.CubicFootPerHour);
-
- ///
- /// Get Flow in CubicFeetPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicFeetPerMinute => As(FlowUnit.CubicFootPerMinute);
-
- ///
- /// Get Flow in CubicFeetPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicFeetPerSecond => As(FlowUnit.CubicFootPerSecond);
-
- ///
- /// Get Flow in CubicMetersPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicMetersPerHour => As(FlowUnit.CubicMeterPerHour);
-
- ///
- /// Get Flow in CubicMetersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicMetersPerMinute => As(FlowUnit.CubicMeterPerMinute);
-
- ///
- /// Get Flow in CubicMetersPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicMetersPerSecond => As(FlowUnit.CubicMeterPerSecond);
-
- ///
- /// Get Flow in CubicYardsPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicYardsPerHour => As(FlowUnit.CubicYardPerHour);
-
- ///
- /// Get Flow in CubicYardsPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicYardsPerMinute => As(FlowUnit.CubicYardPerMinute);
-
- ///
- /// Get Flow in CubicYardsPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double CubicYardsPerSecond => As(FlowUnit.CubicYardPerSecond);
-
- ///
- /// Get Flow in DecilitersPerMinute.
- ///
- public double DecilitersPerMinute => As(FlowUnit.DecilitersPerMinute);
-
- ///
- /// Get Flow in KilolitersPerMinute.
- ///
- public double KilolitersPerMinute => As(FlowUnit.KilolitersPerMinute);
-
- ///
- /// Get Flow in LitersPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double LitersPerHour => As(FlowUnit.LitersPerHour);
-
- ///
- /// Get Flow in LitersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double LitersPerMinute => As(FlowUnit.LitersPerMinute);
-
- ///
- /// Get Flow in LitersPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double LitersPerSecond => As(FlowUnit.LitersPerSecond);
-
- ///
- /// Get Flow in MicrolitersPerMinute.
- ///
- public double MicrolitersPerMinute => As(FlowUnit.MicrolitersPerMinute);
-
- ///
- /// Get Flow in MillilitersPerMinute.
- ///
- public double MillilitersPerMinute => As(FlowUnit.MillilitersPerMinute);
-
- ///
- /// Get Flow in MillionUsGallonsPerDay.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double MillionUsGallonsPerDay => As(FlowUnit.MillionUsGallonsPerDay);
-
- ///
- /// Get Flow in NanolitersPerMinute.
- ///
- public double NanolitersPerMinute => As(FlowUnit.NanolitersPerMinute);
-
- ///
- /// Get Flow in OilBarrelsPerDay.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double OilBarrelsPerDay => As(FlowUnit.OilBarrelsPerDay);
-
- ///
- /// Get Flow in UsGallonsPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double UsGallonsPerHour => As(FlowUnit.UsGallonsPerHour);
-
- ///
- /// Get Flow in UsGallonsPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double UsGallonsPerMinute => As(FlowUnit.UsGallonsPerMinute);
-
- ///
- /// Get Flow in UsGallonsPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
- public double UsGallonsPerSecond => As(FlowUnit.UsGallonsPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond.
- ///
- public static Flow Zero => new Flow(0, BaseUnit);
-
- ///
- /// Get Flow from CentilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCentilitersPerMinute(double centilitersperminute)
-#else
- public static Flow FromCentilitersPerMinute(QuantityValue centilitersperminute)
-#endif
- {
- double value = (double) centilitersperminute;
- return new Flow(value, FlowUnit.CentilitersPerMinute);
- }
-
- ///
- /// Get Flow from CubicDecimetersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicDecimetersPerMinute(double cubicdecimetersperminute)
-#else
- public static Flow FromCubicDecimetersPerMinute(QuantityValue cubicdecimetersperminute)
-#endif
- {
- double value = (double) cubicdecimetersperminute;
- return new Flow(value, FlowUnit.CubicDecimeterPerMinute);
- }
-
- ///
- /// Get Flow from CubicFeetPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicFeetPerHour(double cubicfeetperhour)
-#else
- public static Flow FromCubicFeetPerHour(QuantityValue cubicfeetperhour)
-#endif
- {
- double value = (double) cubicfeetperhour;
- return new Flow(value, FlowUnit.CubicFootPerHour);
- }
-
- ///
- /// Get Flow from CubicFeetPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicFeetPerMinute(double cubicfeetperminute)
-#else
- public static Flow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute)
-#endif
- {
- double value = (double) cubicfeetperminute;
- return new Flow(value, FlowUnit.CubicFootPerMinute);
- }
-
- ///
- /// Get Flow from CubicFeetPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicFeetPerSecond(double cubicfeetpersecond)
-#else
- public static Flow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond)
-#endif
- {
- double value = (double) cubicfeetpersecond;
- return new Flow(value, FlowUnit.CubicFootPerSecond);
- }
-
- ///
- /// Get Flow from CubicMetersPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicMetersPerHour(double cubicmetersperhour)
-#else
- public static Flow FromCubicMetersPerHour(QuantityValue cubicmetersperhour)
-#endif
- {
- double value = (double) cubicmetersperhour;
- return new Flow(value, FlowUnit.CubicMeterPerHour);
- }
-
- ///
- /// Get Flow from CubicMetersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicMetersPerMinute(double cubicmetersperminute)
-#else
- public static Flow FromCubicMetersPerMinute(QuantityValue cubicmetersperminute)
-#endif
- {
- double value = (double) cubicmetersperminute;
- return new Flow(value, FlowUnit.CubicMeterPerMinute);
- }
-
- ///
- /// Get Flow from CubicMetersPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicMetersPerSecond(double cubicmeterspersecond)
-#else
- public static Flow FromCubicMetersPerSecond(QuantityValue cubicmeterspersecond)
-#endif
- {
- double value = (double) cubicmeterspersecond;
- return new Flow(value, FlowUnit.CubicMeterPerSecond);
- }
-
- ///
- /// Get Flow from CubicYardsPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicYardsPerHour(double cubicyardsperhour)
-#else
- public static Flow FromCubicYardsPerHour(QuantityValue cubicyardsperhour)
-#endif
- {
- double value = (double) cubicyardsperhour;
- return new Flow(value, FlowUnit.CubicYardPerHour);
- }
-
- ///
- /// Get Flow from CubicYardsPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicYardsPerMinute(double cubicyardsperminute)
-#else
- public static Flow FromCubicYardsPerMinute(QuantityValue cubicyardsperminute)
-#endif
- {
- double value = (double) cubicyardsperminute;
- return new Flow(value, FlowUnit.CubicYardPerMinute);
- }
-
- ///
- /// Get Flow from CubicYardsPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromCubicYardsPerSecond(double cubicyardspersecond)
-#else
- public static Flow FromCubicYardsPerSecond(QuantityValue cubicyardspersecond)
-#endif
- {
- double value = (double) cubicyardspersecond;
- return new Flow(value, FlowUnit.CubicYardPerSecond);
- }
-
- ///
- /// Get Flow from DecilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromDecilitersPerMinute(double decilitersperminute)
-#else
- public static Flow FromDecilitersPerMinute(QuantityValue decilitersperminute)
-#endif
- {
- double value = (double) decilitersperminute;
- return new Flow(value, FlowUnit.DecilitersPerMinute);
- }
-
- ///
- /// Get Flow from KilolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromKilolitersPerMinute(double kilolitersperminute)
-#else
- public static Flow FromKilolitersPerMinute(QuantityValue kilolitersperminute)
-#endif
- {
- double value = (double) kilolitersperminute;
- return new Flow(value, FlowUnit.KilolitersPerMinute);
- }
-
- ///
- /// Get Flow from LitersPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromLitersPerHour(double litersperhour)
-#else
- public static Flow FromLitersPerHour(QuantityValue litersperhour)
-#endif
- {
- double value = (double) litersperhour;
- return new Flow(value, FlowUnit.LitersPerHour);
- }
-
- ///
- /// Get Flow from LitersPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromLitersPerMinute(double litersperminute)
-#else
- public static Flow FromLitersPerMinute(QuantityValue litersperminute)
-#endif
- {
- double value = (double) litersperminute;
- return new Flow(value, FlowUnit.LitersPerMinute);
- }
-
- ///
- /// Get Flow from LitersPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromLitersPerSecond(double literspersecond)
-#else
- public static Flow FromLitersPerSecond(QuantityValue literspersecond)
-#endif
- {
- double value = (double) literspersecond;
- return new Flow(value, FlowUnit.LitersPerSecond);
- }
-
- ///
- /// Get Flow from MicrolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromMicrolitersPerMinute(double microlitersperminute)
-#else
- public static Flow FromMicrolitersPerMinute(QuantityValue microlitersperminute)
-#endif
- {
- double value = (double) microlitersperminute;
- return new Flow(value, FlowUnit.MicrolitersPerMinute);
- }
-
- ///
- /// Get Flow from MillilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromMillilitersPerMinute(double millilitersperminute)
-#else
- public static Flow FromMillilitersPerMinute(QuantityValue millilitersperminute)
-#endif
- {
- double value = (double) millilitersperminute;
- return new Flow(value, FlowUnit.MillilitersPerMinute);
- }
-
- ///
- /// Get Flow from MillionUsGallonsPerDay.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromMillionUsGallonsPerDay(double millionusgallonsperday)
-#else
- public static Flow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday)
-#endif
- {
- double value = (double) millionusgallonsperday;
- return new Flow(value, FlowUnit.MillionUsGallonsPerDay);
- }
-
- ///
- /// Get Flow from NanolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromNanolitersPerMinute(double nanolitersperminute)
-#else
- public static Flow FromNanolitersPerMinute(QuantityValue nanolitersperminute)
-#endif
- {
- double value = (double) nanolitersperminute;
- return new Flow(value, FlowUnit.NanolitersPerMinute);
- }
-
- ///
- /// Get Flow from OilBarrelsPerDay.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromOilBarrelsPerDay(double oilbarrelsperday)
-#else
- public static Flow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday)
-#endif
- {
- double value = (double) oilbarrelsperday;
- return new Flow(value, FlowUnit.OilBarrelsPerDay);
- }
-
- ///
- /// Get Flow from UsGallonsPerHour.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromUsGallonsPerHour(double usgallonsperhour)
-#else
- public static Flow FromUsGallonsPerHour(QuantityValue usgallonsperhour)
-#endif
- {
- double value = (double) usgallonsperhour;
- return new Flow(value, FlowUnit.UsGallonsPerHour);
- }
-
- ///
- /// Get Flow from UsGallonsPerMinute.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromUsGallonsPerMinute(double usgallonsperminute)
-#else
- public static Flow FromUsGallonsPerMinute(QuantityValue usgallonsperminute)
-#endif
- {
- double value = (double) usgallonsperminute;
- return new Flow(value, FlowUnit.UsGallonsPerMinute);
- }
-
- ///
- /// Get Flow from UsGallonsPerSecond.
- ///
- [System.Obsolete("Deprecated due to github issue #363, please use VolumeFlow instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Flow FromUsGallonsPerSecond(double usgallonspersecond)
-#else
- public static Flow FromUsGallonsPerSecond(QuantityValue usgallonspersecond)
-#endif
- {
- double value = (double) usgallonspersecond;
- return new Flow(value, FlowUnit.UsGallonsPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Flow unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Flow From(double value, FlowUnit fromUnit)
-#else
- public static Flow From(QuantityValue value, FlowUnit fromUnit)
-#endif
- {
- return new Flow((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(FlowUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Flow)) throw new ArgumentException("Expected type Flow.", nameof(obj));
-
- return CompareTo((Flow)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(Flow other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Flow, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Flow))
- return false;
-
- var objQuantity = (Flow)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Flow within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Flow other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Flow 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.
- [Obsolete("Please use the Equals(Flow, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Flow other, Flow maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Flow.
- public override int GetHashCode()
- {
- return new { type = typeof(Flow), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(FlowUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Flow to another Flow with the unit representation .
- ///
- /// A Flow with the specified unit.
- public Flow ToUnit(FlowUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Flow(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case FlowUnit.CentilitersPerMinute: return (_value/60000.00000) * 1e-2d;
- case FlowUnit.CubicDecimeterPerMinute: return _value/60000.00000;
- case FlowUnit.CubicFootPerHour: return _value*7.8657907199999087346816086183876e-6;
- case FlowUnit.CubicFootPerMinute: return _value/2118.88000326;
- case FlowUnit.CubicFootPerSecond: return _value/35.314666721;
- case FlowUnit.CubicMeterPerHour: return _value/3600;
- case FlowUnit.CubicMeterPerMinute: return _value/60;
- case FlowUnit.CubicMeterPerSecond: return _value;
- case FlowUnit.CubicYardPerHour: return _value*2.1237634944E-4;
- case FlowUnit.CubicYardPerMinute: return _value*0.0127425809664;
- case FlowUnit.CubicYardPerSecond: return _value*0.764554857984;
- case FlowUnit.DecilitersPerMinute: return (_value/60000.00000) * 1e-1d;
- case FlowUnit.KilolitersPerMinute: return (_value/60000.00000) * 1e3d;
- case FlowUnit.LitersPerHour: return _value/3600000.000;
- case FlowUnit.LitersPerMinute: return _value/60000.00000;
- case FlowUnit.LitersPerSecond: return _value/1000;
- case FlowUnit.MicrolitersPerMinute: return (_value/60000.00000) * 1e-6d;
- case FlowUnit.MillilitersPerMinute: return (_value/60000.00000) * 1e-3d;
- case FlowUnit.MillionUsGallonsPerDay: return _value/22.824465227;
- case FlowUnit.NanolitersPerMinute: return (_value/60000.00000) * 1e-9d;
- case FlowUnit.OilBarrelsPerDay: return _value*1.8401307283333333333333333333333e-6;
- case FlowUnit.UsGallonsPerHour: return _value/951019.38848933424;
- case FlowUnit.UsGallonsPerMinute: return _value/15850.323141489;
- case FlowUnit.UsGallonsPerSecond: return _value/264.1720523581484;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(FlowUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case FlowUnit.CentilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-2d;
- case FlowUnit.CubicDecimeterPerMinute: return baseUnitValue*60000.00000;
- case FlowUnit.CubicFootPerHour: return baseUnitValue/7.8657907199999087346816086183876e-6;
- case FlowUnit.CubicFootPerMinute: return baseUnitValue*2118.88000326;
- case FlowUnit.CubicFootPerSecond: return baseUnitValue*35.314666721;
- case FlowUnit.CubicMeterPerHour: return baseUnitValue*3600;
- case FlowUnit.CubicMeterPerMinute: return baseUnitValue*60;
- case FlowUnit.CubicMeterPerSecond: return baseUnitValue;
- case FlowUnit.CubicYardPerHour: return baseUnitValue/2.1237634944E-4;
- case FlowUnit.CubicYardPerMinute: return baseUnitValue/0.0127425809664;
- case FlowUnit.CubicYardPerSecond: return baseUnitValue/0.764554857984;
- case FlowUnit.DecilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-1d;
- case FlowUnit.KilolitersPerMinute: return (baseUnitValue*60000.00000) / 1e3d;
- case FlowUnit.LitersPerHour: return baseUnitValue*3600000.000;
- case FlowUnit.LitersPerMinute: return baseUnitValue*60000.00000;
- case FlowUnit.LitersPerSecond: return baseUnitValue*1000;
- case FlowUnit.MicrolitersPerMinute: return (baseUnitValue*60000.00000) / 1e-6d;
- case FlowUnit.MillilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-3d;
- case FlowUnit.MillionUsGallonsPerDay: return baseUnitValue*22.824465227;
- case FlowUnit.NanolitersPerMinute: return (baseUnitValue*60000.00000) / 1e-9d;
- case FlowUnit.OilBarrelsPerDay: return baseUnitValue/1.8401307283333333333333333333333e-6;
- case FlowUnit.UsGallonsPerHour: return baseUnitValue*951019.38848933424;
- case FlowUnit.UsGallonsPerMinute: return baseUnitValue*15850.323141489;
- case FlowUnit.UsGallonsPerSecond: return baseUnitValue*264.1720523581484;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Flow Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Flow result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static FlowUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is CubicMeterPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static FlowUnit ToStringDefaultUnit { get; set; } = FlowUnit.CubicMeterPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(FlowUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Flow
- ///
- public static Flow MaxValue => new Flow(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Flow
- ///
- public static Flow MinValue => new Flow(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Flow.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Flow.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Force.Common.g.cs b/Common/GeneratedCode/Quantities/Force.Common.g.cs
deleted file mode 100644
index 76c1e98ce2..0000000000
--- a/Common/GeneratedCode/Quantities/Force.Common.g.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Force : IQuantity
-#else
- public partial struct Force : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ForceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ForceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Force()
- {
- BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Newton.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Force(double newtons)
- {
- _value = Convert.ToDouble(newtons);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Force(double numericValue, ForceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Newton.
- ///
- /// Value assuming base unit Newton.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Force(long newtons) : this(Convert.ToDouble(newtons), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Newton.
- ///
- /// Value assuming base unit Newton.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Force(decimal newtons) : this(Convert.ToDouble(newtons), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Force;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ForceUnit BaseUnit => ForceUnit.Newton;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Force quantity.
- ///
- public static ForceUnit[] Units { get; } = Enum.GetValues(typeof(ForceUnit)).Cast().Except(new ForceUnit[]{ ForceUnit.Undefined }).ToArray();
-
- ///
- /// Get Force in Decanewtons.
- ///
- public double Decanewtons => As(ForceUnit.Decanewton);
-
- ///
- /// Get Force in Dyne.
- ///
- public double Dyne => As(ForceUnit.Dyn);
-
- ///
- /// Get Force in KilogramsForce.
- ///
- public double KilogramsForce => As(ForceUnit.KilogramForce);
-
- ///
- /// Get Force in Kilonewtons.
- ///
- public double Kilonewtons => As(ForceUnit.Kilonewton);
-
- ///
- /// Get Force in KiloPonds.
- ///
- public double KiloPonds => As(ForceUnit.KiloPond);
-
- ///
- /// Get Force in Meganewtons.
- ///
- public double Meganewtons => As(ForceUnit.Meganewton);
-
- ///
- /// Get Force in Micronewtons.
- ///
- public double Micronewtons => As(ForceUnit.Micronewton);
-
- ///
- /// Get Force in Millinewtons.
- ///
- public double Millinewtons => As(ForceUnit.Millinewton);
-
- ///
- /// Get Force in Newtons.
- ///
- public double Newtons => As(ForceUnit.Newton);
-
- ///
- /// Get Force in OunceForce.
- ///
- public double OunceForce => As(ForceUnit.OunceForce);
-
- ///
- /// Get Force in Poundals.
- ///
- public double Poundals => As(ForceUnit.Poundal);
-
- ///
- /// Get Force in PoundsForce.
- ///
- public double PoundsForce => As(ForceUnit.PoundForce);
-
- ///
- /// Get Force in TonnesForce.
- ///
- public double TonnesForce => As(ForceUnit.TonneForce);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Newton.
- ///
- public static Force Zero => new Force(0, BaseUnit);
-
- ///
- /// Get Force from Decanewtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromDecanewtons(double decanewtons)
-#else
- public static Force FromDecanewtons(QuantityValue decanewtons)
-#endif
- {
- double value = (double) decanewtons;
- return new Force(value, ForceUnit.Decanewton);
- }
-
- ///
- /// Get Force from Dyne.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromDyne(double dyne)
-#else
- public static Force FromDyne(QuantityValue dyne)
-#endif
- {
- double value = (double) dyne;
- return new Force(value, ForceUnit.Dyn);
- }
-
- ///
- /// Get Force from KilogramsForce.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromKilogramsForce(double kilogramsforce)
-#else
- public static Force FromKilogramsForce(QuantityValue kilogramsforce)
-#endif
- {
- double value = (double) kilogramsforce;
- return new Force(value, ForceUnit.KilogramForce);
- }
-
- ///
- /// Get Force from Kilonewtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromKilonewtons(double kilonewtons)
-#else
- public static Force FromKilonewtons(QuantityValue kilonewtons)
-#endif
- {
- double value = (double) kilonewtons;
- return new Force(value, ForceUnit.Kilonewton);
- }
-
- ///
- /// Get Force from KiloPonds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromKiloPonds(double kiloponds)
-#else
- public static Force FromKiloPonds(QuantityValue kiloponds)
-#endif
- {
- double value = (double) kiloponds;
- return new Force(value, ForceUnit.KiloPond);
- }
-
- ///
- /// Get Force from Meganewtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromMeganewtons(double meganewtons)
-#else
- public static Force FromMeganewtons(QuantityValue meganewtons)
-#endif
- {
- double value = (double) meganewtons;
- return new Force(value, ForceUnit.Meganewton);
- }
-
- ///
- /// Get Force from Micronewtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromMicronewtons(double micronewtons)
-#else
- public static Force FromMicronewtons(QuantityValue micronewtons)
-#endif
- {
- double value = (double) micronewtons;
- return new Force(value, ForceUnit.Micronewton);
- }
-
- ///
- /// Get Force from Millinewtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromMillinewtons(double millinewtons)
-#else
- public static Force FromMillinewtons(QuantityValue millinewtons)
-#endif
- {
- double value = (double) millinewtons;
- return new Force(value, ForceUnit.Millinewton);
- }
-
- ///
- /// Get Force from Newtons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromNewtons(double newtons)
-#else
- public static Force FromNewtons(QuantityValue newtons)
-#endif
- {
- double value = (double) newtons;
- return new Force(value, ForceUnit.Newton);
- }
-
- ///
- /// Get Force from OunceForce.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromOunceForce(double ounceforce)
-#else
- public static Force FromOunceForce(QuantityValue ounceforce)
-#endif
- {
- double value = (double) ounceforce;
- return new Force(value, ForceUnit.OunceForce);
- }
-
- ///
- /// Get Force from Poundals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromPoundals(double poundals)
-#else
- public static Force FromPoundals(QuantityValue poundals)
-#endif
- {
- double value = (double) poundals;
- return new Force(value, ForceUnit.Poundal);
- }
-
- ///
- /// Get Force from PoundsForce.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromPoundsForce(double poundsforce)
-#else
- public static Force FromPoundsForce(QuantityValue poundsforce)
-#endif
- {
- double value = (double) poundsforce;
- return new Force(value, ForceUnit.PoundForce);
- }
-
- ///
- /// Get Force from TonnesForce.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Force FromTonnesForce(double tonnesforce)
-#else
- public static Force FromTonnesForce(QuantityValue tonnesforce)
-#endif
- {
- double value = (double) tonnesforce;
- return new Force(value, ForceUnit.TonneForce);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Force unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Force From(double value, ForceUnit fromUnit)
-#else
- public static Force From(QuantityValue value, ForceUnit fromUnit)
-#endif
- {
- return new Force((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ForceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Force)) throw new ArgumentException("Expected type Force.", nameof(obj));
-
- return CompareTo((Force)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(Force other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Force, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Force))
- return false;
-
- var objQuantity = (Force)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Force within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Force other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Force 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.
- [Obsolete("Please use the Equals(Force, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Force other, Force maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Force.
- public override int GetHashCode()
- {
- return new { type = typeof(Force), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ForceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Force to another Force with the unit representation .
- ///
- /// A Force with the specified unit.
- public Force ToUnit(ForceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Force(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ForceUnit.Decanewton: return (_value) * 1e1d;
- case ForceUnit.Dyn: return _value/1e5;
- case ForceUnit.KilogramForce: return _value*9.80665002864;
- case ForceUnit.Kilonewton: return (_value) * 1e3d;
- case ForceUnit.KiloPond: return _value*9.80665002864;
- case ForceUnit.Meganewton: return (_value) * 1e6d;
- case ForceUnit.Micronewton: return (_value) * 1e-6d;
- case ForceUnit.Millinewton: return (_value) * 1e-3d;
- case ForceUnit.Newton: return _value;
- case ForceUnit.OunceForce: return _value*2.780138509537812e-1;
- case ForceUnit.Poundal: return _value*0.13825502798973041652092282466083;
- case ForceUnit.PoundForce: return _value*4.4482216152605095551842641431421;
- case ForceUnit.TonneForce: return _value*9.80665002864e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ForceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ForceUnit.Decanewton: return (baseUnitValue) / 1e1d;
- case ForceUnit.Dyn: return baseUnitValue*1e5;
- case ForceUnit.KilogramForce: return baseUnitValue/9.80665002864;
- case ForceUnit.Kilonewton: return (baseUnitValue) / 1e3d;
- case ForceUnit.KiloPond: return baseUnitValue/9.80665002864;
- case ForceUnit.Meganewton: return (baseUnitValue) / 1e6d;
- case ForceUnit.Micronewton: return (baseUnitValue) / 1e-6d;
- case ForceUnit.Millinewton: return (baseUnitValue) / 1e-3d;
- case ForceUnit.Newton: return baseUnitValue;
- case ForceUnit.OunceForce: return baseUnitValue/2.780138509537812e-1;
- case ForceUnit.Poundal: return baseUnitValue/0.13825502798973041652092282466083;
- case ForceUnit.PoundForce: return baseUnitValue/4.4482216152605095551842641431421;
- case ForceUnit.TonneForce: return baseUnitValue/9.80665002864e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Force Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Force result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ForceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Newton
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ForceUnit ToStringDefaultUnit { get; set; } = ForceUnit.Newton;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ForceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Force
- ///
- public static Force MaxValue => new Force(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Force
- ///
- public static Force MinValue => new Force(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Force.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Force.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ForceChangeRate.Common.g.cs b/Common/GeneratedCode/Quantities/ForceChangeRate.Common.g.cs
deleted file mode 100644
index 8e774ffc2f..0000000000
--- a/Common/GeneratedCode/Quantities/ForceChangeRate.Common.g.cs
+++ /dev/null
@@ -1,700 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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).
- ///
- // 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 ForceChangeRate : IQuantity
-#else
- public partial struct ForceChangeRate : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ForceChangeRateUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ForceChangeRate()
- {
- BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ForceChangeRate(double newtonspersecond)
- {
- _value = Convert.ToDouble(newtonspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ForceChangeRate(double numericValue, ForceChangeRateUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerSecond.
- ///
- /// Value assuming base unit NewtonPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ForceChangeRate(long newtonspersecond) : this(Convert.ToDouble(newtonspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerSecond.
- ///
- /// Value assuming base unit NewtonPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ForceChangeRate(decimal newtonspersecond) : this(Convert.ToDouble(newtonspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ForceChangeRate;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ForceChangeRateUnit BaseUnit => ForceChangeRateUnit.NewtonPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ForceChangeRate quantity.
- ///
- public static ForceChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().Except(new ForceChangeRateUnit[]{ ForceChangeRateUnit.Undefined }).ToArray();
-
- ///
- /// Get ForceChangeRate in CentinewtonsPerSecond.
- ///
- public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in DecanewtonsPerMinute.
- ///
- public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute);
-
- ///
- /// Get ForceChangeRate in DecanewtonsPerSecond.
- ///
- public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in DecinewtonsPerSecond.
- ///
- public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in KilonewtonsPerMinute.
- ///
- public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute);
-
- ///
- /// Get ForceChangeRate in KilonewtonsPerSecond.
- ///
- public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in MicronewtonsPerSecond.
- ///
- public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in MillinewtonsPerSecond.
- ///
- public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in NanonewtonsPerSecond.
- ///
- public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond);
-
- ///
- /// Get ForceChangeRate in NewtonsPerMinute.
- ///
- public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute);
-
- ///
- /// Get ForceChangeRate in NewtonsPerSecond.
- ///
- public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerSecond.
- ///
- public static ForceChangeRate Zero => new ForceChangeRate(0, BaseUnit);
-
- ///
- /// Get ForceChangeRate from CentinewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromCentinewtonsPerSecond(double centinewtonspersecond)
-#else
- public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewtonspersecond)
-#endif
- {
- double value = (double) centinewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from DecanewtonsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromDecanewtonsPerMinute(double decanewtonsperminute)
-#else
- public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtonsperminute)
-#endif
- {
- double value = (double) decanewtonsperminute;
- return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute);
- }
-
- ///
- /// Get ForceChangeRate from DecanewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromDecanewtonsPerSecond(double decanewtonspersecond)
-#else
- public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtonspersecond)
-#endif
- {
- double value = (double) decanewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from DecinewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromDecinewtonsPerSecond(double decinewtonspersecond)
-#else
- public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtonspersecond)
-#endif
- {
- double value = (double) decinewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from KilonewtonsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromKilonewtonsPerMinute(double kilonewtonsperminute)
-#else
- public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtonsperminute)
-#endif
- {
- double value = (double) kilonewtonsperminute;
- return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute);
- }
-
- ///
- /// Get ForceChangeRate from KilonewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromKilonewtonsPerSecond(double kilonewtonspersecond)
-#else
- public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtonspersecond)
-#endif
- {
- double value = (double) kilonewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from MicronewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromMicronewtonsPerSecond(double micronewtonspersecond)
-#else
- public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewtonspersecond)
-#endif
- {
- double value = (double) micronewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from MillinewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromMillinewtonsPerSecond(double millinewtonspersecond)
-#else
- public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewtonspersecond)
-#endif
- {
- double value = (double) millinewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from NanonewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromNanonewtonsPerSecond(double nanonewtonspersecond)
-#else
- public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtonspersecond)
-#endif
- {
- double value = (double) nanonewtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond);
- }
-
- ///
- /// Get ForceChangeRate from NewtonsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromNewtonsPerMinute(double newtonsperminute)
-#else
- public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminute)
-#endif
- {
- double value = (double) newtonsperminute;
- return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute);
- }
-
- ///
- /// Get ForceChangeRate from NewtonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForceChangeRate FromNewtonsPerSecond(double newtonspersecond)
-#else
- public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecond)
-#endif
- {
- double value = (double) newtonspersecond;
- return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ForceChangeRate unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit)
-#else
- public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit)
-#endif
- {
- return new ForceChangeRate((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ForceChangeRateUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ForceChangeRate)) throw new ArgumentException("Expected type ForceChangeRate.", nameof(obj));
-
- return CompareTo((ForceChangeRate)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(ForceChangeRate other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ForceChangeRate, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ForceChangeRate))
- return false;
-
- var objQuantity = (ForceChangeRate)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ForceChangeRate 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.
- [Obsolete("Please use the Equals(ForceChangeRate, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ForceChangeRate other, ForceChangeRate maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ForceChangeRate.
- public override int GetHashCode()
- {
- return new { type = typeof(ForceChangeRate), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ForceChangeRateUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation .
- ///
- /// A ForceChangeRate with the specified unit.
- public ForceChangeRate ToUnit(ForceChangeRateUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ForceChangeRate(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ForceChangeRateUnit.CentinewtonPerSecond: return (_value) * 1e-2d;
- case ForceChangeRateUnit.DecanewtonPerMinute: return (_value/60) * 1e1d;
- case ForceChangeRateUnit.DecanewtonPerSecond: return (_value) * 1e1d;
- case ForceChangeRateUnit.DecinewtonPerSecond: return (_value) * 1e-1d;
- case ForceChangeRateUnit.KilonewtonPerMinute: return (_value/60) * 1e3d;
- case ForceChangeRateUnit.KilonewtonPerSecond: return (_value) * 1e3d;
- case ForceChangeRateUnit.MicronewtonPerSecond: return (_value) * 1e-6d;
- case ForceChangeRateUnit.MillinewtonPerSecond: return (_value) * 1e-3d;
- case ForceChangeRateUnit.NanonewtonPerSecond: return (_value) * 1e-9d;
- case ForceChangeRateUnit.NewtonPerMinute: return _value/60;
- case ForceChangeRateUnit.NewtonPerSecond: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ForceChangeRateUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ForceChangeRateUnit.CentinewtonPerSecond: return (baseUnitValue) / 1e-2d;
- case ForceChangeRateUnit.DecanewtonPerMinute: return (baseUnitValue*60) / 1e1d;
- case ForceChangeRateUnit.DecanewtonPerSecond: return (baseUnitValue) / 1e1d;
- case ForceChangeRateUnit.DecinewtonPerSecond: return (baseUnitValue) / 1e-1d;
- case ForceChangeRateUnit.KilonewtonPerMinute: return (baseUnitValue*60) / 1e3d;
- case ForceChangeRateUnit.KilonewtonPerSecond: return (baseUnitValue) / 1e3d;
- case ForceChangeRateUnit.MicronewtonPerSecond: return (baseUnitValue) / 1e-6d;
- case ForceChangeRateUnit.MillinewtonPerSecond: return (baseUnitValue) / 1e-3d;
- case ForceChangeRateUnit.NanonewtonPerSecond: return (baseUnitValue) / 1e-9d;
- case ForceChangeRateUnit.NewtonPerMinute: return baseUnitValue*60;
- case ForceChangeRateUnit.NewtonPerSecond: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ForceChangeRate Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ForceChangeRate result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ForceChangeRateUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ForceChangeRateUnit ToStringDefaultUnit { get; set; } = ForceChangeRateUnit.NewtonPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ForceChangeRateUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ForceChangeRate
- ///
- public static ForceChangeRate MaxValue => new ForceChangeRate(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ForceChangeRate
- ///
- public static ForceChangeRate MinValue => new ForceChangeRate(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ForceChangeRate.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ForceChangeRate.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ForcePerLength.Common.g.cs b/Common/GeneratedCode/Quantities/ForcePerLength.Common.g.cs
deleted file mode 100644
index 729665e35d..0000000000
--- a/Common/GeneratedCode/Quantities/ForcePerLength.Common.g.cs
+++ /dev/null
@@ -1,658 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The magnitude of force per unit length.
- ///
- // 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 ForcePerLength : IQuantity
-#else
- public partial struct ForcePerLength : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ForcePerLengthUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ForcePerLength()
- {
- BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ForcePerLength(double newtonspermeter)
- {
- _value = Convert.ToDouble(newtonspermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ForcePerLength(double numericValue, ForcePerLengthUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerMeter.
- ///
- /// Value assuming base unit NewtonPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ForcePerLength(long newtonspermeter) : this(Convert.ToDouble(newtonspermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerMeter.
- ///
- /// Value assuming base unit NewtonPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ForcePerLength(decimal newtonspermeter) : this(Convert.ToDouble(newtonspermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ForcePerLength;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ForcePerLengthUnit BaseUnit => ForcePerLengthUnit.NewtonPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ForcePerLength quantity.
- ///
- public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray();
-
- ///
- /// Get ForcePerLength in CentinewtonsPerMeter.
- ///
- public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter);
-
- ///
- /// Get ForcePerLength in DecinewtonsPerMeter.
- ///
- public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter);
-
- ///
- /// Get ForcePerLength in KilogramsForcePerMeter.
- ///
- public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter);
-
- ///
- /// Get ForcePerLength in KilonewtonsPerMeter.
- ///
- public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter);
-
- ///
- /// Get ForcePerLength in MeganewtonsPerMeter.
- ///
- public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter);
-
- ///
- /// Get ForcePerLength in MicronewtonsPerMeter.
- ///
- public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter);
-
- ///
- /// Get ForcePerLength in MillinewtonsPerMeter.
- ///
- public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter);
-
- ///
- /// Get ForcePerLength in NanonewtonsPerMeter.
- ///
- public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter);
-
- ///
- /// Get ForcePerLength in NewtonsPerMeter.
- ///
- public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter.
- ///
- public static ForcePerLength Zero => new ForcePerLength(0, BaseUnit);
-
- ///
- /// Get ForcePerLength from CentinewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromCentinewtonsPerMeter(double centinewtonspermeter)
-#else
- public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtonspermeter)
-#endif
- {
- double value = (double) centinewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from DecinewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromDecinewtonsPerMeter(double decinewtonspermeter)
-#else
- public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspermeter)
-#endif
- {
- double value = (double) decinewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from KilogramsForcePerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromKilogramsForcePerMeter(double kilogramsforcepermeter)
-#else
- public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsforcepermeter)
-#endif
- {
- double value = (double) kilogramsforcepermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter);
- }
-
- ///
- /// Get ForcePerLength from KilonewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromKilonewtonsPerMeter(double kilonewtonspermeter)
-#else
- public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspermeter)
-#endif
- {
- double value = (double) kilonewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from MeganewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromMeganewtonsPerMeter(double meganewtonspermeter)
-#else
- public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspermeter)
-#endif
- {
- double value = (double) meganewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from MicronewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromMicronewtonsPerMeter(double micronewtonspermeter)
-#else
- public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtonspermeter)
-#endif
- {
- double value = (double) micronewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from MillinewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromMillinewtonsPerMeter(double millinewtonspermeter)
-#else
- public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtonspermeter)
-#endif
- {
- double value = (double) millinewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from NanonewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromNanonewtonsPerMeter(double nanonewtonspermeter)
-#else
- public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspermeter)
-#endif
- {
- double value = (double) nanonewtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter);
- }
-
- ///
- /// Get ForcePerLength from NewtonsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ForcePerLength FromNewtonsPerMeter(double newtonspermeter)
-#else
- public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter)
-#endif
- {
- double value = (double) newtonspermeter;
- return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ForcePerLength unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit)
-#else
- public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUnit)
-#endif
- {
- return new ForcePerLength((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ForcePerLengthUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ForcePerLength)) throw new ArgumentException("Expected type ForcePerLength.", nameof(obj));
-
- return CompareTo((ForcePerLength)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(ForcePerLength other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ForcePerLength, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ForcePerLength))
- return false;
-
- var objQuantity = (ForcePerLength)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ForcePerLength within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ForcePerLength 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.
- [Obsolete("Please use the Equals(ForcePerLength, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ForcePerLength other, ForcePerLength maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ForcePerLength.
- public override int GetHashCode()
- {
- return new { type = typeof(ForcePerLength), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ForcePerLengthUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ForcePerLength to another ForcePerLength with the unit representation .
- ///
- /// A ForcePerLength with the specified unit.
- public ForcePerLength ToUnit(ForcePerLengthUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ForcePerLength(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ForcePerLengthUnit.CentinewtonPerMeter: return (_value) * 1e-2d;
- case ForcePerLengthUnit.DecinewtonPerMeter: return (_value) * 1e-1d;
- case ForcePerLengthUnit.KilogramForcePerMeter: return _value*9.80665002864;
- case ForcePerLengthUnit.KilonewtonPerMeter: return (_value) * 1e3d;
- case ForcePerLengthUnit.MeganewtonPerMeter: return (_value) * 1e6d;
- case ForcePerLengthUnit.MicronewtonPerMeter: return (_value) * 1e-6d;
- case ForcePerLengthUnit.MillinewtonPerMeter: return (_value) * 1e-3d;
- case ForcePerLengthUnit.NanonewtonPerMeter: return (_value) * 1e-9d;
- case ForcePerLengthUnit.NewtonPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ForcePerLengthUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ForcePerLengthUnit.CentinewtonPerMeter: return (baseUnitValue) / 1e-2d;
- case ForcePerLengthUnit.DecinewtonPerMeter: return (baseUnitValue) / 1e-1d;
- case ForcePerLengthUnit.KilogramForcePerMeter: return baseUnitValue/9.80665002864;
- case ForcePerLengthUnit.KilonewtonPerMeter: return (baseUnitValue) / 1e3d;
- case ForcePerLengthUnit.MeganewtonPerMeter: return (baseUnitValue) / 1e6d;
- case ForcePerLengthUnit.MicronewtonPerMeter: return (baseUnitValue) / 1e-6d;
- case ForcePerLengthUnit.MillinewtonPerMeter: return (baseUnitValue) / 1e-3d;
- case ForcePerLengthUnit.NanonewtonPerMeter: return (baseUnitValue) / 1e-9d;
- case ForcePerLengthUnit.NewtonPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ForcePerLength Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ForcePerLength result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ForcePerLengthUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ForcePerLengthUnit ToStringDefaultUnit { get; set; } = ForcePerLengthUnit.NewtonPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ForcePerLengthUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ForcePerLength
- ///
- public static ForcePerLength MaxValue => new ForcePerLength(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ForcePerLength
- ///
- public static ForcePerLength MinValue => new ForcePerLength(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ForcePerLength.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ForcePerLength.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Frequency.Common.g.cs b/Common/GeneratedCode/Quantities/Frequency.Common.g.cs
deleted file mode 100644
index 62044a6ae8..0000000000
--- a/Common/GeneratedCode/Quantities/Frequency.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The number of occurrences of a repeating event per unit time.
- ///
- // 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 Frequency : IQuantity
-#else
- public partial struct Frequency : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly FrequencyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public FrequencyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Frequency()
- {
- BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Hertz.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Frequency(double hertz)
- {
- _value = Convert.ToDouble(hertz);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Frequency(double numericValue, FrequencyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Hertz.
- ///
- /// Value assuming base unit Hertz.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Frequency(long hertz) : this(Convert.ToDouble(hertz), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Hertz.
- ///
- /// Value assuming base unit Hertz.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Frequency(decimal hertz) : this(Convert.ToDouble(hertz), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Frequency;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static FrequencyUnit BaseUnit => FrequencyUnit.Hertz;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Frequency quantity.
- ///
- public static FrequencyUnit[] Units { get; } = Enum.GetValues(typeof(FrequencyUnit)).Cast().Except(new FrequencyUnit[]{ FrequencyUnit.Undefined }).ToArray();
-
- ///
- /// Get Frequency in CyclesPerHour.
- ///
- public double CyclesPerHour => As(FrequencyUnit.CyclePerHour);
-
- ///
- /// Get Frequency in CyclesPerMinute.
- ///
- public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute);
-
- ///
- /// Get Frequency in Gigahertz.
- ///
- public double Gigahertz => As(FrequencyUnit.Gigahertz);
-
- ///
- /// Get Frequency in Hertz.
- ///
- public double Hertz => As(FrequencyUnit.Hertz);
-
- ///
- /// Get Frequency in Kilohertz.
- ///
- public double Kilohertz => As(FrequencyUnit.Kilohertz);
-
- ///
- /// Get Frequency in Megahertz.
- ///
- public double Megahertz => As(FrequencyUnit.Megahertz);
-
- ///
- /// Get Frequency in RadiansPerSecond.
- ///
- public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond);
-
- ///
- /// Get Frequency in Terahertz.
- ///
- public double Terahertz => As(FrequencyUnit.Terahertz);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Hertz.
- ///
- public static Frequency Zero => new Frequency(0, BaseUnit);
-
- ///
- /// Get Frequency from CyclesPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromCyclesPerHour(double cyclesperhour)
-#else
- public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour)
-#endif
- {
- double value = (double) cyclesperhour;
- return new Frequency(value, FrequencyUnit.CyclePerHour);
- }
-
- ///
- /// Get Frequency from CyclesPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromCyclesPerMinute(double cyclesperminute)
-#else
- public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute)
-#endif
- {
- double value = (double) cyclesperminute;
- return new Frequency(value, FrequencyUnit.CyclePerMinute);
- }
-
- ///
- /// Get Frequency from Gigahertz.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromGigahertz(double gigahertz)
-#else
- public static Frequency FromGigahertz(QuantityValue gigahertz)
-#endif
- {
- double value = (double) gigahertz;
- return new Frequency(value, FrequencyUnit.Gigahertz);
- }
-
- ///
- /// Get Frequency from Hertz.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromHertz(double hertz)
-#else
- public static Frequency FromHertz(QuantityValue hertz)
-#endif
- {
- double value = (double) hertz;
- return new Frequency(value, FrequencyUnit.Hertz);
- }
-
- ///
- /// Get Frequency from Kilohertz.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromKilohertz(double kilohertz)
-#else
- public static Frequency FromKilohertz(QuantityValue kilohertz)
-#endif
- {
- double value = (double) kilohertz;
- return new Frequency(value, FrequencyUnit.Kilohertz);
- }
-
- ///
- /// Get Frequency from Megahertz.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromMegahertz(double megahertz)
-#else
- public static Frequency FromMegahertz(QuantityValue megahertz)
-#endif
- {
- double value = (double) megahertz;
- return new Frequency(value, FrequencyUnit.Megahertz);
- }
-
- ///
- /// Get Frequency from RadiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromRadiansPerSecond(double radianspersecond)
-#else
- public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond)
-#endif
- {
- double value = (double) radianspersecond;
- return new Frequency(value, FrequencyUnit.RadianPerSecond);
- }
-
- ///
- /// Get Frequency from Terahertz.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Frequency FromTerahertz(double terahertz)
-#else
- public static Frequency FromTerahertz(QuantityValue terahertz)
-#endif
- {
- double value = (double) terahertz;
- return new Frequency(value, FrequencyUnit.Terahertz);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Frequency unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Frequency From(double value, FrequencyUnit fromUnit)
-#else
- public static Frequency From(QuantityValue value, FrequencyUnit fromUnit)
-#endif
- {
- return new Frequency((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(FrequencyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Frequency)) throw new ArgumentException("Expected type Frequency.", nameof(obj));
-
- return CompareTo((Frequency)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(Frequency other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Frequency, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Frequency))
- return false;
-
- var objQuantity = (Frequency)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Frequency within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Frequency 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.
- [Obsolete("Please use the Equals(Frequency, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Frequency other, Frequency maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Frequency.
- public override int GetHashCode()
- {
- return new { type = typeof(Frequency), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(FrequencyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Frequency to another Frequency with the unit representation .
- ///
- /// A Frequency with the specified unit.
- public Frequency ToUnit(FrequencyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Frequency(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case FrequencyUnit.CyclePerHour: return _value/3600;
- case FrequencyUnit.CyclePerMinute: return _value/60;
- case FrequencyUnit.Gigahertz: return (_value) * 1e9d;
- case FrequencyUnit.Hertz: return _value;
- case FrequencyUnit.Kilohertz: return (_value) * 1e3d;
- case FrequencyUnit.Megahertz: return (_value) * 1e6d;
- case FrequencyUnit.RadianPerSecond: return _value/6.2831853072;
- case FrequencyUnit.Terahertz: return (_value) * 1e12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(FrequencyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case FrequencyUnit.CyclePerHour: return baseUnitValue*3600;
- case FrequencyUnit.CyclePerMinute: return baseUnitValue*60;
- case FrequencyUnit.Gigahertz: return (baseUnitValue) / 1e9d;
- case FrequencyUnit.Hertz: return baseUnitValue;
- case FrequencyUnit.Kilohertz: return (baseUnitValue) / 1e3d;
- case FrequencyUnit.Megahertz: return (baseUnitValue) / 1e6d;
- case FrequencyUnit.RadianPerSecond: return baseUnitValue*6.2831853072;
- case FrequencyUnit.Terahertz: return (baseUnitValue) / 1e12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Frequency Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Frequency result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static FrequencyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Hertz
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static FrequencyUnit ToStringDefaultUnit { get; set; } = FrequencyUnit.Hertz;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(FrequencyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Frequency
- ///
- public static Frequency MaxValue => new Frequency(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Frequency
- ///
- public static Frequency MinValue => new Frequency(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Frequency.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Frequency.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/HeatFlux.Common.g.cs b/Common/GeneratedCode/Quantities/HeatFlux.Common.g.cs
deleted file mode 100644
index 613c5cf201..0000000000
--- a/Common/GeneratedCode/Quantities/HeatFlux.Common.g.cs
+++ /dev/null
@@ -1,847 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Heat flux is the flow of energy per unit of area per unit of time
- ///
- // 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 HeatFlux : IQuantity
-#else
- public partial struct HeatFlux : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly HeatFluxUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public HeatFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static HeatFlux()
- {
- BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit WattPerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public HeatFlux(double wattspersquaremeter)
- {
- _value = Convert.ToDouble(wattspersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- HeatFlux(double numericValue, HeatFluxUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeter.
- ///
- /// Value assuming base unit WattPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- HeatFlux(long wattspersquaremeter) : this(Convert.ToDouble(wattspersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeter.
- ///
- /// Value assuming base unit WattPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- HeatFlux(decimal wattspersquaremeter) : this(Convert.ToDouble(wattspersquaremeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.HeatFlux;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static HeatFluxUnit BaseUnit => HeatFluxUnit.WattPerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the HeatFlux quantity.
- ///
- public static HeatFluxUnit[] Units { get; } = Enum.GetValues(typeof(HeatFluxUnit)).Cast().Except(new HeatFluxUnit[]{ HeatFluxUnit.Undefined }).ToArray();
-
- ///
- /// Get HeatFlux in BtusPerHourSquareFoot.
- ///
- public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot);
-
- ///
- /// Get HeatFlux in BtusPerMinuteSquareFoot.
- ///
- public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot);
-
- ///
- /// Get HeatFlux in BtusPerSecondSquareFoot.
- ///
- public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot);
-
- ///
- /// Get HeatFlux in BtusPerSecondSquareInch.
- ///
- public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch);
-
- ///
- /// Get HeatFlux in CaloriesPerSecondSquareCentimeter.
- ///
- public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter);
-
- ///
- /// Get HeatFlux in CentiwattsPerSquareMeter.
- ///
- public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter);
-
- ///
- /// Get HeatFlux in DeciwattsPerSquareMeter.
- ///
- public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter);
-
- ///
- /// Get HeatFlux in KilocaloriesPerHourSquareMeter.
- ///
- public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter);
-
- ///
- /// Get HeatFlux in KilocaloriesPerSecondSquareCentimeter.
- ///
- public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter);
-
- ///
- /// Get HeatFlux in KilowattsPerSquareMeter.
- ///
- public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter);
-
- ///
- /// Get HeatFlux in MicrowattsPerSquareMeter.
- ///
- public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter);
-
- ///
- /// Get HeatFlux in MilliwattsPerSquareMeter.
- ///
- public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter);
-
- ///
- /// Get HeatFlux in NanowattsPerSquareMeter.
- ///
- public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter);
-
- ///
- /// Get HeatFlux in PoundsForcePerFootSecond.
- ///
- public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond);
-
- ///
- /// Get HeatFlux in PoundsPerSecondCubed.
- ///
- public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed);
-
- ///
- /// Get HeatFlux in WattsPerSquareFoot.
- ///
- public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot);
-
- ///
- /// Get HeatFlux in WattsPerSquareInch.
- ///
- public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch);
-
- ///
- /// Get HeatFlux in WattsPerSquareMeter.
- ///
- public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter.
- ///
- public static HeatFlux Zero => new HeatFlux(0, BaseUnit);
-
- ///
- /// Get HeatFlux from BtusPerHourSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromBtusPerHourSquareFoot(double btusperhoursquarefoot)
-#else
- public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquarefoot)
-#endif
- {
- double value = (double) btusperhoursquarefoot;
- return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot);
- }
-
- ///
- /// Get HeatFlux from BtusPerMinuteSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromBtusPerMinuteSquareFoot(double btusperminutesquarefoot)
-#else
- public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesquarefoot)
-#endif
- {
- double value = (double) btusperminutesquarefoot;
- return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot);
- }
-
- ///
- /// Get HeatFlux from BtusPerSecondSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromBtusPerSecondSquareFoot(double btuspersecondsquarefoot)
-#else
- public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsquarefoot)
-#endif
- {
- double value = (double) btuspersecondsquarefoot;
- return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot);
- }
-
- ///
- /// Get HeatFlux from BtusPerSecondSquareInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromBtusPerSecondSquareInch(double btuspersecondsquareinch)
-#else
- public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsquareinch)
-#endif
- {
- double value = (double) btuspersecondsquareinch;
- return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch);
- }
-
- ///
- /// Get HeatFlux from CaloriesPerSecondSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromCaloriesPerSecondSquareCentimeter(double caloriespersecondsquarecentimeter)
-#else
- public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue caloriespersecondsquarecentimeter)
-#endif
- {
- double value = (double) caloriespersecondsquarecentimeter;
- return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter);
- }
-
- ///
- /// Get HeatFlux from CentiwattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromCentiwattsPerSquareMeter(double centiwattspersquaremeter)
-#else
- public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspersquaremeter)
-#endif
- {
- double value = (double) centiwattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from DeciwattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromDeciwattsPerSquareMeter(double deciwattspersquaremeter)
-#else
- public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersquaremeter)
-#endif
- {
- double value = (double) deciwattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from KilocaloriesPerHourSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromKilocaloriesPerHourSquareMeter(double kilocaloriesperhoursquaremeter)
-#else
- public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocaloriesperhoursquaremeter)
-#endif
- {
- double value = (double) kilocaloriesperhoursquaremeter;
- return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter);
- }
-
- ///
- /// Get HeatFlux from KilocaloriesPerSecondSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(double kilocaloriespersecondsquarecentimeter)
-#else
- public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue kilocaloriespersecondsquarecentimeter)
-#endif
- {
- double value = (double) kilocaloriespersecondsquarecentimeter;
- return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter);
- }
-
- ///
- /// Get HeatFlux from KilowattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromKilowattsPerSquareMeter(double kilowattspersquaremeter)
-#else
- public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter)
-#endif
- {
- double value = (double) kilowattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from MicrowattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromMicrowattsPerSquareMeter(double microwattspersquaremeter)
-#else
- public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter)
-#endif
- {
- double value = (double) microwattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from MilliwattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromMilliwattsPerSquareMeter(double milliwattspersquaremeter)
-#else
- public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter)
-#endif
- {
- double value = (double) milliwattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from NanowattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromNanowattsPerSquareMeter(double nanowattspersquaremeter)
-#else
- public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter)
-#endif
- {
- double value = (double) nanowattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter);
- }
-
- ///
- /// Get HeatFlux from PoundsForcePerFootSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromPoundsForcePerFootSecond(double poundsforceperfootsecond)
-#else
- public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceperfootsecond)
-#endif
- {
- double value = (double) poundsforceperfootsecond;
- return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond);
- }
-
- ///
- /// Get HeatFlux from PoundsPerSecondCubed.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromPoundsPerSecondCubed(double poundspersecondcubed)
-#else
- public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcubed)
-#endif
- {
- double value = (double) poundspersecondcubed;
- return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed);
- }
-
- ///
- /// Get HeatFlux from WattsPerSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromWattsPerSquareFoot(double wattspersquarefoot)
-#else
- public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot)
-#endif
- {
- double value = (double) wattspersquarefoot;
- return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot);
- }
-
- ///
- /// Get HeatFlux from WattsPerSquareInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromWattsPerSquareInch(double wattspersquareinch)
-#else
- public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch)
-#endif
- {
- double value = (double) wattspersquareinch;
- return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch);
- }
-
- ///
- /// Get HeatFlux from WattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatFlux FromWattsPerSquareMeter(double wattspersquaremeter)
-#else
- public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter)
-#endif
- {
- double value = (double) wattspersquaremeter;
- return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// HeatFlux unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static HeatFlux From(double value, HeatFluxUnit fromUnit)
-#else
- public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit)
-#endif
- {
- return new HeatFlux((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(HeatFluxUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is HeatFlux)) throw new ArgumentException("Expected type HeatFlux.", nameof(obj));
-
- return CompareTo((HeatFlux)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(HeatFlux other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(HeatFlux, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is HeatFlux))
- return false;
-
- var objQuantity = (HeatFlux)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another HeatFlux within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another HeatFlux 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.
- [Obsolete("Please use the Equals(HeatFlux, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(HeatFlux other, HeatFlux maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current HeatFlux.
- public override int GetHashCode()
- {
- return new { type = typeof(HeatFlux), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(HeatFluxUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this HeatFlux to another HeatFlux with the unit representation .
- ///
- /// A HeatFlux with the specified unit.
- public HeatFlux ToUnit(HeatFluxUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new HeatFlux(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case HeatFluxUnit.BtuPerHourSquareFoot: return _value*3.15459075;
- case HeatFluxUnit.BtuPerMinuteSquareFoot: return _value*1.89275445e2;
- case HeatFluxUnit.BtuPerSecondSquareFoot: return _value*1.13565267e4;
- case HeatFluxUnit.BtuPerSecondSquareInch: return _value*1.63533984e6;
- case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return _value*4.1868e4;
- case HeatFluxUnit.CentiwattPerSquareMeter: return (_value) * 1e-2d;
- case HeatFluxUnit.DeciwattPerSquareMeter: return (_value) * 1e-1d;
- case HeatFluxUnit.KilocaloriePerHourSquareMeter: return _value*1.163;
- case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (_value*4.1868e4) * 1e3d;
- case HeatFluxUnit.KilowattPerSquareMeter: return (_value) * 1e3d;
- case HeatFluxUnit.MicrowattPerSquareMeter: return (_value) * 1e-6d;
- case HeatFluxUnit.MilliwattPerSquareMeter: return (_value) * 1e-3d;
- case HeatFluxUnit.NanowattPerSquareMeter: return (_value) * 1e-9d;
- case HeatFluxUnit.PoundForcePerFootSecond: return _value*1.459390293720636e1;
- case HeatFluxUnit.PoundPerSecondCubed: return _value*4.5359237e-1;
- case HeatFluxUnit.WattPerSquareFoot: return _value*1.07639e1;
- case HeatFluxUnit.WattPerSquareInch: return _value*1.5500031e3;
- case HeatFluxUnit.WattPerSquareMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(HeatFluxUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case HeatFluxUnit.BtuPerHourSquareFoot: return baseUnitValue/3.15459075;
- case HeatFluxUnit.BtuPerMinuteSquareFoot: return baseUnitValue/1.89275445e2;
- case HeatFluxUnit.BtuPerSecondSquareFoot: return baseUnitValue/1.13565267e4;
- case HeatFluxUnit.BtuPerSecondSquareInch: return baseUnitValue/1.63533984e6;
- case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return baseUnitValue/4.1868e4;
- case HeatFluxUnit.CentiwattPerSquareMeter: return (baseUnitValue) / 1e-2d;
- case HeatFluxUnit.DeciwattPerSquareMeter: return (baseUnitValue) / 1e-1d;
- case HeatFluxUnit.KilocaloriePerHourSquareMeter: return baseUnitValue/1.163;
- case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (baseUnitValue/4.1868e4) / 1e3d;
- case HeatFluxUnit.KilowattPerSquareMeter: return (baseUnitValue) / 1e3d;
- case HeatFluxUnit.MicrowattPerSquareMeter: return (baseUnitValue) / 1e-6d;
- case HeatFluxUnit.MilliwattPerSquareMeter: return (baseUnitValue) / 1e-3d;
- case HeatFluxUnit.NanowattPerSquareMeter: return (baseUnitValue) / 1e-9d;
- case HeatFluxUnit.PoundForcePerFootSecond: return baseUnitValue/1.459390293720636e1;
- case HeatFluxUnit.PoundPerSecondCubed: return baseUnitValue/4.5359237e-1;
- case HeatFluxUnit.WattPerSquareFoot: return baseUnitValue/1.07639e1;
- case HeatFluxUnit.WattPerSquareInch: return baseUnitValue/1.5500031e3;
- case HeatFluxUnit.WattPerSquareMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 HeatFlux Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 HeatFlux result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static HeatFluxUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is WattPerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static HeatFluxUnit ToStringDefaultUnit { get; set; } = HeatFluxUnit.WattPerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(HeatFluxUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of HeatFlux
- ///
- public static HeatFlux MaxValue => new HeatFlux(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of HeatFlux
- ///
- public static HeatFlux MinValue => new HeatFlux(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => HeatFlux.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => HeatFlux.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/HeatTransferCoefficient.Common.g.cs b/Common/GeneratedCode/Quantities/HeatTransferCoefficient.Common.g.cs
deleted file mode 100644
index 3cba0c1089..0000000000
--- a/Common/GeneratedCode/Quantities/HeatTransferCoefficient.Common.g.cs
+++ /dev/null
@@ -1,511 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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)
- ///
- // 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 HeatTransferCoefficient : IQuantity
-#else
- public partial struct HeatTransferCoefficient : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly HeatTransferCoefficientUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static HeatTransferCoefficient()
- {
- BaseDimensions = new BaseDimensions(0, 1, -3, 0, -1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit WattPerSquareMeterKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public HeatTransferCoefficient(double wattspersquaremeterkelvin)
- {
- _value = Convert.ToDouble(wattspersquaremeterkelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- HeatTransferCoefficient(double numericValue, HeatTransferCoefficientUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeterKelvin.
- ///
- /// Value assuming base unit WattPerSquareMeterKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- HeatTransferCoefficient(long wattspersquaremeterkelvin) : this(Convert.ToDouble(wattspersquaremeterkelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeterKelvin.
- ///
- /// Value assuming base unit WattPerSquareMeterKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- HeatTransferCoefficient(decimal wattspersquaremeterkelvin) : this(Convert.ToDouble(wattspersquaremeterkelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.HeatTransferCoefficient;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static HeatTransferCoefficientUnit BaseUnit => HeatTransferCoefficientUnit.WattPerSquareMeterKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the HeatTransferCoefficient quantity.
- ///
- public static HeatTransferCoefficientUnit[] Units { get; } = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().Except(new HeatTransferCoefficientUnit[]{ HeatTransferCoefficientUnit.Undefined }).ToArray();
-
- ///
- /// Get HeatTransferCoefficient in WattsPerSquareMeterCelsius.
- ///
- public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius);
-
- ///
- /// Get HeatTransferCoefficient in WattsPerSquareMeterKelvin.
- ///
- public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeterKelvin.
- ///
- public static HeatTransferCoefficient Zero => new HeatTransferCoefficient(0, BaseUnit);
-
- ///
- /// Get HeatTransferCoefficient from WattsPerSquareMeterCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(double wattspersquaremetercelsius)
-#else
- public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityValue wattspersquaremetercelsius)
-#endif
- {
- double value = (double) wattspersquaremetercelsius;
- return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius);
- }
-
- ///
- /// Get HeatTransferCoefficient from WattsPerSquareMeterKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(double wattspersquaremeterkelvin)
-#else
- public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValue wattspersquaremeterkelvin)
-#endif
- {
- double value = (double) wattspersquaremeterkelvin;
- return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// HeatTransferCoefficient unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static HeatTransferCoefficient From(double value, HeatTransferCoefficientUnit fromUnit)
-#else
- public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoefficientUnit fromUnit)
-#endif
- {
- return new HeatTransferCoefficient((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(HeatTransferCoefficientUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is HeatTransferCoefficient)) throw new ArgumentException("Expected type HeatTransferCoefficient.", nameof(obj));
-
- return CompareTo((HeatTransferCoefficient)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(HeatTransferCoefficient other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(HeatTransferCoefficient, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is HeatTransferCoefficient))
- return false;
-
- var objQuantity = (HeatTransferCoefficient)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another HeatTransferCoefficient 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.
- [Obsolete("Please use the Equals(HeatTransferCoefficient, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current HeatTransferCoefficient.
- public override int GetHashCode()
- {
- return new { type = typeof(HeatTransferCoefficient), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(HeatTransferCoefficientUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation .
- ///
- /// A HeatTransferCoefficient with the specified unit.
- public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new HeatTransferCoefficient(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return _value;
- case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(HeatTransferCoefficientUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return baseUnitValue;
- case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 HeatTransferCoefficient Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 HeatTransferCoefficient result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static HeatTransferCoefficientUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is WattPerSquareMeterKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static HeatTransferCoefficientUnit ToStringDefaultUnit { get; set; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(HeatTransferCoefficientUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of HeatTransferCoefficient
- ///
- public static HeatTransferCoefficient MaxValue => new HeatTransferCoefficient(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of HeatTransferCoefficient
- ///
- public static HeatTransferCoefficient MinValue => new HeatTransferCoefficient(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => HeatTransferCoefficient.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => HeatTransferCoefficient.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Illuminance.Common.g.cs b/Common/GeneratedCode/Quantities/Illuminance.Common.g.cs
deleted file mode 100644
index 6017e87c55..0000000000
--- a/Common/GeneratedCode/Quantities/Illuminance.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In photometry, illuminance is the total luminous flux incident on a surface, per unit area.
- ///
- // 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 Illuminance : IQuantity
-#else
- public partial struct Illuminance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly IlluminanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public IlluminanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Illuminance()
- {
- BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Lux.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Illuminance(double lux)
- {
- _value = Convert.ToDouble(lux);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Illuminance(double numericValue, IlluminanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Lux.
- ///
- /// Value assuming base unit Lux.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Illuminance(long lux) : this(Convert.ToDouble(lux), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Lux.
- ///
- /// Value assuming base unit Lux.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Illuminance(decimal lux) : this(Convert.ToDouble(lux), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Illuminance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static IlluminanceUnit BaseUnit => IlluminanceUnit.Lux;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Illuminance quantity.
- ///
- public static IlluminanceUnit[] Units { get; } = Enum.GetValues(typeof(IlluminanceUnit)).Cast().Except(new IlluminanceUnit[]{ IlluminanceUnit.Undefined }).ToArray();
-
- ///
- /// Get Illuminance in Kilolux.
- ///
- public double Kilolux => As(IlluminanceUnit.Kilolux);
-
- ///
- /// Get Illuminance in Lux.
- ///
- public double Lux => As(IlluminanceUnit.Lux);
-
- ///
- /// Get Illuminance in Megalux.
- ///
- public double Megalux => As(IlluminanceUnit.Megalux);
-
- ///
- /// Get Illuminance in Millilux.
- ///
- public double Millilux => As(IlluminanceUnit.Millilux);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Lux.
- ///
- public static Illuminance Zero => new Illuminance(0, BaseUnit);
-
- ///
- /// Get Illuminance from Kilolux.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Illuminance FromKilolux(double kilolux)
-#else
- public static Illuminance FromKilolux(QuantityValue kilolux)
-#endif
- {
- double value = (double) kilolux;
- return new Illuminance(value, IlluminanceUnit.Kilolux);
- }
-
- ///
- /// Get Illuminance from Lux.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Illuminance FromLux(double lux)
-#else
- public static Illuminance FromLux(QuantityValue lux)
-#endif
- {
- double value = (double) lux;
- return new Illuminance(value, IlluminanceUnit.Lux);
- }
-
- ///
- /// Get Illuminance from Megalux.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Illuminance FromMegalux(double megalux)
-#else
- public static Illuminance FromMegalux(QuantityValue megalux)
-#endif
- {
- double value = (double) megalux;
- return new Illuminance(value, IlluminanceUnit.Megalux);
- }
-
- ///
- /// Get Illuminance from Millilux.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Illuminance FromMillilux(double millilux)
-#else
- public static Illuminance FromMillilux(QuantityValue millilux)
-#endif
- {
- double value = (double) millilux;
- return new Illuminance(value, IlluminanceUnit.Millilux);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Illuminance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Illuminance From(double value, IlluminanceUnit fromUnit)
-#else
- public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit)
-#endif
- {
- return new Illuminance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(IlluminanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Illuminance)) throw new ArgumentException("Expected type Illuminance.", nameof(obj));
-
- return CompareTo((Illuminance)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(Illuminance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Illuminance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Illuminance))
- return false;
-
- var objQuantity = (Illuminance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Illuminance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Illuminance 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.
- [Obsolete("Please use the Equals(Illuminance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Illuminance other, Illuminance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Illuminance.
- public override int GetHashCode()
- {
- return new { type = typeof(Illuminance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(IlluminanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Illuminance to another Illuminance with the unit representation .
- ///
- /// A Illuminance with the specified unit.
- public Illuminance ToUnit(IlluminanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Illuminance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case IlluminanceUnit.Kilolux: return (_value) * 1e3d;
- case IlluminanceUnit.Lux: return _value;
- case IlluminanceUnit.Megalux: return (_value) * 1e6d;
- case IlluminanceUnit.Millilux: return (_value) * 1e-3d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(IlluminanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case IlluminanceUnit.Kilolux: return (baseUnitValue) / 1e3d;
- case IlluminanceUnit.Lux: return baseUnitValue;
- case IlluminanceUnit.Megalux: return (baseUnitValue) / 1e6d;
- case IlluminanceUnit.Millilux: return (baseUnitValue) / 1e-3d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Illuminance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Illuminance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static IlluminanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Lux
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static IlluminanceUnit ToStringDefaultUnit { get; set; } = IlluminanceUnit.Lux;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(IlluminanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Illuminance
- ///
- public static Illuminance MaxValue => new Illuminance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Illuminance
- ///
- public static Illuminance MinValue => new Illuminance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Illuminance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Illuminance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Information.Common.g.cs b/Common/GeneratedCode/Quantities/Information.Common.g.cs
deleted file mode 100644
index 3051e9b23a..0000000000
--- a/Common/GeneratedCode/Quantities/Information.Common.g.cs
+++ /dev/null
@@ -1,1013 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Information : IQuantity
-#else
- public partial struct Information : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly decimal _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly InformationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public InformationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Information()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Bit.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Information(double bits)
- {
- _value = Convert.ToDecimal(bits);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Information(decimal numericValue, InformationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Bit.
- ///
- /// Value assuming base unit Bit.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Information(long bits) : this(Convert.ToDecimal(bits), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Bit.
- ///
- /// Value assuming base unit Bit.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Information(decimal bits) : this(Convert.ToDecimal(bits), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Information;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static InformationUnit BaseUnit => InformationUnit.Bit;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Information quantity.
- ///
- public static InformationUnit[] Units { get; } = Enum.GetValues(typeof(InformationUnit)).Cast().Except(new InformationUnit[]{ InformationUnit.Undefined }).ToArray();
-
- ///
- /// Get Information in Bits.
- ///
- public double Bits => As(InformationUnit.Bit);
-
- ///
- /// Get Information in Bytes.
- ///
- public double Bytes => As(InformationUnit.Byte);
-
- ///
- /// Get Information in Exabits.
- ///
- public double Exabits => As(InformationUnit.Exabit);
-
- ///
- /// Get Information in Exabytes.
- ///
- public double Exabytes => As(InformationUnit.Exabyte);
-
- ///
- /// Get Information in Exbibits.
- ///
- public double Exbibits => As(InformationUnit.Exbibit);
-
- ///
- /// Get Information in Exbibytes.
- ///
- public double Exbibytes => As(InformationUnit.Exbibyte);
-
- ///
- /// Get Information in Gibibits.
- ///
- public double Gibibits => As(InformationUnit.Gibibit);
-
- ///
- /// Get Information in Gibibytes.
- ///
- public double Gibibytes => As(InformationUnit.Gibibyte);
-
- ///
- /// Get Information in Gigabits.
- ///
- public double Gigabits => As(InformationUnit.Gigabit);
-
- ///
- /// Get Information in Gigabytes.
- ///
- public double Gigabytes => As(InformationUnit.Gigabyte);
-
- ///
- /// Get Information in Kibibits.
- ///
- public double Kibibits => As(InformationUnit.Kibibit);
-
- ///
- /// Get Information in Kibibytes.
- ///
- public double Kibibytes => As(InformationUnit.Kibibyte);
-
- ///
- /// Get Information in Kilobits.
- ///
- public double Kilobits => As(InformationUnit.Kilobit);
-
- ///
- /// Get Information in Kilobytes.
- ///
- public double Kilobytes => As(InformationUnit.Kilobyte);
-
- ///
- /// Get Information in Mebibits.
- ///
- public double Mebibits => As(InformationUnit.Mebibit);
-
- ///
- /// Get Information in Mebibytes.
- ///
- public double Mebibytes => As(InformationUnit.Mebibyte);
-
- ///
- /// Get Information in Megabits.
- ///
- public double Megabits => As(InformationUnit.Megabit);
-
- ///
- /// Get Information in Megabytes.
- ///
- public double Megabytes => As(InformationUnit.Megabyte);
-
- ///
- /// Get Information in Pebibits.
- ///
- public double Pebibits => As(InformationUnit.Pebibit);
-
- ///
- /// Get Information in Pebibytes.
- ///
- public double Pebibytes => As(InformationUnit.Pebibyte);
-
- ///
- /// Get Information in Petabits.
- ///
- public double Petabits => As(InformationUnit.Petabit);
-
- ///
- /// Get Information in Petabytes.
- ///
- public double Petabytes => As(InformationUnit.Petabyte);
-
- ///
- /// Get Information in Tebibits.
- ///
- public double Tebibits => As(InformationUnit.Tebibit);
-
- ///
- /// Get Information in Tebibytes.
- ///
- public double Tebibytes => As(InformationUnit.Tebibyte);
-
- ///
- /// Get Information in Terabits.
- ///
- public double Terabits => As(InformationUnit.Terabit);
-
- ///
- /// Get Information in Terabytes.
- ///
- public double Terabytes => As(InformationUnit.Terabyte);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Bit.
- ///
- public static Information Zero => new Information(0, BaseUnit);
-
- ///
- /// Get Information from Bits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromBits(double bits)
-#else
- public static Information FromBits(QuantityValue bits)
-#endif
- {
- decimal value = (decimal) bits;
- return new Information(value, InformationUnit.Bit);
- }
-
- ///
- /// Get Information from Bytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromBytes(double bytes)
-#else
- public static Information FromBytes(QuantityValue bytes)
-#endif
- {
- decimal value = (decimal) bytes;
- return new Information(value, InformationUnit.Byte);
- }
-
- ///
- /// Get Information from Exabits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromExabits(double exabits)
-#else
- public static Information FromExabits(QuantityValue exabits)
-#endif
- {
- decimal value = (decimal) exabits;
- return new Information(value, InformationUnit.Exabit);
- }
-
- ///
- /// Get Information from Exabytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromExabytes(double exabytes)
-#else
- public static Information FromExabytes(QuantityValue exabytes)
-#endif
- {
- decimal value = (decimal) exabytes;
- return new Information(value, InformationUnit.Exabyte);
- }
-
- ///
- /// Get Information from Exbibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromExbibits(double exbibits)
-#else
- public static Information FromExbibits(QuantityValue exbibits)
-#endif
- {
- decimal value = (decimal) exbibits;
- return new Information(value, InformationUnit.Exbibit);
- }
-
- ///
- /// Get Information from Exbibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromExbibytes(double exbibytes)
-#else
- public static Information FromExbibytes(QuantityValue exbibytes)
-#endif
- {
- decimal value = (decimal) exbibytes;
- return new Information(value, InformationUnit.Exbibyte);
- }
-
- ///
- /// Get Information from Gibibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromGibibits(double gibibits)
-#else
- public static Information FromGibibits(QuantityValue gibibits)
-#endif
- {
- decimal value = (decimal) gibibits;
- return new Information(value, InformationUnit.Gibibit);
- }
-
- ///
- /// Get Information from Gibibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromGibibytes(double gibibytes)
-#else
- public static Information FromGibibytes(QuantityValue gibibytes)
-#endif
- {
- decimal value = (decimal) gibibytes;
- return new Information(value, InformationUnit.Gibibyte);
- }
-
- ///
- /// Get Information from Gigabits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromGigabits(double gigabits)
-#else
- public static Information FromGigabits(QuantityValue gigabits)
-#endif
- {
- decimal value = (decimal) gigabits;
- return new Information(value, InformationUnit.Gigabit);
- }
-
- ///
- /// Get Information from Gigabytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromGigabytes(double gigabytes)
-#else
- public static Information FromGigabytes(QuantityValue gigabytes)
-#endif
- {
- decimal value = (decimal) gigabytes;
- return new Information(value, InformationUnit.Gigabyte);
- }
-
- ///
- /// Get Information from Kibibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromKibibits(double kibibits)
-#else
- public static Information FromKibibits(QuantityValue kibibits)
-#endif
- {
- decimal value = (decimal) kibibits;
- return new Information(value, InformationUnit.Kibibit);
- }
-
- ///
- /// Get Information from Kibibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromKibibytes(double kibibytes)
-#else
- public static Information FromKibibytes(QuantityValue kibibytes)
-#endif
- {
- decimal value = (decimal) kibibytes;
- return new Information(value, InformationUnit.Kibibyte);
- }
-
- ///
- /// Get Information from Kilobits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromKilobits(double kilobits)
-#else
- public static Information FromKilobits(QuantityValue kilobits)
-#endif
- {
- decimal value = (decimal) kilobits;
- return new Information(value, InformationUnit.Kilobit);
- }
-
- ///
- /// Get Information from Kilobytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromKilobytes(double kilobytes)
-#else
- public static Information FromKilobytes(QuantityValue kilobytes)
-#endif
- {
- decimal value = (decimal) kilobytes;
- return new Information(value, InformationUnit.Kilobyte);
- }
-
- ///
- /// Get Information from Mebibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromMebibits(double mebibits)
-#else
- public static Information FromMebibits(QuantityValue mebibits)
-#endif
- {
- decimal value = (decimal) mebibits;
- return new Information(value, InformationUnit.Mebibit);
- }
-
- ///
- /// Get Information from Mebibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromMebibytes(double mebibytes)
-#else
- public static Information FromMebibytes(QuantityValue mebibytes)
-#endif
- {
- decimal value = (decimal) mebibytes;
- return new Information(value, InformationUnit.Mebibyte);
- }
-
- ///
- /// Get Information from Megabits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromMegabits(double megabits)
-#else
- public static Information FromMegabits(QuantityValue megabits)
-#endif
- {
- decimal value = (decimal) megabits;
- return new Information(value, InformationUnit.Megabit);
- }
-
- ///
- /// Get Information from Megabytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromMegabytes(double megabytes)
-#else
- public static Information FromMegabytes(QuantityValue megabytes)
-#endif
- {
- decimal value = (decimal) megabytes;
- return new Information(value, InformationUnit.Megabyte);
- }
-
- ///
- /// Get Information from Pebibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromPebibits(double pebibits)
-#else
- public static Information FromPebibits(QuantityValue pebibits)
-#endif
- {
- decimal value = (decimal) pebibits;
- return new Information(value, InformationUnit.Pebibit);
- }
-
- ///
- /// Get Information from Pebibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromPebibytes(double pebibytes)
-#else
- public static Information FromPebibytes(QuantityValue pebibytes)
-#endif
- {
- decimal value = (decimal) pebibytes;
- return new Information(value, InformationUnit.Pebibyte);
- }
-
- ///
- /// Get Information from Petabits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromPetabits(double petabits)
-#else
- public static Information FromPetabits(QuantityValue petabits)
-#endif
- {
- decimal value = (decimal) petabits;
- return new Information(value, InformationUnit.Petabit);
- }
-
- ///
- /// Get Information from Petabytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromPetabytes(double petabytes)
-#else
- public static Information FromPetabytes(QuantityValue petabytes)
-#endif
- {
- decimal value = (decimal) petabytes;
- return new Information(value, InformationUnit.Petabyte);
- }
-
- ///
- /// Get Information from Tebibits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromTebibits(double tebibits)
-#else
- public static Information FromTebibits(QuantityValue tebibits)
-#endif
- {
- decimal value = (decimal) tebibits;
- return new Information(value, InformationUnit.Tebibit);
- }
-
- ///
- /// Get Information from Tebibytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromTebibytes(double tebibytes)
-#else
- public static Information FromTebibytes(QuantityValue tebibytes)
-#endif
- {
- decimal value = (decimal) tebibytes;
- return new Information(value, InformationUnit.Tebibyte);
- }
-
- ///
- /// Get Information from Terabits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromTerabits(double terabits)
-#else
- public static Information FromTerabits(QuantityValue terabits)
-#endif
- {
- decimal value = (decimal) terabits;
- return new Information(value, InformationUnit.Terabit);
- }
-
- ///
- /// Get Information from Terabytes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Information FromTerabytes(double terabytes)
-#else
- public static Information FromTerabytes(QuantityValue terabytes)
-#endif
- {
- decimal value = (decimal) terabytes;
- return new Information(value, InformationUnit.Terabyte);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Information unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Information From(double value, InformationUnit fromUnit)
-#else
- public static Information From(QuantityValue value, InformationUnit fromUnit)
-#endif
- {
- return new Information((decimal)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(InformationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Information)) throw new ArgumentException("Expected type Information.", nameof(obj));
-
- return CompareTo((Information)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(Information other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Information))
- return false;
-
- var objQuantity = (Information)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Information within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Information other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Information 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.
- [Obsolete("Please use the Equals(Information, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Information other, Information maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Information.
- public override int GetHashCode()
- {
- return new { type = typeof(Information), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(InformationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Information to another Information with the unit representation .
- ///
- /// A Information with the specified unit.
- public Information ToUnit(InformationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Information(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private decimal AsBaseUnit()
- {
- switch(Unit)
- {
- case InformationUnit.Bit: return _value;
- case InformationUnit.Byte: return _value*8m;
- case InformationUnit.Exabit: return (_value) * 1e18m;
- case InformationUnit.Exabyte: return (_value*8m) * 1e18m;
- case InformationUnit.Exbibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Exbibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Gibibit: return (_value) * (1024m * 1024 * 1024);
- case InformationUnit.Gibibyte: return (_value*8m) * (1024m * 1024 * 1024);
- case InformationUnit.Gigabit: return (_value) * 1e9m;
- case InformationUnit.Gigabyte: return (_value*8m) * 1e9m;
- case InformationUnit.Kibibit: return (_value) * 1024m;
- case InformationUnit.Kibibyte: return (_value*8m) * 1024m;
- case InformationUnit.Kilobit: return (_value) * 1e3m;
- case InformationUnit.Kilobyte: return (_value*8m) * 1e3m;
- case InformationUnit.Mebibit: return (_value) * (1024m * 1024);
- case InformationUnit.Mebibyte: return (_value*8m) * (1024m * 1024);
- case InformationUnit.Megabit: return (_value) * 1e6m;
- case InformationUnit.Megabyte: return (_value*8m) * 1e6m;
- case InformationUnit.Pebibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Pebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Petabit: return (_value) * 1e15m;
- case InformationUnit.Petabyte: return (_value*8m) * 1e15m;
- case InformationUnit.Tebibit: return (_value) * (1024m * 1024 * 1024 * 1024);
- case InformationUnit.Tebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024);
- case InformationUnit.Terabit: return (_value) * 1e12m;
- case InformationUnit.Terabyte: return (_value*8m) * 1e12m;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private decimal AsBaseNumericType(InformationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case InformationUnit.Bit: return baseUnitValue;
- case InformationUnit.Byte: return baseUnitValue/8m;
- case InformationUnit.Exabit: return (baseUnitValue) / 1e18m;
- case InformationUnit.Exabyte: return (baseUnitValue/8m) / 1e18m;
- case InformationUnit.Exbibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Exbibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Gibibit: return (baseUnitValue) / (1024m * 1024 * 1024);
- case InformationUnit.Gibibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024);
- case InformationUnit.Gigabit: return (baseUnitValue) / 1e9m;
- case InformationUnit.Gigabyte: return (baseUnitValue/8m) / 1e9m;
- case InformationUnit.Kibibit: return (baseUnitValue) / 1024m;
- case InformationUnit.Kibibyte: return (baseUnitValue/8m) / 1024m;
- case InformationUnit.Kilobit: return (baseUnitValue) / 1e3m;
- case InformationUnit.Kilobyte: return (baseUnitValue/8m) / 1e3m;
- case InformationUnit.Mebibit: return (baseUnitValue) / (1024m * 1024);
- case InformationUnit.Mebibyte: return (baseUnitValue/8m) / (1024m * 1024);
- case InformationUnit.Megabit: return (baseUnitValue) / 1e6m;
- case InformationUnit.Megabyte: return (baseUnitValue/8m) / 1e6m;
- case InformationUnit.Pebibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Pebibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024);
- case InformationUnit.Petabit: return (baseUnitValue) / 1e15m;
- case InformationUnit.Petabyte: return (baseUnitValue/8m) / 1e15m;
- case InformationUnit.Tebibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024);
- case InformationUnit.Tebibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024);
- case InformationUnit.Terabit: return (baseUnitValue) / 1e12m;
- case InformationUnit.Terabyte: return (baseUnitValue/8m) / 1e12m;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Information Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Information result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static InformationUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Bit
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static InformationUnit ToStringDefaultUnit { get; set; } = InformationUnit.Bit;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(InformationUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Information
- ///
- public static Information MaxValue => new Information(decimal.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Information
- ///
- public static Information MinValue => new Information(decimal.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Information.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Information.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Irradiance.Common.g.cs b/Common/GeneratedCode/Quantities/Irradiance.Common.g.cs
deleted file mode 100644
index a74974d31f..0000000000
--- a/Common/GeneratedCode/Quantities/Irradiance.Common.g.cs
+++ /dev/null
@@ -1,511 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.
- ///
- // 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 Irradiance : IQuantity
-#else
- public partial struct Irradiance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly IrradianceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public IrradianceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Irradiance()
- {
- BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit WattPerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Irradiance(double wattspersquaremeter)
- {
- _value = Convert.ToDouble(wattspersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Irradiance(double numericValue, IrradianceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeter.
- ///
- /// Value assuming base unit WattPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Irradiance(long wattspersquaremeter) : this(Convert.ToDouble(wattspersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerSquareMeter.
- ///
- /// Value assuming base unit WattPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Irradiance(decimal wattspersquaremeter) : this(Convert.ToDouble(wattspersquaremeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Irradiance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static IrradianceUnit BaseUnit => IrradianceUnit.WattPerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Irradiance quantity.
- ///
- public static IrradianceUnit[] Units { get; } = Enum.GetValues(typeof(IrradianceUnit)).Cast().Except(new IrradianceUnit[]{ IrradianceUnit.Undefined }).ToArray();
-
- ///
- /// Get Irradiance in KilowattsPerSquareMeter.
- ///
- public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter);
-
- ///
- /// Get Irradiance in WattsPerSquareMeter.
- ///
- public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter.
- ///
- public static Irradiance Zero => new Irradiance(0, BaseUnit);
-
- ///
- /// Get Irradiance from KilowattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Irradiance FromKilowattsPerSquareMeter(double kilowattspersquaremeter)
-#else
- public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter)
-#endif
- {
- double value = (double) kilowattspersquaremeter;
- return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter);
- }
-
- ///
- /// Get Irradiance from WattsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Irradiance FromWattsPerSquareMeter(double wattspersquaremeter)
-#else
- public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremeter)
-#endif
- {
- double value = (double) wattspersquaremeter;
- return new Irradiance(value, IrradianceUnit.WattPerSquareMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Irradiance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Irradiance From(double value, IrradianceUnit fromUnit)
-#else
- public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit)
-#endif
- {
- return new Irradiance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(IrradianceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Irradiance)) throw new ArgumentException("Expected type Irradiance.", nameof(obj));
-
- return CompareTo((Irradiance)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(Irradiance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Irradiance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Irradiance))
- return false;
-
- var objQuantity = (Irradiance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Irradiance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Irradiance 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.
- [Obsolete("Please use the Equals(Irradiance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Irradiance other, Irradiance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Irradiance.
- public override int GetHashCode()
- {
- return new { type = typeof(Irradiance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(IrradianceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Irradiance to another Irradiance with the unit representation .
- ///
- /// A Irradiance with the specified unit.
- public Irradiance ToUnit(IrradianceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Irradiance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case IrradianceUnit.KilowattPerSquareMeter: return (_value) * 1e3d;
- case IrradianceUnit.WattPerSquareMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(IrradianceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case IrradianceUnit.KilowattPerSquareMeter: return (baseUnitValue) / 1e3d;
- case IrradianceUnit.WattPerSquareMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Irradiance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Irradiance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static IrradianceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is WattPerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static IrradianceUnit ToStringDefaultUnit { get; set; } = IrradianceUnit.WattPerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(IrradianceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Irradiance
- ///
- public static Irradiance MaxValue => new Irradiance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Irradiance
- ///
- public static Irradiance MinValue => new Irradiance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Irradiance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Irradiance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Irradiation.Common.g.cs b/Common/GeneratedCode/Quantities/Irradiation.Common.g.cs
deleted file mode 100644
index f9f5dcd450..0000000000
--- a/Common/GeneratedCode/Quantities/Irradiation.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// 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 : IQuantity
-#else
- public partial struct Irradiation : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly IrradiationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public IrradiationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Irradiation()
- {
- BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Irradiation(double joulespersquaremeter)
- {
- _value = Convert.ToDouble(joulespersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Irradiation(double numericValue, IrradiationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerSquareMeter.
- ///
- /// Value assuming base unit JoulePerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Irradiation(long joulespersquaremeter) : this(Convert.ToDouble(joulespersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerSquareMeter.
- ///
- /// Value assuming base unit JoulePerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Irradiation(decimal joulespersquaremeter) : this(Convert.ToDouble(joulespersquaremeter), BaseUnit) { }
-
- #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 => IrradiationUnit.JoulePerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Irradiation quantity.
- ///
- public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().Except(new IrradiationUnit[]{ IrradiationUnit.Undefined }).ToArray();
-
- ///
- /// Get Irradiation in JoulesPerSquareMeter.
- ///
- public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter);
-
- ///
- /// Get Irradiation in KilowattHoursPerSquareMeter.
- ///
- public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter);
-
- ///
- /// Get Irradiation in WattHoursPerSquareMeter.
- ///
- public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerSquareMeter.
- ///
- public static Irradiation Zero => new Irradiation(0, BaseUnit);
-
- ///
- /// Get Irradiation from JoulesPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Irradiation FromJoulesPerSquareMeter(double joulespersquaremeter)
-#else
- public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquaremeter)
-#endif
- {
- double value = (double) joulespersquaremeter;
- return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter);
- }
-
- ///
- /// Get Irradiation from KilowattHoursPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Irradiation FromKilowattHoursPerSquareMeter(double kilowatthourspersquaremeter)
-#else
- public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatthourspersquaremeter)
-#endif
- {
- double value = (double) kilowatthourspersquaremeter;
- return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter);
- }
-
- ///
- /// Get Irradiation from WattHoursPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Irradiation FromWattHoursPerSquareMeter(double watthourspersquaremeter)
-#else
- public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthourspersquaremeter)
-#endif
- {
- double value = (double) watthourspersquaremeter;
- return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter);
- }
-
-
- ///
- /// 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
- {
- return new Irradiation((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(IrradiationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Irradiation)) throw new ArgumentException("Expected type Irradiation.", nameof(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 _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Irradiation, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Irradiation))
- return false;
-
- var objQuantity = (Irradiation)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Irradiation within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// 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.
- [Obsolete("Please use the Equals(Irradiation, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Irradiation other, Irradiation maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Irradiation.
- public override int GetHashCode()
- {
- return new { type = typeof(Irradiation), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(IrradiationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Irradiation to another Irradiation with the unit representation .
- ///
- /// A Irradiation with the specified unit.
- public Irradiation ToUnit(IrradiationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Irradiation(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case IrradiationUnit.JoulePerSquareMeter: return _value;
- case IrradiationUnit.KilowattHourPerSquareMeter: return (_value*3600d) * 1e3d;
- case IrradiationUnit.WattHourPerSquareMeter: return _value*3600d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(IrradiationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case IrradiationUnit.JoulePerSquareMeter: return baseUnitValue;
- case IrradiationUnit.KilowattHourPerSquareMeter: return (baseUnitValue/3600d) / 1e3d;
- case IrradiationUnit.WattHourPerSquareMeter: return baseUnitValue/3600d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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);
- }
-
- ///
- /// 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);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// 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);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static IrradiationUnit ToStringDefaultUnit { get; set; } = IrradiationUnit.JoulePerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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);
- }
-
- ///
- /// Represents the largest possible value of Irradiation
- ///
- public static Irradiation MaxValue => new Irradiation(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Irradiation
- ///
- public static Irradiation MinValue => new Irradiation(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Irradiation.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Irradiation.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/KinematicViscosity.Common.g.cs b/Common/GeneratedCode/Quantities/KinematicViscosity.Common.g.cs
deleted file mode 100644
index 76b96b9df4..0000000000
--- a/Common/GeneratedCode/Quantities/KinematicViscosity.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress.
- ///
- // 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 KinematicViscosity : IQuantity
-#else
- public partial struct KinematicViscosity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly KinematicViscosityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static KinematicViscosity()
- {
- BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit SquareMeterPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public KinematicViscosity(double squaremeterspersecond)
- {
- _value = Convert.ToDouble(squaremeterspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- KinematicViscosity(double numericValue, KinematicViscosityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeterPerSecond.
- ///
- /// Value assuming base unit SquareMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- KinematicViscosity(long squaremeterspersecond) : this(Convert.ToDouble(squaremeterspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeterPerSecond.
- ///
- /// Value assuming base unit SquareMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- KinematicViscosity(decimal squaremeterspersecond) : this(Convert.ToDouble(squaremeterspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.KinematicViscosity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static KinematicViscosityUnit BaseUnit => KinematicViscosityUnit.SquareMeterPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the KinematicViscosity quantity.
- ///
- public static KinematicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().Except(new KinematicViscosityUnit[]{ KinematicViscosityUnit.Undefined }).ToArray();
-
- ///
- /// Get KinematicViscosity in Centistokes.
- ///
- public double Centistokes => As(KinematicViscosityUnit.Centistokes);
-
- ///
- /// Get KinematicViscosity in Decistokes.
- ///
- public double Decistokes => As(KinematicViscosityUnit.Decistokes);
-
- ///
- /// Get KinematicViscosity in Kilostokes.
- ///
- public double Kilostokes => As(KinematicViscosityUnit.Kilostokes);
-
- ///
- /// Get KinematicViscosity in Microstokes.
- ///
- public double Microstokes => As(KinematicViscosityUnit.Microstokes);
-
- ///
- /// Get KinematicViscosity in Millistokes.
- ///
- public double Millistokes => As(KinematicViscosityUnit.Millistokes);
-
- ///
- /// Get KinematicViscosity in Nanostokes.
- ///
- public double Nanostokes => As(KinematicViscosityUnit.Nanostokes);
-
- ///
- /// Get KinematicViscosity in SquareMetersPerSecond.
- ///
- public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond);
-
- ///
- /// Get KinematicViscosity in Stokes.
- ///
- public double Stokes => As(KinematicViscosityUnit.Stokes);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterPerSecond.
- ///
- public static KinematicViscosity Zero => new KinematicViscosity(0, BaseUnit);
-
- ///
- /// Get KinematicViscosity from Centistokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromCentistokes(double centistokes)
-#else
- public static KinematicViscosity FromCentistokes(QuantityValue centistokes)
-#endif
- {
- double value = (double) centistokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes);
- }
-
- ///
- /// Get KinematicViscosity from Decistokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromDecistokes(double decistokes)
-#else
- public static KinematicViscosity FromDecistokes(QuantityValue decistokes)
-#endif
- {
- double value = (double) decistokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes);
- }
-
- ///
- /// Get KinematicViscosity from Kilostokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromKilostokes(double kilostokes)
-#else
- public static KinematicViscosity FromKilostokes(QuantityValue kilostokes)
-#endif
- {
- double value = (double) kilostokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes);
- }
-
- ///
- /// Get KinematicViscosity from Microstokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromMicrostokes(double microstokes)
-#else
- public static KinematicViscosity FromMicrostokes(QuantityValue microstokes)
-#endif
- {
- double value = (double) microstokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes);
- }
-
- ///
- /// Get KinematicViscosity from Millistokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromMillistokes(double millistokes)
-#else
- public static KinematicViscosity FromMillistokes(QuantityValue millistokes)
-#endif
- {
- double value = (double) millistokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes);
- }
-
- ///
- /// Get KinematicViscosity from Nanostokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromNanostokes(double nanostokes)
-#else
- public static KinematicViscosity FromNanostokes(QuantityValue nanostokes)
-#endif
- {
- double value = (double) nanostokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes);
- }
-
- ///
- /// Get KinematicViscosity from SquareMetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromSquareMetersPerSecond(double squaremeterspersecond)
-#else
- public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squaremeterspersecond)
-#endif
- {
- double value = (double) squaremeterspersecond;
- return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond);
- }
-
- ///
- /// Get KinematicViscosity from Stokes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static KinematicViscosity FromStokes(double stokes)
-#else
- public static KinematicViscosity FromStokes(QuantityValue stokes)
-#endif
- {
- double value = (double) stokes;
- return new KinematicViscosity(value, KinematicViscosityUnit.Stokes);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// KinematicViscosity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static KinematicViscosity From(double value, KinematicViscosityUnit fromUnit)
-#else
- public static KinematicViscosity From(QuantityValue value, KinematicViscosityUnit fromUnit)
-#endif
- {
- return new KinematicViscosity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(KinematicViscosityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is KinematicViscosity)) throw new ArgumentException("Expected type KinematicViscosity.", nameof(obj));
-
- return CompareTo((KinematicViscosity)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(KinematicViscosity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(KinematicViscosity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is KinematicViscosity))
- return false;
-
- var objQuantity = (KinematicViscosity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another KinematicViscosity 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.
- [Obsolete("Please use the Equals(KinematicViscosity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(KinematicViscosity other, KinematicViscosity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current KinematicViscosity.
- public override int GetHashCode()
- {
- return new { type = typeof(KinematicViscosity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(KinematicViscosityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation .
- ///
- /// A KinematicViscosity with the specified unit.
- public KinematicViscosity ToUnit(KinematicViscosityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new KinematicViscosity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case KinematicViscosityUnit.Centistokes: return (_value/1e4) * 1e-2d;
- case KinematicViscosityUnit.Decistokes: return (_value/1e4) * 1e-1d;
- case KinematicViscosityUnit.Kilostokes: return (_value/1e4) * 1e3d;
- case KinematicViscosityUnit.Microstokes: return (_value/1e4) * 1e-6d;
- case KinematicViscosityUnit.Millistokes: return (_value/1e4) * 1e-3d;
- case KinematicViscosityUnit.Nanostokes: return (_value/1e4) * 1e-9d;
- case KinematicViscosityUnit.SquareMeterPerSecond: return _value;
- case KinematicViscosityUnit.Stokes: return _value/1e4;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(KinematicViscosityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case KinematicViscosityUnit.Centistokes: return (baseUnitValue*1e4) / 1e-2d;
- case KinematicViscosityUnit.Decistokes: return (baseUnitValue*1e4) / 1e-1d;
- case KinematicViscosityUnit.Kilostokes: return (baseUnitValue*1e4) / 1e3d;
- case KinematicViscosityUnit.Microstokes: return (baseUnitValue*1e4) / 1e-6d;
- case KinematicViscosityUnit.Millistokes: return (baseUnitValue*1e4) / 1e-3d;
- case KinematicViscosityUnit.Nanostokes: return (baseUnitValue*1e4) / 1e-9d;
- case KinematicViscosityUnit.SquareMeterPerSecond: return baseUnitValue;
- case KinematicViscosityUnit.Stokes: return baseUnitValue*1e4;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 KinematicViscosity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 KinematicViscosity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static KinematicViscosityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is SquareMeterPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static KinematicViscosityUnit ToStringDefaultUnit { get; set; } = KinematicViscosityUnit.SquareMeterPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(KinematicViscosityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of KinematicViscosity
- ///
- public static KinematicViscosity MaxValue => new KinematicViscosity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of KinematicViscosity
- ///
- public static KinematicViscosity MinValue => new KinematicViscosity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => KinematicViscosity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => KinematicViscosity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/LapseRate.Common.g.cs b/Common/GeneratedCode/Quantities/LapseRate.Common.g.cs
deleted file mode 100644
index e305ba5321..0000000000
--- a/Common/GeneratedCode/Quantities/LapseRate.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 LapseRate : IQuantity
-#else
- public partial struct LapseRate : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LapseRateUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LapseRateUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static LapseRate()
- {
- BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit DegreeCelsiusPerKilometer.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public LapseRate(double degreescelciusperkilometer)
- {
- _value = Convert.ToDouble(degreescelciusperkilometer);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- LapseRate(double numericValue, LapseRateUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DegreeCelsiusPerKilometer.
- ///
- /// Value assuming base unit DegreeCelsiusPerKilometer.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LapseRate(long degreescelciusperkilometer) : this(Convert.ToDouble(degreescelciusperkilometer), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DegreeCelsiusPerKilometer.
- ///
- /// Value assuming base unit DegreeCelsiusPerKilometer.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LapseRate(decimal degreescelciusperkilometer) : this(Convert.ToDouble(degreescelciusperkilometer), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.LapseRate;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LapseRateUnit BaseUnit => LapseRateUnit.DegreeCelsiusPerKilometer;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the LapseRate quantity.
- ///
- public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().Except(new LapseRateUnit[]{ LapseRateUnit.Undefined }).ToArray();
-
- ///
- /// Get LapseRate in DegreesCelciusPerKilometer.
- ///
- public double DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer.
- ///
- public static LapseRate Zero => new LapseRate(0, BaseUnit);
-
- ///
- /// Get LapseRate from DegreesCelciusPerKilometer.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LapseRate FromDegreesCelciusPerKilometer(double degreescelciusperkilometer)
-#else
- public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer)
-#endif
- {
- double value = (double) degreescelciusperkilometer;
- return new LapseRate(value, LapseRateUnit.DegreeCelsiusPerKilometer);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// LapseRate unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static LapseRate From(double value, LapseRateUnit fromUnit)
-#else
- public static LapseRate From(QuantityValue value, LapseRateUnit fromUnit)
-#endif
- {
- return new LapseRate((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LapseRateUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is LapseRate)) throw new ArgumentException("Expected type LapseRate.", nameof(obj));
-
- return CompareTo((LapseRate)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(LapseRate other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(LapseRate, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is LapseRate))
- return false;
-
- var objQuantity = (LapseRate)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another LapseRate within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another LapseRate 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.
- [Obsolete("Please use the Equals(LapseRate, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(LapseRate other, LapseRate maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current LapseRate.
- public override int GetHashCode()
- {
- return new { type = typeof(LapseRate), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LapseRateUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this LapseRate to another LapseRate with the unit representation .
- ///
- /// A LapseRate with the specified unit.
- public LapseRate ToUnit(LapseRateUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new LapseRate(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LapseRateUnit.DegreeCelsiusPerKilometer: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LapseRateUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LapseRateUnit.DegreeCelsiusPerKilometer: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 LapseRate Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 LapseRate result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LapseRateUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is DegreeCelsiusPerKilometer
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LapseRateUnit ToStringDefaultUnit { get; set; } = LapseRateUnit.DegreeCelsiusPerKilometer;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LapseRateUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of LapseRate
- ///
- public static LapseRate MaxValue => new LapseRate(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of LapseRate
- ///
- public static LapseRate MinValue => new LapseRate(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => LapseRate.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => LapseRate.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Length.Common.g.cs b/Common/GeneratedCode/Quantities/Length.Common.g.cs
deleted file mode 100644
index c038a148a0..0000000000
--- a/Common/GeneratedCode/Quantities/Length.Common.g.cs
+++ /dev/null
@@ -1,931 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Length : IQuantity
-#else
- public partial struct Length : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LengthUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LengthUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Length()
- {
- BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Meter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Length(double meters)
- {
- _value = Convert.ToDouble(meters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Length(double numericValue, LengthUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Meter.
- ///
- /// Value assuming base unit Meter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Length(long meters) : this(Convert.ToDouble(meters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Meter.
- ///
- /// Value assuming base unit Meter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Length(decimal meters) : this(Convert.ToDouble(meters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Length;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LengthUnit BaseUnit => LengthUnit.Meter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Length quantity.
- ///
- public static LengthUnit[] Units { get; } = Enum.GetValues(typeof(LengthUnit)).Cast().Except(new LengthUnit[]{ LengthUnit.Undefined }).ToArray();
-
- ///
- /// Get Length in Centimeters.
- ///
- public double Centimeters => As(LengthUnit.Centimeter);
-
- ///
- /// Get Length in Decimeters.
- ///
- public double Decimeters => As(LengthUnit.Decimeter);
-
- ///
- /// Get Length in DtpPicas.
- ///
- public double DtpPicas => As(LengthUnit.DtpPica);
-
- ///
- /// Get Length in DtpPoints.
- ///
- public double DtpPoints => As(LengthUnit.DtpPoint);
-
- ///
- /// Get Length in Fathoms.
- ///
- public double Fathoms => As(LengthUnit.Fathom);
-
- ///
- /// Get Length in Feet.
- ///
- public double Feet => As(LengthUnit.Foot);
-
- ///
- /// Get Length in Inches.
- ///
- public double Inches => As(LengthUnit.Inch);
-
- ///
- /// Get Length in Kilometers.
- ///
- public double Kilometers => As(LengthUnit.Kilometer);
-
- ///
- /// Get Length in Meters.
- ///
- public double Meters => As(LengthUnit.Meter);
-
- ///
- /// Get Length in Microinches.
- ///
- public double Microinches => As(LengthUnit.Microinch);
-
- ///
- /// Get Length in Micrometers.
- ///
- public double Micrometers => As(LengthUnit.Micrometer);
-
- ///
- /// Get Length in Mils.
- ///
- public double Mils => As(LengthUnit.Mil);
-
- ///
- /// Get Length in Miles.
- ///
- public double Miles => As(LengthUnit.Mile);
-
- ///
- /// Get Length in Millimeters.
- ///
- public double Millimeters => As(LengthUnit.Millimeter);
-
- ///
- /// Get Length in Nanometers.
- ///
- public double Nanometers => As(LengthUnit.Nanometer);
-
- ///
- /// Get Length in NauticalMiles.
- ///
- public double NauticalMiles => As(LengthUnit.NauticalMile);
-
- ///
- /// Get Length in PrinterPicas.
- ///
- public double PrinterPicas => As(LengthUnit.PrinterPica);
-
- ///
- /// Get Length in PrinterPoints.
- ///
- public double PrinterPoints => As(LengthUnit.PrinterPoint);
-
- ///
- /// Get Length in Shackles.
- ///
- public double Shackles => As(LengthUnit.Shackle);
-
- ///
- /// Get Length in Twips.
- ///
- public double Twips => As(LengthUnit.Twip);
-
- ///
- /// Get Length in UsSurveyFeet.
- ///
- public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot);
-
- ///
- /// Get Length in Yards.
- ///
- public double Yards => As(LengthUnit.Yard);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Meter.
- ///
- public static Length Zero => new Length(0, BaseUnit);
-
- ///
- /// Get Length from Centimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromCentimeters(double centimeters)
-#else
- public static Length FromCentimeters(QuantityValue centimeters)
-#endif
- {
- double value = (double) centimeters;
- return new Length(value, LengthUnit.Centimeter);
- }
-
- ///
- /// Get Length from Decimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromDecimeters(double decimeters)
-#else
- public static Length FromDecimeters(QuantityValue decimeters)
-#endif
- {
- double value = (double) decimeters;
- return new Length(value, LengthUnit.Decimeter);
- }
-
- ///
- /// Get Length from DtpPicas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromDtpPicas(double dtppicas)
-#else
- public static Length FromDtpPicas(QuantityValue dtppicas)
-#endif
- {
- double value = (double) dtppicas;
- return new Length(value, LengthUnit.DtpPica);
- }
-
- ///
- /// Get Length from DtpPoints.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromDtpPoints(double dtppoints)
-#else
- public static Length FromDtpPoints(QuantityValue dtppoints)
-#endif
- {
- double value = (double) dtppoints;
- return new Length(value, LengthUnit.DtpPoint);
- }
-
- ///
- /// Get Length from Fathoms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromFathoms(double fathoms)
-#else
- public static Length FromFathoms(QuantityValue fathoms)
-#endif
- {
- double value = (double) fathoms;
- return new Length(value, LengthUnit.Fathom);
- }
-
- ///
- /// Get Length from Feet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromFeet(double feet)
-#else
- public static Length FromFeet(QuantityValue feet)
-#endif
- {
- double value = (double) feet;
- return new Length(value, LengthUnit.Foot);
- }
-
- ///
- /// Get Length from Inches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromInches(double inches)
-#else
- public static Length FromInches(QuantityValue inches)
-#endif
- {
- double value = (double) inches;
- return new Length(value, LengthUnit.Inch);
- }
-
- ///
- /// Get Length from Kilometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromKilometers(double kilometers)
-#else
- public static Length FromKilometers(QuantityValue kilometers)
-#endif
- {
- double value = (double) kilometers;
- return new Length(value, LengthUnit.Kilometer);
- }
-
- ///
- /// Get Length from Meters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMeters(double meters)
-#else
- public static Length FromMeters(QuantityValue meters)
-#endif
- {
- double value = (double) meters;
- return new Length(value, LengthUnit.Meter);
- }
-
- ///
- /// Get Length from Microinches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMicroinches(double microinches)
-#else
- public static Length FromMicroinches(QuantityValue microinches)
-#endif
- {
- double value = (double) microinches;
- return new Length(value, LengthUnit.Microinch);
- }
-
- ///
- /// Get Length from Micrometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMicrometers(double micrometers)
-#else
- public static Length FromMicrometers(QuantityValue micrometers)
-#endif
- {
- double value = (double) micrometers;
- return new Length(value, LengthUnit.Micrometer);
- }
-
- ///
- /// Get Length from Mils.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMils(double mils)
-#else
- public static Length FromMils(QuantityValue mils)
-#endif
- {
- double value = (double) mils;
- return new Length(value, LengthUnit.Mil);
- }
-
- ///
- /// Get Length from Miles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMiles(double miles)
-#else
- public static Length FromMiles(QuantityValue miles)
-#endif
- {
- double value = (double) miles;
- return new Length(value, LengthUnit.Mile);
- }
-
- ///
- /// Get Length from Millimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromMillimeters(double millimeters)
-#else
- public static Length FromMillimeters(QuantityValue millimeters)
-#endif
- {
- double value = (double) millimeters;
- return new Length(value, LengthUnit.Millimeter);
- }
-
- ///
- /// Get Length from Nanometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromNanometers(double nanometers)
-#else
- public static Length FromNanometers(QuantityValue nanometers)
-#endif
- {
- double value = (double) nanometers;
- return new Length(value, LengthUnit.Nanometer);
- }
-
- ///
- /// Get Length from NauticalMiles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromNauticalMiles(double nauticalmiles)
-#else
- public static Length FromNauticalMiles(QuantityValue nauticalmiles)
-#endif
- {
- double value = (double) nauticalmiles;
- return new Length(value, LengthUnit.NauticalMile);
- }
-
- ///
- /// Get Length from PrinterPicas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromPrinterPicas(double printerpicas)
-#else
- public static Length FromPrinterPicas(QuantityValue printerpicas)
-#endif
- {
- double value = (double) printerpicas;
- return new Length(value, LengthUnit.PrinterPica);
- }
-
- ///
- /// Get Length from PrinterPoints.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromPrinterPoints(double printerpoints)
-#else
- public static Length FromPrinterPoints(QuantityValue printerpoints)
-#endif
- {
- double value = (double) printerpoints;
- return new Length(value, LengthUnit.PrinterPoint);
- }
-
- ///
- /// Get Length from Shackles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromShackles(double shackles)
-#else
- public static Length FromShackles(QuantityValue shackles)
-#endif
- {
- double value = (double) shackles;
- return new Length(value, LengthUnit.Shackle);
- }
-
- ///
- /// Get Length from Twips.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromTwips(double twips)
-#else
- public static Length FromTwips(QuantityValue twips)
-#endif
- {
- double value = (double) twips;
- return new Length(value, LengthUnit.Twip);
- }
-
- ///
- /// Get Length from UsSurveyFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromUsSurveyFeet(double ussurveyfeet)
-#else
- public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet)
-#endif
- {
- double value = (double) ussurveyfeet;
- return new Length(value, LengthUnit.UsSurveyFoot);
- }
-
- ///
- /// Get Length from Yards.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Length FromYards(double yards)
-#else
- public static Length FromYards(QuantityValue yards)
-#endif
- {
- double value = (double) yards;
- return new Length(value, LengthUnit.Yard);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Length unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Length From(double value, LengthUnit fromUnit)
-#else
- public static Length From(QuantityValue value, LengthUnit fromUnit)
-#endif
- {
- return new Length((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LengthUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Length)) throw new ArgumentException("Expected type Length.", nameof(obj));
-
- return CompareTo((Length)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(Length other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Length, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Length))
- return false;
-
- var objQuantity = (Length)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Length within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Length other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Length 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.
- [Obsolete("Please use the Equals(Length, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Length other, Length maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Length.
- public override int GetHashCode()
- {
- return new { type = typeof(Length), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LengthUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Length to another Length with the unit representation .
- ///
- /// A Length with the specified unit.
- public Length ToUnit(LengthUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Length(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LengthUnit.Centimeter: return (_value) * 1e-2d;
- case LengthUnit.Decimeter: return (_value) * 1e-1d;
- case LengthUnit.DtpPica: return _value/236.220472441;
- case LengthUnit.DtpPoint: return (_value/72)*2.54e-2;
- case LengthUnit.Fathom: return _value*1.8288;
- case LengthUnit.Foot: return _value*0.3048;
- case LengthUnit.Inch: return _value*2.54e-2;
- case LengthUnit.Kilometer: return (_value) * 1e3d;
- case LengthUnit.Meter: return _value;
- case LengthUnit.Microinch: return _value*2.54e-8;
- case LengthUnit.Micrometer: return (_value) * 1e-6d;
- case LengthUnit.Mil: return _value*2.54e-5;
- case LengthUnit.Mile: return _value*1609.34;
- case LengthUnit.Millimeter: return (_value) * 1e-3d;
- case LengthUnit.Nanometer: return (_value) * 1e-9d;
- case LengthUnit.NauticalMile: return _value*1852;
- case LengthUnit.PrinterPica: return _value/237.106301584;
- case LengthUnit.PrinterPoint: return (_value/72.27)*2.54e-2;
- case LengthUnit.Shackle: return _value*27.432;
- case LengthUnit.Twip: return _value/56692.913385826;
- case LengthUnit.UsSurveyFoot: return _value*1200/3937;
- case LengthUnit.Yard: return _value*0.9144;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LengthUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LengthUnit.Centimeter: return (baseUnitValue) / 1e-2d;
- case LengthUnit.Decimeter: return (baseUnitValue) / 1e-1d;
- case LengthUnit.DtpPica: return baseUnitValue*236.220472441;
- case LengthUnit.DtpPoint: return (baseUnitValue/2.54e-2)*72;
- case LengthUnit.Fathom: return baseUnitValue/1.8288;
- case LengthUnit.Foot: return baseUnitValue/0.3048;
- case LengthUnit.Inch: return baseUnitValue/2.54e-2;
- case LengthUnit.Kilometer: return (baseUnitValue) / 1e3d;
- case LengthUnit.Meter: return baseUnitValue;
- case LengthUnit.Microinch: return baseUnitValue/2.54e-8;
- case LengthUnit.Micrometer: return (baseUnitValue) / 1e-6d;
- case LengthUnit.Mil: return baseUnitValue/2.54e-5;
- case LengthUnit.Mile: return baseUnitValue/1609.34;
- case LengthUnit.Millimeter: return (baseUnitValue) / 1e-3d;
- case LengthUnit.Nanometer: return (baseUnitValue) / 1e-9d;
- case LengthUnit.NauticalMile: return baseUnitValue/1852;
- case LengthUnit.PrinterPica: return baseUnitValue*237.106301584;
- case LengthUnit.PrinterPoint: return (baseUnitValue/2.54e-2)*72.27;
- case LengthUnit.Shackle: return baseUnitValue/27.432;
- case LengthUnit.Twip: return baseUnitValue*56692.913385826;
- case LengthUnit.UsSurveyFoot: return baseUnitValue*3937/1200;
- case LengthUnit.Yard: return baseUnitValue/0.9144;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Length Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Length result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LengthUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Meter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LengthUnit ToStringDefaultUnit { get; set; } = LengthUnit.Meter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LengthUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Length
- ///
- public static Length MaxValue => new Length(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Length
- ///
- public static Length MinValue => new Length(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Length.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Length.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Level.Common.g.cs b/Common/GeneratedCode/Quantities/Level.Common.g.cs
deleted file mode 100644
index 11d76a138d..0000000000
--- a/Common/GeneratedCode/Quantities/Level.Common.g.cs
+++ /dev/null
@@ -1,510 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 Level : IQuantity
-#else
- public partial struct Level : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LevelUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LevelUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Level()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Decibel.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Level(double decibels)
- {
- _value = Convert.ToDouble(decibels);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Level(double numericValue, LevelUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Decibel.
- ///
- /// Value assuming base unit Decibel.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Level(long decibels) : this(Convert.ToDouble(decibels), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Decibel.
- ///
- /// Value assuming base unit Decibel.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Level(decimal decibels) : this(Convert.ToDouble(decibels), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Level;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LevelUnit BaseUnit => LevelUnit.Decibel;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Level quantity.
- ///
- public static LevelUnit[] Units { get; } = Enum.GetValues(typeof(LevelUnit)).Cast().Except(new LevelUnit[]{ LevelUnit.Undefined }).ToArray();
-
- ///
- /// Get Level in Decibels.
- ///
- public double Decibels => As(LevelUnit.Decibel);
-
- ///
- /// Get Level in Nepers.
- ///
- public double Nepers => As(LevelUnit.Neper);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Decibel.
- ///
- public static Level Zero => new Level(0, BaseUnit);
-
- ///
- /// Get Level from Decibels.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Level FromDecibels(double decibels)
-#else
- public static Level FromDecibels(QuantityValue decibels)
-#endif
- {
- double value = (double) decibels;
- return new Level(value, LevelUnit.Decibel);
- }
-
- ///
- /// Get Level from Nepers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Level FromNepers(double nepers)
-#else
- public static Level FromNepers(QuantityValue nepers)
-#endif
- {
- double value = (double) nepers;
- return new Level(value, LevelUnit.Neper);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Level unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Level From(double value, LevelUnit fromUnit)
-#else
- public static Level From(QuantityValue value, LevelUnit fromUnit)
-#endif
- {
- return new Level((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LevelUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Level)) throw new ArgumentException("Expected type Level.", nameof(obj));
-
- return CompareTo((Level)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(Level other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Level, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Level))
- return false;
-
- var objQuantity = (Level)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Level within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Level other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Level 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.
- [Obsolete("Please use the Equals(Level, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Level other, Level maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Level.
- public override int GetHashCode()
- {
- return new { type = typeof(Level), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LevelUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Level to another Level with the unit representation .
- ///
- /// A Level with the specified unit.
- public Level ToUnit(LevelUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Level(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LevelUnit.Decibel: return _value;
- case LevelUnit.Neper: return (1/0.115129254)*_value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LevelUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LevelUnit.Decibel: return baseUnitValue;
- case LevelUnit.Neper: return 0.115129254*baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Level Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Level result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LevelUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Decibel
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LevelUnit ToStringDefaultUnit { get; set; } = LevelUnit.Decibel;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LevelUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Level
- ///
- public static Level MaxValue => new Level(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Level
- ///
- public static Level MinValue => new Level(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Level.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Level.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/LinearDensity.Common.g.cs b/Common/GeneratedCode/Quantities/LinearDensity.Common.g.cs
deleted file mode 100644
index db00a79a9a..0000000000
--- a/Common/GeneratedCode/Quantities/LinearDensity.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.
- ///
- // 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 LinearDensity : IQuantity
-#else
- public partial struct LinearDensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LinearDensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LinearDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static LinearDensity()
- {
- BaseDimensions = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public LinearDensity(double kilogramspermeter)
- {
- _value = Convert.ToDouble(kilogramspermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- LinearDensity(double numericValue, LinearDensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerMeter.
- ///
- /// Value assuming base unit KilogramPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LinearDensity(long kilogramspermeter) : this(Convert.ToDouble(kilogramspermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerMeter.
- ///
- /// Value assuming base unit KilogramPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LinearDensity(decimal kilogramspermeter) : this(Convert.ToDouble(kilogramspermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.LinearDensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LinearDensityUnit BaseUnit => LinearDensityUnit.KilogramPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the LinearDensity quantity.
- ///
- public static LinearDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearDensityUnit)).Cast().Except(new LinearDensityUnit[]{ LinearDensityUnit.Undefined }).ToArray();
-
- ///
- /// Get LinearDensity in GramsPerMeter.
- ///
- public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter);
-
- ///
- /// Get LinearDensity in KilogramsPerMeter.
- ///
- public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter);
-
- ///
- /// Get LinearDensity in PoundsPerFoot.
- ///
- public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMeter.
- ///
- public static LinearDensity Zero => new LinearDensity(0, BaseUnit);
-
- ///
- /// Get LinearDensity from GramsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LinearDensity FromGramsPerMeter(double gramspermeter)
-#else
- public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter)
-#endif
- {
- double value = (double) gramspermeter;
- return new LinearDensity(value, LinearDensityUnit.GramPerMeter);
- }
-
- ///
- /// Get LinearDensity from KilogramsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LinearDensity FromKilogramsPerMeter(double kilogramspermeter)
-#else
- public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermeter)
-#endif
- {
- double value = (double) kilogramspermeter;
- return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter);
- }
-
- ///
- /// Get LinearDensity from PoundsPerFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LinearDensity FromPoundsPerFoot(double poundsperfoot)
-#else
- public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot)
-#endif
- {
- double value = (double) poundsperfoot;
- return new LinearDensity(value, LinearDensityUnit.PoundPerFoot);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// LinearDensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static LinearDensity From(double value, LinearDensityUnit fromUnit)
-#else
- public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit)
-#endif
- {
- return new LinearDensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LinearDensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is LinearDensity)) throw new ArgumentException("Expected type LinearDensity.", nameof(obj));
-
- return CompareTo((LinearDensity)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(LinearDensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(LinearDensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is LinearDensity))
- return false;
-
- var objQuantity = (LinearDensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another LinearDensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another LinearDensity 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.
- [Obsolete("Please use the Equals(LinearDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(LinearDensity other, LinearDensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current LinearDensity.
- public override int GetHashCode()
- {
- return new { type = typeof(LinearDensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LinearDensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this LinearDensity to another LinearDensity with the unit representation .
- ///
- /// A LinearDensity with the specified unit.
- public LinearDensity ToUnit(LinearDensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new LinearDensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LinearDensityUnit.GramPerMeter: return _value*1e-3;
- case LinearDensityUnit.KilogramPerMeter: return (_value*1e-3) * 1e3d;
- case LinearDensityUnit.PoundPerFoot: return _value*1.48816394;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LinearDensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LinearDensityUnit.GramPerMeter: return baseUnitValue/1e-3;
- case LinearDensityUnit.KilogramPerMeter: return (baseUnitValue/1e-3) / 1e3d;
- case LinearDensityUnit.PoundPerFoot: return baseUnitValue/1.48816394;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 LinearDensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 LinearDensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LinearDensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LinearDensityUnit ToStringDefaultUnit { get; set; } = LinearDensityUnit.KilogramPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LinearDensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of LinearDensity
- ///
- public static LinearDensity MaxValue => new LinearDensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of LinearDensity
- ///
- public static LinearDensity MinValue => new LinearDensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => LinearDensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => LinearDensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/LuminousFlux.Common.g.cs b/Common/GeneratedCode/Quantities/LuminousFlux.Common.g.cs
deleted file mode 100644
index 231b16e213..0000000000
--- a/Common/GeneratedCode/Quantities/LuminousFlux.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In photometry, luminous flux or luminous power is the measure of the perceived power of light.
- ///
- // 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 LuminousFlux : IQuantity
-#else
- public partial struct LuminousFlux : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LuminousFluxUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LuminousFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static LuminousFlux()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Lumen.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public LuminousFlux(double lumens)
- {
- _value = Convert.ToDouble(lumens);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- LuminousFlux(double numericValue, LuminousFluxUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Lumen.
- ///
- /// Value assuming base unit Lumen.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LuminousFlux(long lumens) : this(Convert.ToDouble(lumens), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Lumen.
- ///
- /// Value assuming base unit Lumen.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LuminousFlux(decimal lumens) : this(Convert.ToDouble(lumens), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.LuminousFlux;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LuminousFluxUnit BaseUnit => LuminousFluxUnit.Lumen;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the LuminousFlux quantity.
- ///
- public static LuminousFluxUnit[] Units { get; } = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().Except(new LuminousFluxUnit[]{ LuminousFluxUnit.Undefined }).ToArray();
-
- ///
- /// Get LuminousFlux in Lumens.
- ///
- public double Lumens => As(LuminousFluxUnit.Lumen);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Lumen.
- ///
- public static LuminousFlux Zero => new LuminousFlux(0, BaseUnit);
-
- ///
- /// Get LuminousFlux from Lumens.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LuminousFlux FromLumens(double lumens)
-#else
- public static LuminousFlux FromLumens(QuantityValue lumens)
-#endif
- {
- double value = (double) lumens;
- return new LuminousFlux(value, LuminousFluxUnit.Lumen);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// LuminousFlux unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static LuminousFlux From(double value, LuminousFluxUnit fromUnit)
-#else
- public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit)
-#endif
- {
- return new LuminousFlux((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LuminousFluxUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is LuminousFlux)) throw new ArgumentException("Expected type LuminousFlux.", nameof(obj));
-
- return CompareTo((LuminousFlux)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(LuminousFlux other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(LuminousFlux, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is LuminousFlux))
- return false;
-
- var objQuantity = (LuminousFlux)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another LuminousFlux within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another LuminousFlux 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.
- [Obsolete("Please use the Equals(LuminousFlux, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(LuminousFlux other, LuminousFlux maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current LuminousFlux.
- public override int GetHashCode()
- {
- return new { type = typeof(LuminousFlux), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LuminousFluxUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this LuminousFlux to another LuminousFlux with the unit representation .
- ///
- /// A LuminousFlux with the specified unit.
- public LuminousFlux ToUnit(LuminousFluxUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new LuminousFlux(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LuminousFluxUnit.Lumen: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LuminousFluxUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LuminousFluxUnit.Lumen: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 LuminousFlux Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 LuminousFlux result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LuminousFluxUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Lumen
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LuminousFluxUnit ToStringDefaultUnit { get; set; } = LuminousFluxUnit.Lumen;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LuminousFluxUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of LuminousFlux
- ///
- public static LuminousFlux MaxValue => new LuminousFlux(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of LuminousFlux
- ///
- public static LuminousFlux MinValue => new LuminousFlux(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => LuminousFlux.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => LuminousFlux.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/LuminousIntensity.Common.g.cs b/Common/GeneratedCode/Quantities/LuminousIntensity.Common.g.cs
deleted file mode 100644
index 5e090cb729..0000000000
--- a/Common/GeneratedCode/Quantities/LuminousIntensity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye.
- ///
- // 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 LuminousIntensity : IQuantity
-#else
- public partial struct LuminousIntensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly LuminousIntensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static LuminousIntensity()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Candela.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public LuminousIntensity(double candela)
- {
- _value = Convert.ToDouble(candela);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- LuminousIntensity(double numericValue, LuminousIntensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Candela.
- ///
- /// Value assuming base unit Candela.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LuminousIntensity(long candela) : this(Convert.ToDouble(candela), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Candela.
- ///
- /// Value assuming base unit Candela.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- LuminousIntensity(decimal candela) : this(Convert.ToDouble(candela), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.LuminousIntensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static LuminousIntensityUnit BaseUnit => LuminousIntensityUnit.Candela;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the LuminousIntensity quantity.
- ///
- public static LuminousIntensityUnit[] Units { get; } = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().Except(new LuminousIntensityUnit[]{ LuminousIntensityUnit.Undefined }).ToArray();
-
- ///
- /// Get LuminousIntensity in Candela.
- ///
- public double Candela => As(LuminousIntensityUnit.Candela);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Candela.
- ///
- public static LuminousIntensity Zero => new LuminousIntensity(0, BaseUnit);
-
- ///
- /// Get LuminousIntensity from Candela.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static LuminousIntensity FromCandela(double candela)
-#else
- public static LuminousIntensity FromCandela(QuantityValue candela)
-#endif
- {
- double value = (double) candela;
- return new LuminousIntensity(value, LuminousIntensityUnit.Candela);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// LuminousIntensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static LuminousIntensity From(double value, LuminousIntensityUnit fromUnit)
-#else
- public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit fromUnit)
-#endif
- {
- return new LuminousIntensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(LuminousIntensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is LuminousIntensity)) throw new ArgumentException("Expected type LuminousIntensity.", nameof(obj));
-
- return CompareTo((LuminousIntensity)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(LuminousIntensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(LuminousIntensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is LuminousIntensity))
- return false;
-
- var objQuantity = (LuminousIntensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another LuminousIntensity 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.
- [Obsolete("Please use the Equals(LuminousIntensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(LuminousIntensity other, LuminousIntensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current LuminousIntensity.
- public override int GetHashCode()
- {
- return new { type = typeof(LuminousIntensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(LuminousIntensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation .
- ///
- /// A LuminousIntensity with the specified unit.
- public LuminousIntensity ToUnit(LuminousIntensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new LuminousIntensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case LuminousIntensityUnit.Candela: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(LuminousIntensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case LuminousIntensityUnit.Candela: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 LuminousIntensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 LuminousIntensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static LuminousIntensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Candela
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static LuminousIntensityUnit ToStringDefaultUnit { get; set; } = LuminousIntensityUnit.Candela;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(LuminousIntensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of LuminousIntensity
- ///
- public static LuminousIntensity MaxValue => new LuminousIntensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of LuminousIntensity
- ///
- public static LuminousIntensity MinValue => new LuminousIntensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => LuminousIntensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => LuminousIntensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MagneticField.Common.g.cs b/Common/GeneratedCode/Quantities/MagneticField.Common.g.cs
deleted file mode 100644
index 90c00171c9..0000000000
--- a/Common/GeneratedCode/Quantities/MagneticField.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles.
- ///
- // 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 MagneticField : IQuantity
-#else
- public partial struct MagneticField : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MagneticFieldUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MagneticFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MagneticField()
- {
- BaseDimensions = new BaseDimensions(0, 1, -2, -1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Tesla.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MagneticField(double teslas)
- {
- _value = Convert.ToDouble(teslas);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MagneticField(double numericValue, MagneticFieldUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Tesla.
- ///
- /// Value assuming base unit Tesla.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MagneticField(long teslas) : this(Convert.ToDouble(teslas), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Tesla.
- ///
- /// Value assuming base unit Tesla.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MagneticField(decimal teslas) : this(Convert.ToDouble(teslas), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MagneticField;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MagneticFieldUnit BaseUnit => MagneticFieldUnit.Tesla;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MagneticField quantity.
- ///
- public static MagneticFieldUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().Except(new MagneticFieldUnit[]{ MagneticFieldUnit.Undefined }).ToArray();
-
- ///
- /// Get MagneticField in Microteslas.
- ///
- public double Microteslas => As(MagneticFieldUnit.Microtesla);
-
- ///
- /// Get MagneticField in Milliteslas.
- ///
- public double Milliteslas => As(MagneticFieldUnit.Millitesla);
-
- ///
- /// Get MagneticField in Nanoteslas.
- ///
- public double Nanoteslas => As(MagneticFieldUnit.Nanotesla);
-
- ///
- /// Get MagneticField in Teslas.
- ///
- public double Teslas => As(MagneticFieldUnit.Tesla);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Tesla.
- ///
- public static MagneticField Zero => new MagneticField(0, BaseUnit);
-
- ///
- /// Get MagneticField from Microteslas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MagneticField FromMicroteslas(double microteslas)
-#else
- public static MagneticField FromMicroteslas(QuantityValue microteslas)
-#endif
- {
- double value = (double) microteslas;
- return new MagneticField(value, MagneticFieldUnit.Microtesla);
- }
-
- ///
- /// Get MagneticField from Milliteslas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MagneticField FromMilliteslas(double milliteslas)
-#else
- public static MagneticField FromMilliteslas(QuantityValue milliteslas)
-#endif
- {
- double value = (double) milliteslas;
- return new MagneticField(value, MagneticFieldUnit.Millitesla);
- }
-
- ///
- /// Get MagneticField from Nanoteslas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MagneticField FromNanoteslas(double nanoteslas)
-#else
- public static MagneticField FromNanoteslas(QuantityValue nanoteslas)
-#endif
- {
- double value = (double) nanoteslas;
- return new MagneticField(value, MagneticFieldUnit.Nanotesla);
- }
-
- ///
- /// Get MagneticField from Teslas.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MagneticField FromTeslas(double teslas)
-#else
- public static MagneticField FromTeslas(QuantityValue teslas)
-#endif
- {
- double value = (double) teslas;
- return new MagneticField(value, MagneticFieldUnit.Tesla);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MagneticField unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MagneticField From(double value, MagneticFieldUnit fromUnit)
-#else
- public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit)
-#endif
- {
- return new MagneticField((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MagneticFieldUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MagneticField)) throw new ArgumentException("Expected type MagneticField.", nameof(obj));
-
- return CompareTo((MagneticField)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(MagneticField other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MagneticField, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MagneticField))
- return false;
-
- var objQuantity = (MagneticField)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MagneticField within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MagneticField 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.
- [Obsolete("Please use the Equals(MagneticField, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MagneticField other, MagneticField maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MagneticField.
- public override int GetHashCode()
- {
- return new { type = typeof(MagneticField), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MagneticFieldUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MagneticField to another MagneticField with the unit representation .
- ///
- /// A MagneticField with the specified unit.
- public MagneticField ToUnit(MagneticFieldUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MagneticField(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MagneticFieldUnit.Microtesla: return (_value) * 1e-6d;
- case MagneticFieldUnit.Millitesla: return (_value) * 1e-3d;
- case MagneticFieldUnit.Nanotesla: return (_value) * 1e-9d;
- case MagneticFieldUnit.Tesla: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MagneticFieldUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MagneticFieldUnit.Microtesla: return (baseUnitValue) / 1e-6d;
- case MagneticFieldUnit.Millitesla: return (baseUnitValue) / 1e-3d;
- case MagneticFieldUnit.Nanotesla: return (baseUnitValue) / 1e-9d;
- case MagneticFieldUnit.Tesla: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MagneticField Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MagneticField result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MagneticFieldUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Tesla
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MagneticFieldUnit ToStringDefaultUnit { get; set; } = MagneticFieldUnit.Tesla;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MagneticFieldUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MagneticField
- ///
- public static MagneticField MaxValue => new MagneticField(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MagneticField
- ///
- public static MagneticField MinValue => new MagneticField(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MagneticField.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MagneticField.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MagneticFlux.Common.g.cs b/Common/GeneratedCode/Quantities/MagneticFlux.Common.g.cs
deleted file mode 100644
index 11743f090b..0000000000
--- a/Common/GeneratedCode/Quantities/MagneticFlux.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface.
- ///
- // 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 MagneticFlux : IQuantity
-#else
- public partial struct MagneticFlux : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MagneticFluxUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MagneticFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MagneticFlux()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, -1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Weber.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MagneticFlux(double webers)
- {
- _value = Convert.ToDouble(webers);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MagneticFlux(double numericValue, MagneticFluxUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Weber.
- ///
- /// Value assuming base unit Weber.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MagneticFlux(long webers) : this(Convert.ToDouble(webers), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Weber.
- ///
- /// Value assuming base unit Weber.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MagneticFlux(decimal webers) : this(Convert.ToDouble(webers), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MagneticFlux;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MagneticFluxUnit BaseUnit => MagneticFluxUnit.Weber;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MagneticFlux quantity.
- ///
- public static MagneticFluxUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().Except(new MagneticFluxUnit[]{ MagneticFluxUnit.Undefined }).ToArray();
-
- ///
- /// Get MagneticFlux in Webers.
- ///
- public double Webers => As(MagneticFluxUnit.Weber);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Weber.
- ///
- public static MagneticFlux Zero => new MagneticFlux(0, BaseUnit);
-
- ///
- /// Get MagneticFlux from Webers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MagneticFlux FromWebers(double webers)
-#else
- public static MagneticFlux FromWebers(QuantityValue webers)
-#endif
- {
- double value = (double) webers;
- return new MagneticFlux(value, MagneticFluxUnit.Weber);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MagneticFlux unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MagneticFlux From(double value, MagneticFluxUnit fromUnit)
-#else
- public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit)
-#endif
- {
- return new MagneticFlux((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MagneticFluxUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MagneticFlux)) throw new ArgumentException("Expected type MagneticFlux.", nameof(obj));
-
- return CompareTo((MagneticFlux)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(MagneticFlux other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MagneticFlux, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MagneticFlux))
- return false;
-
- var objQuantity = (MagneticFlux)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MagneticFlux within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MagneticFlux 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.
- [Obsolete("Please use the Equals(MagneticFlux, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MagneticFlux other, MagneticFlux maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MagneticFlux.
- public override int GetHashCode()
- {
- return new { type = typeof(MagneticFlux), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MagneticFluxUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MagneticFlux to another MagneticFlux with the unit representation .
- ///
- /// A MagneticFlux with the specified unit.
- public MagneticFlux ToUnit(MagneticFluxUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MagneticFlux(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MagneticFluxUnit.Weber: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MagneticFluxUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MagneticFluxUnit.Weber: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MagneticFlux Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MagneticFlux result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MagneticFluxUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Weber
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MagneticFluxUnit ToStringDefaultUnit { get; set; } = MagneticFluxUnit.Weber;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MagneticFluxUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MagneticFlux
- ///
- public static MagneticFlux MaxValue => new MagneticFlux(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MagneticFlux
- ///
- public static MagneticFlux MinValue => new MagneticFlux(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MagneticFlux.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MagneticFlux.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Magnetization.Common.g.cs b/Common/GeneratedCode/Quantities/Magnetization.Common.g.cs
deleted file mode 100644
index 2f0c772afa..0000000000
--- a/Common/GeneratedCode/Quantities/Magnetization.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material.
- ///
- // 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 Magnetization : IQuantity
-#else
- public partial struct Magnetization : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MagnetizationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MagnetizationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Magnetization()
- {
- BaseDimensions = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit AmperePerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Magnetization(double amperespermeter)
- {
- _value = Convert.ToDouble(amperespermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Magnetization(double numericValue, MagnetizationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerMeter.
- ///
- /// Value assuming base unit AmperePerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Magnetization(long amperespermeter) : this(Convert.ToDouble(amperespermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit AmperePerMeter.
- ///
- /// Value assuming base unit AmperePerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Magnetization(decimal amperespermeter) : this(Convert.ToDouble(amperespermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Magnetization;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MagnetizationUnit BaseUnit => MagnetizationUnit.AmperePerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Magnetization quantity.
- ///
- public static MagnetizationUnit[] Units { get; } = Enum.GetValues(typeof(MagnetizationUnit)).Cast().Except(new MagnetizationUnit[]{ MagnetizationUnit.Undefined }).ToArray();
-
- ///
- /// Get Magnetization in AmperesPerMeter.
- ///
- public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerMeter.
- ///
- public static Magnetization Zero => new Magnetization(0, BaseUnit);
-
- ///
- /// Get Magnetization from AmperesPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Magnetization FromAmperesPerMeter(double amperespermeter)
-#else
- public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter)
-#endif
- {
- double value = (double) amperespermeter;
- return new Magnetization(value, MagnetizationUnit.AmperePerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Magnetization unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Magnetization From(double value, MagnetizationUnit fromUnit)
-#else
- public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit)
-#endif
- {
- return new Magnetization((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MagnetizationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Magnetization)) throw new ArgumentException("Expected type Magnetization.", nameof(obj));
-
- return CompareTo((Magnetization)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(Magnetization other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Magnetization, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Magnetization))
- return false;
-
- var objQuantity = (Magnetization)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Magnetization within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Magnetization 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.
- [Obsolete("Please use the Equals(Magnetization, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Magnetization other, Magnetization maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Magnetization.
- public override int GetHashCode()
- {
- return new { type = typeof(Magnetization), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MagnetizationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Magnetization to another Magnetization with the unit representation .
- ///
- /// A Magnetization with the specified unit.
- public Magnetization ToUnit(MagnetizationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Magnetization(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MagnetizationUnit.AmperePerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MagnetizationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MagnetizationUnit.AmperePerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Magnetization Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Magnetization result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MagnetizationUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is AmperePerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MagnetizationUnit ToStringDefaultUnit { get; set; } = MagnetizationUnit.AmperePerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MagnetizationUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Magnetization
- ///
- public static Magnetization MaxValue => new Magnetization(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Magnetization
- ///
- public static Magnetization MinValue => new Magnetization(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Magnetization.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Magnetization.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Mass.Common.g.cs b/Common/GeneratedCode/Quantities/Mass.Common.g.cs
deleted file mode 100644
index 065a1a94b6..0000000000
--- a/Common/GeneratedCode/Quantities/Mass.Common.g.cs
+++ /dev/null
@@ -1,931 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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).
- ///
- // 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 Mass : IQuantity
-#else
- public partial struct Mass : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MassUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MassUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Mass()
- {
- BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Kilogram.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Mass(double kilograms)
- {
- _value = Convert.ToDouble(kilograms);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Mass(double numericValue, MassUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kilogram.
- ///
- /// Value assuming base unit Kilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Mass(long kilograms) : this(Convert.ToDouble(kilograms), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kilogram.
- ///
- /// Value assuming base unit Kilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Mass(decimal kilograms) : this(Convert.ToDouble(kilograms), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Mass;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MassUnit BaseUnit => MassUnit.Kilogram;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Mass quantity.
- ///
- public static MassUnit[] Units { get; } = Enum.GetValues(typeof(MassUnit)).Cast().Except(new MassUnit[]{ MassUnit.Undefined }).ToArray();
-
- ///
- /// Get Mass in Centigrams.
- ///
- public double Centigrams => As(MassUnit.Centigram);
-
- ///
- /// Get Mass in Decagrams.
- ///
- public double Decagrams => As(MassUnit.Decagram);
-
- ///
- /// Get Mass in Decigrams.
- ///
- public double Decigrams => As(MassUnit.Decigram);
-
- ///
- /// Get Mass in Grams.
- ///
- public double Grams => As(MassUnit.Gram);
-
- ///
- /// Get Mass in Hectograms.
- ///
- public double Hectograms => As(MassUnit.Hectogram);
-
- ///
- /// Get Mass in Kilograms.
- ///
- public double Kilograms => As(MassUnit.Kilogram);
-
- ///
- /// Get Mass in Kilopounds.
- ///
- public double Kilopounds => As(MassUnit.Kilopound);
-
- ///
- /// Get Mass in Kilotonnes.
- ///
- public double Kilotonnes => As(MassUnit.Kilotonne);
-
- ///
- /// Get Mass in LongHundredweight.
- ///
- public double LongHundredweight => As(MassUnit.LongHundredweight);
-
- ///
- /// Get Mass in LongTons.
- ///
- public double LongTons => As(MassUnit.LongTon);
-
- ///
- /// Get Mass in Megapounds.
- ///
- public double Megapounds => As(MassUnit.Megapound);
-
- ///
- /// Get Mass in Megatonnes.
- ///
- public double Megatonnes => As(MassUnit.Megatonne);
-
- ///
- /// Get Mass in Micrograms.
- ///
- public double Micrograms => As(MassUnit.Microgram);
-
- ///
- /// Get Mass in Milligrams.
- ///
- public double Milligrams => As(MassUnit.Milligram);
-
- ///
- /// Get Mass in Nanograms.
- ///
- public double Nanograms => As(MassUnit.Nanogram);
-
- ///
- /// Get Mass in Ounces.
- ///
- public double Ounces => As(MassUnit.Ounce);
-
- ///
- /// Get Mass in Pounds.
- ///
- public double Pounds => As(MassUnit.Pound);
-
- ///
- /// Get Mass in ShortHundredweight.
- ///
- public double ShortHundredweight => As(MassUnit.ShortHundredweight);
-
- ///
- /// Get Mass in ShortTons.
- ///
- public double ShortTons => As(MassUnit.ShortTon);
-
- ///
- /// Get Mass in Slugs.
- ///
- public double Slugs => As(MassUnit.Slug);
-
- ///
- /// Get Mass in Stone.
- ///
- public double Stone => As(MassUnit.Stone);
-
- ///
- /// Get Mass in Tonnes.
- ///
- public double Tonnes => As(MassUnit.Tonne);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Kilogram.
- ///
- public static Mass Zero => new Mass(0, BaseUnit);
-
- ///
- /// Get Mass from Centigrams.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromCentigrams(double centigrams)
-#else
- public static Mass FromCentigrams(QuantityValue centigrams)
-#endif
- {
- double value = (double) centigrams;
- return new Mass(value, MassUnit.Centigram);
- }
-
- ///
- /// Get Mass from Decagrams.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromDecagrams(double decagrams)
-#else
- public static Mass FromDecagrams(QuantityValue decagrams)
-#endif
- {
- double value = (double) decagrams;
- return new Mass(value, MassUnit.Decagram);
- }
-
- ///
- /// Get Mass from Decigrams.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromDecigrams(double decigrams)
-#else
- public static Mass FromDecigrams(QuantityValue decigrams)
-#endif
- {
- double value = (double) decigrams;
- return new Mass(value, MassUnit.Decigram);
- }
-
- ///
- /// Get Mass from Grams.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromGrams(double grams)
-#else
- public static Mass FromGrams(QuantityValue grams)
-#endif
- {
- double value = (double) grams;
- return new Mass(value, MassUnit.Gram);
- }
-
- ///
- /// Get Mass from Hectograms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromHectograms(double hectograms)
-#else
- public static Mass FromHectograms(QuantityValue hectograms)
-#endif
- {
- double value = (double) hectograms;
- return new Mass(value, MassUnit.Hectogram);
- }
-
- ///
- /// Get Mass from Kilograms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromKilograms(double kilograms)
-#else
- public static Mass FromKilograms(QuantityValue kilograms)
-#endif
- {
- double value = (double) kilograms;
- return new Mass(value, MassUnit.Kilogram);
- }
-
- ///
- /// Get Mass from Kilopounds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromKilopounds(double kilopounds)
-#else
- public static Mass FromKilopounds(QuantityValue kilopounds)
-#endif
- {
- double value = (double) kilopounds;
- return new Mass(value, MassUnit.Kilopound);
- }
-
- ///
- /// Get Mass from Kilotonnes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromKilotonnes(double kilotonnes)
-#else
- public static Mass FromKilotonnes(QuantityValue kilotonnes)
-#endif
- {
- double value = (double) kilotonnes;
- return new Mass(value, MassUnit.Kilotonne);
- }
-
- ///
- /// Get Mass from LongHundredweight.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromLongHundredweight(double longhundredweight)
-#else
- public static Mass FromLongHundredweight(QuantityValue longhundredweight)
-#endif
- {
- double value = (double) longhundredweight;
- return new Mass(value, MassUnit.LongHundredweight);
- }
-
- ///
- /// Get Mass from LongTons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromLongTons(double longtons)
-#else
- public static Mass FromLongTons(QuantityValue longtons)
-#endif
- {
- double value = (double) longtons;
- return new Mass(value, MassUnit.LongTon);
- }
-
- ///
- /// Get Mass from Megapounds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromMegapounds(double megapounds)
-#else
- public static Mass FromMegapounds(QuantityValue megapounds)
-#endif
- {
- double value = (double) megapounds;
- return new Mass(value, MassUnit.Megapound);
- }
-
- ///
- /// Get Mass from Megatonnes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromMegatonnes(double megatonnes)
-#else
- public static Mass FromMegatonnes(QuantityValue megatonnes)
-#endif
- {
- double value = (double) megatonnes;
- return new Mass(value, MassUnit.Megatonne);
- }
-
- ///
- /// Get Mass from Micrograms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromMicrograms(double micrograms)
-#else
- public static Mass FromMicrograms(QuantityValue micrograms)
-#endif
- {
- double value = (double) micrograms;
- return new Mass(value, MassUnit.Microgram);
- }
-
- ///
- /// Get Mass from Milligrams.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromMilligrams(double milligrams)
-#else
- public static Mass FromMilligrams(QuantityValue milligrams)
-#endif
- {
- double value = (double) milligrams;
- return new Mass(value, MassUnit.Milligram);
- }
-
- ///
- /// Get Mass from Nanograms.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromNanograms(double nanograms)
-#else
- public static Mass FromNanograms(QuantityValue nanograms)
-#endif
- {
- double value = (double) nanograms;
- return new Mass(value, MassUnit.Nanogram);
- }
-
- ///
- /// Get Mass from Ounces.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromOunces(double ounces)
-#else
- public static Mass FromOunces(QuantityValue ounces)
-#endif
- {
- double value = (double) ounces;
- return new Mass(value, MassUnit.Ounce);
- }
-
- ///
- /// Get Mass from Pounds.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromPounds(double pounds)
-#else
- public static Mass FromPounds(QuantityValue pounds)
-#endif
- {
- double value = (double) pounds;
- return new Mass(value, MassUnit.Pound);
- }
-
- ///
- /// Get Mass from ShortHundredweight.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromShortHundredweight(double shorthundredweight)
-#else
- public static Mass FromShortHundredweight(QuantityValue shorthundredweight)
-#endif
- {
- double value = (double) shorthundredweight;
- return new Mass(value, MassUnit.ShortHundredweight);
- }
-
- ///
- /// Get Mass from ShortTons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromShortTons(double shorttons)
-#else
- public static Mass FromShortTons(QuantityValue shorttons)
-#endif
- {
- double value = (double) shorttons;
- return new Mass(value, MassUnit.ShortTon);
- }
-
- ///
- /// Get Mass from Slugs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromSlugs(double slugs)
-#else
- public static Mass FromSlugs(QuantityValue slugs)
-#endif
- {
- double value = (double) slugs;
- return new Mass(value, MassUnit.Slug);
- }
-
- ///
- /// Get Mass from Stone.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromStone(double stone)
-#else
- public static Mass FromStone(QuantityValue stone)
-#endif
- {
- double value = (double) stone;
- return new Mass(value, MassUnit.Stone);
- }
-
- ///
- /// Get Mass from Tonnes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Mass FromTonnes(double tonnes)
-#else
- public static Mass FromTonnes(QuantityValue tonnes)
-#endif
- {
- double value = (double) tonnes;
- return new Mass(value, MassUnit.Tonne);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Mass unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Mass From(double value, MassUnit fromUnit)
-#else
- public static Mass From(QuantityValue value, MassUnit fromUnit)
-#endif
- {
- return new Mass((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MassUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Mass)) throw new ArgumentException("Expected type Mass.", nameof(obj));
-
- return CompareTo((Mass)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(Mass other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Mass, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Mass))
- return false;
-
- var objQuantity = (Mass)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Mass within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Mass other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Mass 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.
- [Obsolete("Please use the Equals(Mass, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Mass other, Mass maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Mass.
- public override int GetHashCode()
- {
- return new { type = typeof(Mass), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MassUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Mass to another Mass with the unit representation .
- ///
- /// A Mass with the specified unit.
- public Mass ToUnit(MassUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Mass(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MassUnit.Centigram: return (_value/1e3) * 1e-2d;
- case MassUnit.Decagram: return (_value/1e3) * 1e1d;
- case MassUnit.Decigram: return (_value/1e3) * 1e-1d;
- case MassUnit.Gram: return _value/1e3;
- case MassUnit.Hectogram: return (_value/1e3) * 1e2d;
- case MassUnit.Kilogram: return (_value/1e3) * 1e3d;
- case MassUnit.Kilopound: return (_value*0.45359237) * 1e3d;
- case MassUnit.Kilotonne: return (_value*1e3) * 1e3d;
- case MassUnit.LongHundredweight: return _value/0.01968413055222121;
- case MassUnit.LongTon: return _value*1.0160469088e3;
- case MassUnit.Megapound: return (_value*0.45359237) * 1e6d;
- case MassUnit.Megatonne: return (_value*1e3) * 1e6d;
- case MassUnit.Microgram: return (_value/1e3) * 1e-6d;
- case MassUnit.Milligram: return (_value/1e3) * 1e-3d;
- case MassUnit.Nanogram: return (_value/1e3) * 1e-9d;
- case MassUnit.Ounce: return _value/35.2739619;
- case MassUnit.Pound: return _value*0.45359237;
- case MassUnit.ShortHundredweight: return _value/0.022046226218487758;
- case MassUnit.ShortTon: return _value*9.0718474e2;
- case MassUnit.Slug: return _value/6.852176556196105e-2;
- case MassUnit.Stone: return _value/0.1574731728702698;
- case MassUnit.Tonne: return _value*1e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MassUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MassUnit.Centigram: return (baseUnitValue*1e3) / 1e-2d;
- case MassUnit.Decagram: return (baseUnitValue*1e3) / 1e1d;
- case MassUnit.Decigram: return (baseUnitValue*1e3) / 1e-1d;
- case MassUnit.Gram: return baseUnitValue*1e3;
- case MassUnit.Hectogram: return (baseUnitValue*1e3) / 1e2d;
- case MassUnit.Kilogram: return (baseUnitValue*1e3) / 1e3d;
- case MassUnit.Kilopound: return (baseUnitValue/0.45359237) / 1e3d;
- case MassUnit.Kilotonne: return (baseUnitValue/1e3) / 1e3d;
- case MassUnit.LongHundredweight: return baseUnitValue*0.01968413055222121;
- case MassUnit.LongTon: return baseUnitValue/1.0160469088e3;
- case MassUnit.Megapound: return (baseUnitValue/0.45359237) / 1e6d;
- case MassUnit.Megatonne: return (baseUnitValue/1e3) / 1e6d;
- case MassUnit.Microgram: return (baseUnitValue*1e3) / 1e-6d;
- case MassUnit.Milligram: return (baseUnitValue*1e3) / 1e-3d;
- case MassUnit.Nanogram: return (baseUnitValue*1e3) / 1e-9d;
- case MassUnit.Ounce: return baseUnitValue*35.2739619;
- case MassUnit.Pound: return baseUnitValue/0.45359237;
- case MassUnit.ShortHundredweight: return baseUnitValue*0.022046226218487758;
- case MassUnit.ShortTon: return baseUnitValue/9.0718474e2;
- case MassUnit.Slug: return baseUnitValue*6.852176556196105e-2;
- case MassUnit.Stone: return baseUnitValue*0.1574731728702698;
- case MassUnit.Tonne: return baseUnitValue/1e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Mass Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Mass result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MassUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Kilogram
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MassUnit ToStringDefaultUnit { get; set; } = MassUnit.Kilogram;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MassUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Mass
- ///
- public static Mass MaxValue => new Mass(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Mass
- ///
- public static Mass MinValue => new Mass(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Mass.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Mass.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MassFlow.Common.g.cs b/Common/GeneratedCode/Quantities/MassFlow.Common.g.cs
deleted file mode 100644
index d60a2c5d4a..0000000000
--- a/Common/GeneratedCode/Quantities/MassFlow.Common.g.cs
+++ /dev/null
@@ -1,847 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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).
- ///
- // 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 MassFlow : IQuantity
-#else
- public partial struct MassFlow : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MassFlowUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MassFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MassFlow()
- {
- BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit GramPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MassFlow(double gramspersecond)
- {
- _value = Convert.ToDouble(gramspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MassFlow(double numericValue, MassFlowUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit GramPerSecond.
- ///
- /// Value assuming base unit GramPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassFlow(long gramspersecond) : this(Convert.ToDouble(gramspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit GramPerSecond.
- ///
- /// Value assuming base unit GramPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassFlow(decimal gramspersecond) : this(Convert.ToDouble(gramspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MassFlow;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MassFlowUnit BaseUnit => MassFlowUnit.GramPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MassFlow quantity.
- ///
- public static MassFlowUnit[] Units { get; } = Enum.GetValues(typeof(MassFlowUnit)).Cast().Except(new MassFlowUnit[]{ MassFlowUnit.Undefined }).ToArray();
-
- ///
- /// Get MassFlow in CentigramsPerSecond.
- ///
- public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond);
-
- ///
- /// Get MassFlow in DecagramsPerSecond.
- ///
- public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond);
-
- ///
- /// Get MassFlow in DecigramsPerSecond.
- ///
- public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond);
-
- ///
- /// Get MassFlow in GramsPerSecond.
- ///
- public double GramsPerSecond => As(MassFlowUnit.GramPerSecond);
-
- ///
- /// Get MassFlow in HectogramsPerSecond.
- ///
- public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond);
-
- ///
- /// Get MassFlow in KilogramsPerHour.
- ///
- public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour);
-
- ///
- /// Get MassFlow in KilogramsPerMinute.
- ///
- public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute);
-
- ///
- /// Get MassFlow in KilogramsPerSecond.
- ///
- public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond);
-
- ///
- /// Get MassFlow in MegapoundsPerHour.
- ///
- public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour);
-
- ///
- /// Get MassFlow in MegapoundsPerMinute.
- ///
- public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute);
-
- ///
- /// Get MassFlow in MicrogramsPerSecond.
- ///
- public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond);
-
- ///
- /// Get MassFlow in MilligramsPerSecond.
- ///
- public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond);
-
- ///
- /// Get MassFlow in NanogramsPerSecond.
- ///
- public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond);
-
- ///
- /// Get MassFlow in PoundsPerHour.
- ///
- public double PoundsPerHour => As(MassFlowUnit.PoundPerHour);
-
- ///
- /// Get MassFlow in PoundsPerMinute.
- ///
- public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute);
-
- ///
- /// Get MassFlow in ShortTonsPerHour.
- ///
- public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour);
-
- ///
- /// Get MassFlow in TonnesPerDay.
- ///
- public double TonnesPerDay => As(MassFlowUnit.TonnePerDay);
-
- ///
- /// Get MassFlow in TonnesPerHour.
- ///
- public double TonnesPerHour => As(MassFlowUnit.TonnePerHour);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit GramPerSecond.
- ///
- public static MassFlow Zero => new MassFlow(0, BaseUnit);
-
- ///
- /// Get MassFlow from CentigramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromCentigramsPerSecond(double centigramspersecond)
-#else
- public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond)
-#endif
- {
- double value = (double) centigramspersecond;
- return new MassFlow(value, MassFlowUnit.CentigramPerSecond);
- }
-
- ///
- /// Get MassFlow from DecagramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromDecagramsPerSecond(double decagramspersecond)
-#else
- public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond)
-#endif
- {
- double value = (double) decagramspersecond;
- return new MassFlow(value, MassFlowUnit.DecagramPerSecond);
- }
-
- ///
- /// Get MassFlow from DecigramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromDecigramsPerSecond(double decigramspersecond)
-#else
- public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond)
-#endif
- {
- double value = (double) decigramspersecond;
- return new MassFlow(value, MassFlowUnit.DecigramPerSecond);
- }
-
- ///
- /// Get MassFlow from GramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromGramsPerSecond(double gramspersecond)
-#else
- public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond)
-#endif
- {
- double value = (double) gramspersecond;
- return new MassFlow(value, MassFlowUnit.GramPerSecond);
- }
-
- ///
- /// Get MassFlow from HectogramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromHectogramsPerSecond(double hectogramspersecond)
-#else
- public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond)
-#endif
- {
- double value = (double) hectogramspersecond;
- return new MassFlow(value, MassFlowUnit.HectogramPerSecond);
- }
-
- ///
- /// Get MassFlow from KilogramsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromKilogramsPerHour(double kilogramsperhour)
-#else
- public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour)
-#endif
- {
- double value = (double) kilogramsperhour;
- return new MassFlow(value, MassFlowUnit.KilogramPerHour);
- }
-
- ///
- /// Get MassFlow from KilogramsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromKilogramsPerMinute(double kilogramsperminute)
-#else
- public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute)
-#endif
- {
- double value = (double) kilogramsperminute;
- return new MassFlow(value, MassFlowUnit.KilogramPerMinute);
- }
-
- ///
- /// Get MassFlow from KilogramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromKilogramsPerSecond(double kilogramspersecond)
-#else
- public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond)
-#endif
- {
- double value = (double) kilogramspersecond;
- return new MassFlow(value, MassFlowUnit.KilogramPerSecond);
- }
-
- ///
- /// Get MassFlow from MegapoundsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromMegapoundsPerHour(double megapoundsperhour)
-#else
- public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour)
-#endif
- {
- double value = (double) megapoundsperhour;
- return new MassFlow(value, MassFlowUnit.MegapoundPerHour);
- }
-
- ///
- /// Get MassFlow from MegapoundsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromMegapoundsPerMinute(double megapoundsperminute)
-#else
- public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute)
-#endif
- {
- double value = (double) megapoundsperminute;
- return new MassFlow(value, MassFlowUnit.MegapoundPerMinute);
- }
-
- ///
- /// Get MassFlow from MicrogramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromMicrogramsPerSecond(double microgramspersecond)
-#else
- public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond)
-#endif
- {
- double value = (double) microgramspersecond;
- return new MassFlow(value, MassFlowUnit.MicrogramPerSecond);
- }
-
- ///
- /// Get MassFlow from MilligramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromMilligramsPerSecond(double milligramspersecond)
-#else
- public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond)
-#endif
- {
- double value = (double) milligramspersecond;
- return new MassFlow(value, MassFlowUnit.MilligramPerSecond);
- }
-
- ///
- /// Get MassFlow from NanogramsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromNanogramsPerSecond(double nanogramspersecond)
-#else
- public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond)
-#endif
- {
- double value = (double) nanogramspersecond;
- return new MassFlow(value, MassFlowUnit.NanogramPerSecond);
- }
-
- ///
- /// Get MassFlow from PoundsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromPoundsPerHour(double poundsperhour)
-#else
- public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour)
-#endif
- {
- double value = (double) poundsperhour;
- return new MassFlow(value, MassFlowUnit.PoundPerHour);
- }
-
- ///
- /// Get MassFlow from PoundsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromPoundsPerMinute(double poundsperminute)
-#else
- public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute)
-#endif
- {
- double value = (double) poundsperminute;
- return new MassFlow(value, MassFlowUnit.PoundPerMinute);
- }
-
- ///
- /// Get MassFlow from ShortTonsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromShortTonsPerHour(double shorttonsperhour)
-#else
- public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour)
-#endif
- {
- double value = (double) shorttonsperhour;
- return new MassFlow(value, MassFlowUnit.ShortTonPerHour);
- }
-
- ///
- /// Get MassFlow from TonnesPerDay.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromTonnesPerDay(double tonnesperday)
-#else
- public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday)
-#endif
- {
- double value = (double) tonnesperday;
- return new MassFlow(value, MassFlowUnit.TonnePerDay);
- }
-
- ///
- /// Get MassFlow from TonnesPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlow FromTonnesPerHour(double tonnesperhour)
-#else
- public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour)
-#endif
- {
- double value = (double) tonnesperhour;
- return new MassFlow(value, MassFlowUnit.TonnePerHour);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MassFlow unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MassFlow From(double value, MassFlowUnit fromUnit)
-#else
- public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit)
-#endif
- {
- return new MassFlow((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MassFlowUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MassFlow)) throw new ArgumentException("Expected type MassFlow.", nameof(obj));
-
- return CompareTo((MassFlow)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(MassFlow other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MassFlow, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MassFlow))
- return false;
-
- var objQuantity = (MassFlow)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MassFlow within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MassFlow 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.
- [Obsolete("Please use the Equals(MassFlow, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MassFlow other, MassFlow maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MassFlow.
- public override int GetHashCode()
- {
- return new { type = typeof(MassFlow), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MassFlowUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MassFlow to another MassFlow with the unit representation .
- ///
- /// A MassFlow with the specified unit.
- public MassFlow ToUnit(MassFlowUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MassFlow(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MassFlowUnit.CentigramPerSecond: return (_value) * 1e-2d;
- case MassFlowUnit.DecagramPerSecond: return (_value) * 1e1d;
- case MassFlowUnit.DecigramPerSecond: return (_value) * 1e-1d;
- case MassFlowUnit.GramPerSecond: return _value;
- case MassFlowUnit.HectogramPerSecond: return (_value) * 1e2d;
- case MassFlowUnit.KilogramPerHour: return _value/3.6;
- case MassFlowUnit.KilogramPerMinute: return _value/0.06;
- case MassFlowUnit.KilogramPerSecond: return (_value) * 1e3d;
- case MassFlowUnit.MegapoundPerHour: return (_value/7.93664) * 1e6d;
- case MassFlowUnit.MegapoundPerMinute: return (_value/0.132277) * 1e6d;
- case MassFlowUnit.MicrogramPerSecond: return (_value) * 1e-6d;
- case MassFlowUnit.MilligramPerSecond: return (_value) * 1e-3d;
- case MassFlowUnit.NanogramPerSecond: return (_value) * 1e-9d;
- case MassFlowUnit.PoundPerHour: return _value/7.93664;
- case MassFlowUnit.PoundPerMinute: return _value/0.132277;
- case MassFlowUnit.ShortTonPerHour: return _value*251.9957611;
- case MassFlowUnit.TonnePerDay: return _value/0.0864000;
- case MassFlowUnit.TonnePerHour: return 1000*_value/3.6;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MassFlowUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MassFlowUnit.CentigramPerSecond: return (baseUnitValue) / 1e-2d;
- case MassFlowUnit.DecagramPerSecond: return (baseUnitValue) / 1e1d;
- case MassFlowUnit.DecigramPerSecond: return (baseUnitValue) / 1e-1d;
- case MassFlowUnit.GramPerSecond: return baseUnitValue;
- case MassFlowUnit.HectogramPerSecond: return (baseUnitValue) / 1e2d;
- case MassFlowUnit.KilogramPerHour: return baseUnitValue*3.6;
- case MassFlowUnit.KilogramPerMinute: return baseUnitValue*0.06;
- case MassFlowUnit.KilogramPerSecond: return (baseUnitValue) / 1e3d;
- case MassFlowUnit.MegapoundPerHour: return (baseUnitValue*7.93664) / 1e6d;
- case MassFlowUnit.MegapoundPerMinute: return (baseUnitValue*0.132277) / 1e6d;
- case MassFlowUnit.MicrogramPerSecond: return (baseUnitValue) / 1e-6d;
- case MassFlowUnit.MilligramPerSecond: return (baseUnitValue) / 1e-3d;
- case MassFlowUnit.NanogramPerSecond: return (baseUnitValue) / 1e-9d;
- case MassFlowUnit.PoundPerHour: return baseUnitValue*7.93664;
- case MassFlowUnit.PoundPerMinute: return baseUnitValue*0.132277;
- case MassFlowUnit.ShortTonPerHour: return baseUnitValue/251.9957611;
- case MassFlowUnit.TonnePerDay: return baseUnitValue*0.0864000;
- case MassFlowUnit.TonnePerHour: return baseUnitValue*3.6/1000;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MassFlow Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MassFlow result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MassFlowUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is GramPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MassFlowUnit ToStringDefaultUnit { get; set; } = MassFlowUnit.GramPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MassFlowUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MassFlow
- ///
- public static MassFlow MaxValue => new MassFlow(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MassFlow
- ///
- public static MassFlow MinValue => new MassFlow(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MassFlow.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MassFlow.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MassFlux.Common.g.cs b/Common/GeneratedCode/Quantities/MassFlux.Common.g.cs
deleted file mode 100644
index 3b11775e10..0000000000
--- a/Common/GeneratedCode/Quantities/MassFlux.Common.g.cs
+++ /dev/null
@@ -1,511 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Mass flux is the mass flow rate per unit area.
- ///
- // 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 MassFlux : IQuantity
-#else
- public partial struct MassFlux : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MassFluxUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MassFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MassFlux()
- {
- BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerSecondPerSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MassFlux(double kilogramspersecondpersquaremeter)
- {
- _value = Convert.ToDouble(kilogramspersecondpersquaremeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MassFlux(double numericValue, MassFluxUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerSecondPerSquareMeter.
- ///
- /// Value assuming base unit KilogramPerSecondPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassFlux(long kilogramspersecondpersquaremeter) : this(Convert.ToDouble(kilogramspersecondpersquaremeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerSecondPerSquareMeter.
- ///
- /// Value assuming base unit KilogramPerSecondPerSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassFlux(decimal kilogramspersecondpersquaremeter) : this(Convert.ToDouble(kilogramspersecondpersquaremeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MassFlux;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MassFluxUnit BaseUnit => MassFluxUnit.KilogramPerSecondPerSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MassFlux quantity.
- ///
- public static MassFluxUnit[] Units { get; } = Enum.GetValues(typeof(MassFluxUnit)).Cast().Except(new MassFluxUnit[]{ MassFluxUnit.Undefined }).ToArray();
-
- ///
- /// Get MassFlux in GramsPerSecondPerSquareMeter.
- ///
- public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter);
-
- ///
- /// Get MassFlux in KilogramsPerSecondPerSquareMeter.
- ///
- public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter.
- ///
- public static MassFlux Zero => new MassFlux(0, BaseUnit);
-
- ///
- /// Get MassFlux from GramsPerSecondPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlux FromGramsPerSecondPerSquareMeter(double gramspersecondpersquaremeter)
-#else
- public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramspersecondpersquaremeter)
-#endif
- {
- double value = (double) gramspersecondpersquaremeter;
- return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter);
- }
-
- ///
- /// Get MassFlux from KilogramsPerSecondPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassFlux FromKilogramsPerSecondPerSquareMeter(double kilogramspersecondpersquaremeter)
-#else
- public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogramspersecondpersquaremeter)
-#endif
- {
- double value = (double) kilogramspersecondpersquaremeter;
- return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MassFlux unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MassFlux From(double value, MassFluxUnit fromUnit)
-#else
- public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit)
-#endif
- {
- return new MassFlux((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MassFluxUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MassFlux)) throw new ArgumentException("Expected type MassFlux.", nameof(obj));
-
- return CompareTo((MassFlux)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(MassFlux other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MassFlux, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MassFlux))
- return false;
-
- var objQuantity = (MassFlux)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MassFlux within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MassFlux 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.
- [Obsolete("Please use the Equals(MassFlux, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MassFlux other, MassFlux maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MassFlux.
- public override int GetHashCode()
- {
- return new { type = typeof(MassFlux), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MassFluxUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MassFlux to another MassFlux with the unit representation .
- ///
- /// A MassFlux with the specified unit.
- public MassFlux ToUnit(MassFluxUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MassFlux(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MassFluxUnit.GramPerSecondPerSquareMeter: return _value/1e3;
- case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (_value/1e3) * 1e3d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MassFluxUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MassFluxUnit.GramPerSecondPerSquareMeter: return baseUnitValue*1e3;
- case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (baseUnitValue*1e3) / 1e3d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MassFlux Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MassFlux result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MassFluxUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerSecondPerSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MassFluxUnit ToStringDefaultUnit { get; set; } = MassFluxUnit.KilogramPerSecondPerSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MassFluxUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MassFlux
- ///
- public static MassFlux MaxValue => new MassFlux(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MassFlux
- ///
- public static MassFlux MinValue => new MassFlux(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MassFlux.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MassFlux.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MassMomentOfInertia.Common.g.cs b/Common/GeneratedCode/Quantities/MassMomentOfInertia.Common.g.cs
deleted file mode 100644
index 73d79c6d4d..0000000000
--- a/Common/GeneratedCode/Quantities/MassMomentOfInertia.Common.g.cs
+++ /dev/null
@@ -1,1057 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// A property of body reflects how its mass is distributed with regard to an axis.
- ///
- // 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 MassMomentOfInertia : IQuantity
-#else
- public partial struct MassMomentOfInertia : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MassMomentOfInertiaUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MassMomentOfInertia()
- {
- BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramSquareMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MassMomentOfInertia(double kilogramsquaremeters)
- {
- _value = Convert.ToDouble(kilogramsquaremeters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MassMomentOfInertia(double numericValue, MassMomentOfInertiaUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramSquareMeter.
- ///
- /// Value assuming base unit KilogramSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassMomentOfInertia(long kilogramsquaremeters) : this(Convert.ToDouble(kilogramsquaremeters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramSquareMeter.
- ///
- /// Value assuming base unit KilogramSquareMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MassMomentOfInertia(decimal kilogramsquaremeters) : this(Convert.ToDouble(kilogramsquaremeters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MassMomentOfInertia;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MassMomentOfInertiaUnit BaseUnit => MassMomentOfInertiaUnit.KilogramSquareMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MassMomentOfInertia quantity.
- ///
- public static MassMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().Except(new MassMomentOfInertiaUnit[]{ MassMomentOfInertiaUnit.Undefined }).ToArray();
-
- ///
- /// Get MassMomentOfInertia in GramSquareCentimeters.
- ///
- public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in GramSquareDecimeters.
- ///
- public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in GramSquareMeters.
- ///
- public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in GramSquareMillimeters.
- ///
- public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter);
-
- ///
- /// Get MassMomentOfInertia in KilogramSquareCentimeters.
- ///
- public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in KilogramSquareDecimeters.
- ///
- public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in KilogramSquareMeters.
- ///
- public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in KilogramSquareMillimeters.
- ///
- public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter);
-
- ///
- /// Get MassMomentOfInertia in KilotonneSquareCentimeters.
- ///
- public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in KilotonneSquareDecimeters.
- ///
- public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in KilotonneSquareMeters.
- ///
- public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in KilotonneSquareMilimeters.
- ///
- public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter);
-
- ///
- /// Get MassMomentOfInertia in MegatonneSquareCentimeters.
- ///
- public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in MegatonneSquareDecimeters.
- ///
- public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in MegatonneSquareMeters.
- ///
- public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in MegatonneSquareMilimeters.
- ///
- public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter);
-
- ///
- /// Get MassMomentOfInertia in MilligramSquareCentimeters.
- ///
- public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in MilligramSquareDecimeters.
- ///
- public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in MilligramSquareMeters.
- ///
- public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in MilligramSquareMillimeters.
- ///
- public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter);
-
- ///
- /// Get MassMomentOfInertia in PoundSquareFeet.
- ///
- public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot);
-
- ///
- /// Get MassMomentOfInertia in PoundSquareInches.
- ///
- public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch);
-
- ///
- /// Get MassMomentOfInertia in SlugSquareFeet.
- ///
- public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot);
-
- ///
- /// Get MassMomentOfInertia in SlugSquareInches.
- ///
- public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch);
-
- ///
- /// Get MassMomentOfInertia in TonneSquareCentimeters.
- ///
- public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter);
-
- ///
- /// Get MassMomentOfInertia in TonneSquareDecimeters.
- ///
- public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter);
-
- ///
- /// Get MassMomentOfInertia in TonneSquareMeters.
- ///
- public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter);
-
- ///
- /// Get MassMomentOfInertia in TonneSquareMilimeters.
- ///
- public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramSquareMeter.
- ///
- public static MassMomentOfInertia Zero => new MassMomentOfInertia(0, BaseUnit);
-
- ///
- /// Get MassMomentOfInertia from GramSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromGramSquareCentimeters(double gramsquarecentimeters)
-#else
- public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsquarecentimeters)
-#endif
- {
- double value = (double) gramsquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from GramSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromGramSquareDecimeters(double gramsquaredecimeters)
-#else
- public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsquaredecimeters)
-#endif
- {
- double value = (double) gramsquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from GramSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromGramSquareMeters(double gramsquaremeters)
-#else
- public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquaremeters)
-#endif
- {
- double value = (double) gramsquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from GramSquareMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromGramSquareMillimeters(double gramsquaremillimeters)
-#else
- public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsquaremillimeters)
-#endif
- {
- double value = (double) gramsquaremillimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilogramSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilogramSquareCentimeters(double kilogramsquarecentimeters)
-#else
- public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue kilogramsquarecentimeters)
-#endif
- {
- double value = (double) kilogramsquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilogramSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilogramSquareDecimeters(double kilogramsquaredecimeters)
-#else
- public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kilogramsquaredecimeters)
-#endif
- {
- double value = (double) kilogramsquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilogramSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilogramSquareMeters(double kilogramsquaremeters)
-#else
- public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogramsquaremeters)
-#endif
- {
- double value = (double) kilogramsquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilogramSquareMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilogramSquareMillimeters(double kilogramsquaremillimeters)
-#else
- public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue kilogramsquaremillimeters)
-#endif
- {
- double value = (double) kilogramsquaremillimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilotonneSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilotonneSquareCentimeters(double kilotonnesquarecentimeters)
-#else
- public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue kilotonnesquarecentimeters)
-#endif
- {
- double value = (double) kilotonnesquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilotonneSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilotonneSquareDecimeters(double kilotonnesquaredecimeters)
-#else
- public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue kilotonnesquaredecimeters)
-#endif
- {
- double value = (double) kilotonnesquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilotonneSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilotonneSquareMeters(double kilotonnesquaremeters)
-#else
- public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kilotonnesquaremeters)
-#endif
- {
- double value = (double) kilotonnesquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from KilotonneSquareMilimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromKilotonneSquareMilimeters(double kilotonnesquaremilimeters)
-#else
- public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue kilotonnesquaremilimeters)
-#endif
- {
- double value = (double) kilotonnesquaremilimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MegatonneSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMegatonneSquareCentimeters(double megatonnesquarecentimeters)
-#else
- public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue megatonnesquarecentimeters)
-#endif
- {
- double value = (double) megatonnesquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MegatonneSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMegatonneSquareDecimeters(double megatonnesquaredecimeters)
-#else
- public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue megatonnesquaredecimeters)
-#endif
- {
- double value = (double) megatonnesquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MegatonneSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMegatonneSquareMeters(double megatonnesquaremeters)
-#else
- public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megatonnesquaremeters)
-#endif
- {
- double value = (double) megatonnesquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MegatonneSquareMilimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMegatonneSquareMilimeters(double megatonnesquaremilimeters)
-#else
- public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue megatonnesquaremilimeters)
-#endif
- {
- double value = (double) megatonnesquaremilimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MilligramSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMilligramSquareCentimeters(double milligramsquarecentimeters)
-#else
- public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue milligramsquarecentimeters)
-#endif
- {
- double value = (double) milligramsquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MilligramSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMilligramSquareDecimeters(double milligramsquaredecimeters)
-#else
- public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue milligramsquaredecimeters)
-#endif
- {
- double value = (double) milligramsquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MilligramSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMilligramSquareMeters(double milligramsquaremeters)
-#else
- public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue milligramsquaremeters)
-#endif
- {
- double value = (double) milligramsquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from MilligramSquareMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromMilligramSquareMillimeters(double milligramsquaremillimeters)
-#else
- public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue milligramsquaremillimeters)
-#endif
- {
- double value = (double) milligramsquaremillimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from PoundSquareFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromPoundSquareFeet(double poundsquarefeet)
-#else
- public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquarefeet)
-#endif
- {
- double value = (double) poundsquarefeet;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot);
- }
-
- ///
- /// Get MassMomentOfInertia from PoundSquareInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromPoundSquareInches(double poundsquareinches)
-#else
- public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquareinches)
-#endif
- {
- double value = (double) poundsquareinches;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch);
- }
-
- ///
- /// Get MassMomentOfInertia from SlugSquareFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromSlugSquareFeet(double slugsquarefeet)
-#else
- public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefeet)
-#endif
- {
- double value = (double) slugsquarefeet;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot);
- }
-
- ///
- /// Get MassMomentOfInertia from SlugSquareInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromSlugSquareInches(double slugsquareinches)
-#else
- public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquareinches)
-#endif
- {
- double value = (double) slugsquareinches;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch);
- }
-
- ///
- /// Get MassMomentOfInertia from TonneSquareCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromTonneSquareCentimeters(double tonnesquarecentimeters)
-#else
- public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonnesquarecentimeters)
-#endif
- {
- double value = (double) tonnesquarecentimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from TonneSquareDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromTonneSquareDecimeters(double tonnesquaredecimeters)
-#else
- public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnesquaredecimeters)
-#endif
- {
- double value = (double) tonnesquaredecimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter);
- }
-
- ///
- /// Get MassMomentOfInertia from TonneSquareMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromTonneSquareMeters(double tonnesquaremeters)
-#else
- public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquaremeters)
-#endif
- {
- double value = (double) tonnesquaremeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter);
- }
-
- ///
- /// Get MassMomentOfInertia from TonneSquareMilimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MassMomentOfInertia FromTonneSquareMilimeters(double tonnesquaremilimeters)
-#else
- public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnesquaremilimeters)
-#endif
- {
- double value = (double) tonnesquaremilimeters;
- return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MassMomentOfInertia unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MassMomentOfInertia From(double value, MassMomentOfInertiaUnit fromUnit)
-#else
- public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaUnit fromUnit)
-#endif
- {
- return new MassMomentOfInertia((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MassMomentOfInertiaUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MassMomentOfInertia)) throw new ArgumentException("Expected type MassMomentOfInertia.", nameof(obj));
-
- return CompareTo((MassMomentOfInertia)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(MassMomentOfInertia other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MassMomentOfInertia, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MassMomentOfInertia))
- return false;
-
- var objQuantity = (MassMomentOfInertia)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MassMomentOfInertia 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.
- [Obsolete("Please use the Equals(MassMomentOfInertia, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MassMomentOfInertia other, MassMomentOfInertia maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MassMomentOfInertia.
- public override int GetHashCode()
- {
- return new { type = typeof(MassMomentOfInertia), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MassMomentOfInertiaUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation .
- ///
- /// A MassMomentOfInertia with the specified unit.
- public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MassMomentOfInertia(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MassMomentOfInertiaUnit.GramSquareCentimeter: return _value/1e7;
- case MassMomentOfInertiaUnit.GramSquareDecimeter: return _value/1e5;
- case MassMomentOfInertiaUnit.GramSquareMeter: return _value/1e3;
- case MassMomentOfInertiaUnit.GramSquareMillimeter: return _value/1e9;
- case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (_value/1e7) * 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (_value/1e5) * 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareMeter: return (_value/1e3) * 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (_value/1e9) * 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (_value/1e1) * 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (_value/1e-1) * 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (_value/1e-3) * 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (_value/1e3) * 1e3d;
- case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (_value/1e1) * 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (_value/1e-1) * 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (_value/1e-3) * 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (_value/1e3) * 1e6d;
- case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (_value/1e7) * 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (_value/1e5) * 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareMeter: return (_value/1e3) * 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (_value/1e9) * 1e-3d;
- case MassMomentOfInertiaUnit.PoundSquareFoot: return _value*4.21401101e-2;
- case MassMomentOfInertiaUnit.PoundSquareInch: return _value*2.9263965e-4;
- case MassMomentOfInertiaUnit.SlugSquareFoot: return _value*1.3558179619;
- case MassMomentOfInertiaUnit.SlugSquareInch: return _value*9.41540242e-3;
- case MassMomentOfInertiaUnit.TonneSquareCentimeter: return _value/1e1;
- case MassMomentOfInertiaUnit.TonneSquareDecimeter: return _value/1e-1;
- case MassMomentOfInertiaUnit.TonneSquareMeter: return _value/1e-3;
- case MassMomentOfInertiaUnit.TonneSquareMilimeter: return _value/1e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MassMomentOfInertiaUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MassMomentOfInertiaUnit.GramSquareCentimeter: return baseUnitValue*1e7;
- case MassMomentOfInertiaUnit.GramSquareDecimeter: return baseUnitValue*1e5;
- case MassMomentOfInertiaUnit.GramSquareMeter: return baseUnitValue*1e3;
- case MassMomentOfInertiaUnit.GramSquareMillimeter: return baseUnitValue*1e9;
- case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (baseUnitValue*1e7) / 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (baseUnitValue*1e5) / 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareMeter: return (baseUnitValue*1e3) / 1e3d;
- case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (baseUnitValue*1e9) / 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (baseUnitValue*1e1) / 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (baseUnitValue*1e-1) / 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (baseUnitValue*1e-3) / 1e3d;
- case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (baseUnitValue*1e3) / 1e3d;
- case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (baseUnitValue*1e1) / 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (baseUnitValue*1e-1) / 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (baseUnitValue*1e-3) / 1e6d;
- case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (baseUnitValue*1e3) / 1e6d;
- case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (baseUnitValue*1e7) / 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (baseUnitValue*1e5) / 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareMeter: return (baseUnitValue*1e3) / 1e-3d;
- case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (baseUnitValue*1e9) / 1e-3d;
- case MassMomentOfInertiaUnit.PoundSquareFoot: return baseUnitValue/4.21401101e-2;
- case MassMomentOfInertiaUnit.PoundSquareInch: return baseUnitValue/2.9263965e-4;
- case MassMomentOfInertiaUnit.SlugSquareFoot: return baseUnitValue/1.3558179619;
- case MassMomentOfInertiaUnit.SlugSquareInch: return baseUnitValue/9.41540242e-3;
- case MassMomentOfInertiaUnit.TonneSquareCentimeter: return baseUnitValue*1e1;
- case MassMomentOfInertiaUnit.TonneSquareDecimeter: return baseUnitValue*1e-1;
- case MassMomentOfInertiaUnit.TonneSquareMeter: return baseUnitValue*1e-3;
- case MassMomentOfInertiaUnit.TonneSquareMilimeter: return baseUnitValue*1e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MassMomentOfInertia Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MassMomentOfInertia result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MassMomentOfInertiaUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramSquareMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MassMomentOfInertiaUnit ToStringDefaultUnit { get; set; } = MassMomentOfInertiaUnit.KilogramSquareMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MassMomentOfInertiaUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MassMomentOfInertia
- ///
- public static MassMomentOfInertia MaxValue => new MassMomentOfInertia(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MassMomentOfInertia
- ///
- public static MassMomentOfInertia MinValue => new MassMomentOfInertia(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MassMomentOfInertia.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MassMomentOfInertia.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MolarEnergy.Common.g.cs b/Common/GeneratedCode/Quantities/MolarEnergy.Common.g.cs
deleted file mode 100644
index 37f4cefa41..0000000000
--- a/Common/GeneratedCode/Quantities/MolarEnergy.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Molar energy is the amount of energy stored in 1 mole of a substance.
- ///
- // 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 MolarEnergy : IQuantity
-#else
- public partial struct MolarEnergy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MolarEnergyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MolarEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MolarEnergy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, -1, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerMole.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MolarEnergy(double joulespermole)
- {
- _value = Convert.ToDouble(joulespermole);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MolarEnergy(double numericValue, MolarEnergyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerMole.
- ///
- /// Value assuming base unit JoulePerMole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarEnergy(long joulespermole) : this(Convert.ToDouble(joulespermole), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerMole.
- ///
- /// Value assuming base unit JoulePerMole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarEnergy(decimal joulespermole) : this(Convert.ToDouble(joulespermole), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MolarEnergy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MolarEnergyUnit BaseUnit => MolarEnergyUnit.JoulePerMole;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MolarEnergy quantity.
- ///
- public static MolarEnergyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().Except(new MolarEnergyUnit[]{ MolarEnergyUnit.Undefined }).ToArray();
-
- ///
- /// Get MolarEnergy in JoulesPerMole.
- ///
- public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole);
-
- ///
- /// Get MolarEnergy in KilojoulesPerMole.
- ///
- public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole);
-
- ///
- /// Get MolarEnergy in MegajoulesPerMole.
- ///
- public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMole.
- ///
- public static MolarEnergy Zero => new MolarEnergy(0, BaseUnit);
-
- ///
- /// Get MolarEnergy from JoulesPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEnergy FromJoulesPerMole(double joulespermole)
-#else
- public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole)
-#endif
- {
- double value = (double) joulespermole;
- return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole);
- }
-
- ///
- /// Get MolarEnergy from KilojoulesPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEnergy FromKilojoulesPerMole(double kilojoulespermole)
-#else
- public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole)
-#endif
- {
- double value = (double) kilojoulespermole;
- return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole);
- }
-
- ///
- /// Get MolarEnergy from MegajoulesPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEnergy FromMegajoulesPerMole(double megajoulespermole)
-#else
- public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole)
-#endif
- {
- double value = (double) megajoulespermole;
- return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MolarEnergy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MolarEnergy From(double value, MolarEnergyUnit fromUnit)
-#else
- public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit)
-#endif
- {
- return new MolarEnergy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MolarEnergyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MolarEnergy)) throw new ArgumentException("Expected type MolarEnergy.", nameof(obj));
-
- return CompareTo((MolarEnergy)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(MolarEnergy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MolarEnergy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MolarEnergy))
- return false;
-
- var objQuantity = (MolarEnergy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MolarEnergy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MolarEnergy 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.
- [Obsolete("Please use the Equals(MolarEnergy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MolarEnergy other, MolarEnergy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MolarEnergy.
- public override int GetHashCode()
- {
- return new { type = typeof(MolarEnergy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MolarEnergyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MolarEnergy to another MolarEnergy with the unit representation .
- ///
- /// A MolarEnergy with the specified unit.
- public MolarEnergy ToUnit(MolarEnergyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MolarEnergy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MolarEnergyUnit.JoulePerMole: return _value;
- case MolarEnergyUnit.KilojoulePerMole: return (_value) * 1e3d;
- case MolarEnergyUnit.MegajoulePerMole: return (_value) * 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MolarEnergyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MolarEnergyUnit.JoulePerMole: return baseUnitValue;
- case MolarEnergyUnit.KilojoulePerMole: return (baseUnitValue) / 1e3d;
- case MolarEnergyUnit.MegajoulePerMole: return (baseUnitValue) / 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MolarEnergy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MolarEnergy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MolarEnergyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerMole
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MolarEnergyUnit ToStringDefaultUnit { get; set; } = MolarEnergyUnit.JoulePerMole;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MolarEnergyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MolarEnergy
- ///
- public static MolarEnergy MaxValue => new MolarEnergy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MolarEnergy
- ///
- public static MolarEnergy MinValue => new MolarEnergy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MolarEnergy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MolarEnergy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MolarEntropy.Common.g.cs b/Common/GeneratedCode/Quantities/MolarEntropy.Common.g.cs
deleted file mode 100644
index e39453521e..0000000000
--- a/Common/GeneratedCode/Quantities/MolarEntropy.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.
- ///
- // 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 MolarEntropy : IQuantity
-#else
- public partial struct MolarEntropy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MolarEntropyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MolarEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MolarEntropy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, -1, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerMoleKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MolarEntropy(double joulespermolekelvin)
- {
- _value = Convert.ToDouble(joulespermolekelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MolarEntropy(double numericValue, MolarEntropyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerMoleKelvin.
- ///
- /// Value assuming base unit JoulePerMoleKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarEntropy(long joulespermolekelvin) : this(Convert.ToDouble(joulespermolekelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerMoleKelvin.
- ///
- /// Value assuming base unit JoulePerMoleKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarEntropy(decimal joulespermolekelvin) : this(Convert.ToDouble(joulespermolekelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MolarEntropy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MolarEntropyUnit BaseUnit => MolarEntropyUnit.JoulePerMoleKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MolarEntropy quantity.
- ///
- public static MolarEntropyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().Except(new MolarEntropyUnit[]{ MolarEntropyUnit.Undefined }).ToArray();
-
- ///
- /// Get MolarEntropy in JoulesPerMoleKelvin.
- ///
- public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin);
-
- ///
- /// Get MolarEntropy in KilojoulesPerMoleKelvin.
- ///
- public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin);
-
- ///
- /// Get MolarEntropy in MegajoulesPerMoleKelvin.
- ///
- public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMoleKelvin.
- ///
- public static MolarEntropy Zero => new MolarEntropy(0, BaseUnit);
-
- ///
- /// Get MolarEntropy from JoulesPerMoleKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEntropy FromJoulesPerMoleKelvin(double joulespermolekelvin)
-#else
- public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermolekelvin)
-#endif
- {
- double value = (double) joulespermolekelvin;
- return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin);
- }
-
- ///
- /// Get MolarEntropy from KilojoulesPerMoleKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEntropy FromKilojoulesPerMoleKelvin(double kilojoulespermolekelvin)
-#else
- public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulespermolekelvin)
-#endif
- {
- double value = (double) kilojoulespermolekelvin;
- return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin);
- }
-
- ///
- /// Get MolarEntropy from MegajoulesPerMoleKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarEntropy FromMegajoulesPerMoleKelvin(double megajoulespermolekelvin)
-#else
- public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulespermolekelvin)
-#endif
- {
- double value = (double) megajoulespermolekelvin;
- return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MolarEntropy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MolarEntropy From(double value, MolarEntropyUnit fromUnit)
-#else
- public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit)
-#endif
- {
- return new MolarEntropy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MolarEntropyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MolarEntropy)) throw new ArgumentException("Expected type MolarEntropy.", nameof(obj));
-
- return CompareTo((MolarEntropy)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(MolarEntropy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MolarEntropy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MolarEntropy))
- return false;
-
- var objQuantity = (MolarEntropy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MolarEntropy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MolarEntropy 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.
- [Obsolete("Please use the Equals(MolarEntropy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MolarEntropy other, MolarEntropy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MolarEntropy.
- public override int GetHashCode()
- {
- return new { type = typeof(MolarEntropy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MolarEntropyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MolarEntropy to another MolarEntropy with the unit representation .
- ///
- /// A MolarEntropy with the specified unit.
- public MolarEntropy ToUnit(MolarEntropyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MolarEntropy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MolarEntropyUnit.JoulePerMoleKelvin: return _value;
- case MolarEntropyUnit.KilojoulePerMoleKelvin: return (_value) * 1e3d;
- case MolarEntropyUnit.MegajoulePerMoleKelvin: return (_value) * 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MolarEntropyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MolarEntropyUnit.JoulePerMoleKelvin: return baseUnitValue;
- case MolarEntropyUnit.KilojoulePerMoleKelvin: return (baseUnitValue) / 1e3d;
- case MolarEntropyUnit.MegajoulePerMoleKelvin: return (baseUnitValue) / 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MolarEntropy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MolarEntropy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MolarEntropyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerMoleKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MolarEntropyUnit ToStringDefaultUnit { get; set; } = MolarEntropyUnit.JoulePerMoleKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MolarEntropyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MolarEntropy
- ///
- public static MolarEntropy MaxValue => new MolarEntropy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MolarEntropy
- ///
- public static MolarEntropy MinValue => new MolarEntropy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MolarEntropy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MolarEntropy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/MolarMass.Common.g.cs b/Common/GeneratedCode/Quantities/MolarMass.Common.g.cs
deleted file mode 100644
index 4ff7707aa2..0000000000
--- a/Common/GeneratedCode/Quantities/MolarMass.Common.g.cs
+++ /dev/null
@@ -1,721 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-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.
- ///
- // 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 MolarMass : IQuantity
-#else
- public partial struct MolarMass : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MolarMassUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MolarMassUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static MolarMass()
- {
- BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, -1, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit KilogramPerMole.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public MolarMass(double kilogramspermole)
- {
- _value = Convert.ToDouble(kilogramspermole);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- MolarMass(double numericValue, MolarMassUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerMole.
- ///
- /// Value assuming base unit KilogramPerMole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarMass(long kilogramspermole) : this(Convert.ToDouble(kilogramspermole), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit KilogramPerMole.
- ///
- /// Value assuming base unit KilogramPerMole.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- MolarMass(decimal kilogramspermole) : this(Convert.ToDouble(kilogramspermole), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.MolarMass;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MolarMassUnit BaseUnit => MolarMassUnit.KilogramPerMole;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the MolarMass quantity.
- ///
- public static MolarMassUnit[] Units { get; } = Enum.GetValues(typeof(MolarMassUnit)).Cast().Except(new MolarMassUnit[]{ MolarMassUnit.Undefined }).ToArray();
-
- ///
- /// Get MolarMass in CentigramsPerMole.
- ///
- public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole);
-
- ///
- /// Get MolarMass in DecagramsPerMole.
- ///
- public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole);
-
- ///
- /// Get MolarMass in DecigramsPerMole.
- ///
- public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole);
-
- ///
- /// Get MolarMass in GramsPerMole.
- ///
- public double GramsPerMole => As(MolarMassUnit.GramPerMole);
-
- ///
- /// Get MolarMass in HectogramsPerMole.
- ///
- public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole);
-
- ///
- /// Get MolarMass in KilogramsPerMole.
- ///
- public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole);
-
- ///
- /// Get MolarMass in KilopoundsPerMole.
- ///
- public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole);
-
- ///
- /// Get MolarMass in MegapoundsPerMole.
- ///
- public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole);
-
- ///
- /// Get MolarMass in MicrogramsPerMole.
- ///
- public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole);
-
- ///
- /// Get MolarMass in MilligramsPerMole.
- ///
- public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole);
-
- ///
- /// Get MolarMass in NanogramsPerMole.
- ///
- public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole);
-
- ///
- /// Get MolarMass in PoundsPerMole.
- ///
- public double PoundsPerMole => As(MolarMassUnit.PoundPerMole);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMole.
- ///
- public static MolarMass Zero => new MolarMass(0, BaseUnit);
-
- ///
- /// Get MolarMass from CentigramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromCentigramsPerMole(double centigramspermole)
-#else
- public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole)
-#endif
- {
- double value = (double) centigramspermole;
- return new MolarMass(value, MolarMassUnit.CentigramPerMole);
- }
-
- ///
- /// Get MolarMass from DecagramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromDecagramsPerMole(double decagramspermole)
-#else
- public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole)
-#endif
- {
- double value = (double) decagramspermole;
- return new MolarMass(value, MolarMassUnit.DecagramPerMole);
- }
-
- ///
- /// Get MolarMass from DecigramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromDecigramsPerMole(double decigramspermole)
-#else
- public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole)
-#endif
- {
- double value = (double) decigramspermole;
- return new MolarMass(value, MolarMassUnit.DecigramPerMole);
- }
-
- ///
- /// Get MolarMass from GramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromGramsPerMole(double gramspermole)
-#else
- public static MolarMass FromGramsPerMole(QuantityValue gramspermole)
-#endif
- {
- double value = (double) gramspermole;
- return new MolarMass(value, MolarMassUnit.GramPerMole);
- }
-
- ///
- /// Get MolarMass from HectogramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromHectogramsPerMole(double hectogramspermole)
-#else
- public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole)
-#endif
- {
- double value = (double) hectogramspermole;
- return new MolarMass(value, MolarMassUnit.HectogramPerMole);
- }
-
- ///
- /// Get MolarMass from KilogramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromKilogramsPerMole(double kilogramspermole)
-#else
- public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole)
-#endif
- {
- double value = (double) kilogramspermole;
- return new MolarMass(value, MolarMassUnit.KilogramPerMole);
- }
-
- ///
- /// Get MolarMass from KilopoundsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromKilopoundsPerMole(double kilopoundspermole)
-#else
- public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole)
-#endif
- {
- double value = (double) kilopoundspermole;
- return new MolarMass(value, MolarMassUnit.KilopoundPerMole);
- }
-
- ///
- /// Get MolarMass from MegapoundsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromMegapoundsPerMole(double megapoundspermole)
-#else
- public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole)
-#endif
- {
- double value = (double) megapoundspermole;
- return new MolarMass(value, MolarMassUnit.MegapoundPerMole);
- }
-
- ///
- /// Get MolarMass from MicrogramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromMicrogramsPerMole(double microgramspermole)
-#else
- public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole)
-#endif
- {
- double value = (double) microgramspermole;
- return new MolarMass(value, MolarMassUnit.MicrogramPerMole);
- }
-
- ///
- /// Get MolarMass from MilligramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromMilligramsPerMole(double milligramspermole)
-#else
- public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole)
-#endif
- {
- double value = (double) milligramspermole;
- return new MolarMass(value, MolarMassUnit.MilligramPerMole);
- }
-
- ///
- /// Get MolarMass from NanogramsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromNanogramsPerMole(double nanogramspermole)
-#else
- public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole)
-#endif
- {
- double value = (double) nanogramspermole;
- return new MolarMass(value, MolarMassUnit.NanogramPerMole);
- }
-
- ///
- /// Get MolarMass from PoundsPerMole.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static MolarMass FromPoundsPerMole(double poundspermole)
-#else
- public static MolarMass FromPoundsPerMole(QuantityValue poundspermole)
-#endif
- {
- double value = (double) poundspermole;
- return new MolarMass(value, MolarMassUnit.PoundPerMole);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// MolarMass unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static MolarMass From(double value, MolarMassUnit fromUnit)
-#else
- public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit)
-#endif
- {
- return new MolarMass((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MolarMassUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is MolarMass)) throw new ArgumentException("Expected type MolarMass.", nameof(obj));
-
- return CompareTo((MolarMass)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(MolarMass other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(MolarMass, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is MolarMass))
- return false;
-
- var objQuantity = (MolarMass)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another MolarMass within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another MolarMass 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.
- [Obsolete("Please use the Equals(MolarMass, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(MolarMass other, MolarMass maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current MolarMass.
- public override int GetHashCode()
- {
- return new { type = typeof(MolarMass), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MolarMassUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this MolarMass to another MolarMass with the unit representation .
- ///
- /// A MolarMass with the specified unit.
- public MolarMass ToUnit(MolarMassUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new MolarMass(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MolarMassUnit.CentigramPerMole: return (_value/1e3) * 1e-2d;
- case MolarMassUnit.DecagramPerMole: return (_value/1e3) * 1e1d;
- case MolarMassUnit.DecigramPerMole: return (_value/1e3) * 1e-1d;
- case MolarMassUnit.GramPerMole: return _value/1e3;
- case MolarMassUnit.HectogramPerMole: return (_value/1e3) * 1e2d;
- case MolarMassUnit.KilogramPerMole: return (_value/1e3) * 1e3d;
- case MolarMassUnit.KilopoundPerMole: return (_value*0.45359237) * 1e3d;
- case MolarMassUnit.MegapoundPerMole: return (_value*0.45359237) * 1e6d;
- case MolarMassUnit.MicrogramPerMole: return (_value/1e3) * 1e-6d;
- case MolarMassUnit.MilligramPerMole: return (_value/1e3) * 1e-3d;
- case MolarMassUnit.NanogramPerMole: return (_value/1e3) * 1e-9d;
- case MolarMassUnit.PoundPerMole: return _value*0.45359237;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MolarMassUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MolarMassUnit.CentigramPerMole: return (baseUnitValue*1e3) / 1e-2d;
- case MolarMassUnit.DecagramPerMole: return (baseUnitValue*1e3) / 1e1d;
- case MolarMassUnit.DecigramPerMole: return (baseUnitValue*1e3) / 1e-1d;
- case MolarMassUnit.GramPerMole: return baseUnitValue*1e3;
- case MolarMassUnit.HectogramPerMole: return (baseUnitValue*1e3) / 1e2d;
- case MolarMassUnit.KilogramPerMole: return (baseUnitValue*1e3) / 1e3d;
- case MolarMassUnit.KilopoundPerMole: return (baseUnitValue/0.45359237) / 1e3d;
- case MolarMassUnit.MegapoundPerMole: return (baseUnitValue/0.45359237) / 1e6d;
- case MolarMassUnit.MicrogramPerMole: return (baseUnitValue*1e3) / 1e-6d;
- case MolarMassUnit.MilligramPerMole: return (baseUnitValue*1e3) / 1e-3d;
- case MolarMassUnit.NanogramPerMole: return (baseUnitValue*1e3) / 1e-9d;
- case MolarMassUnit.PoundPerMole: return baseUnitValue/0.45359237;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 MolarMass Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 MolarMass result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MolarMassUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is KilogramPerMole
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MolarMassUnit ToStringDefaultUnit { get; set; } = MolarMassUnit.KilogramPerMole;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MolarMassUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of MolarMass
- ///
- public static MolarMass MaxValue => new MolarMass(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of MolarMass
- ///
- public static MolarMass MinValue => new MolarMass(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => MolarMass.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => MolarMass.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Molarity.Common.g.cs b/Common/GeneratedCode/Quantities/Molarity.Common.g.cs
deleted file mode 100644
index c8a35c446e..0000000000
--- a/Common/GeneratedCode/Quantities/Molarity.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume.
- ///
- // 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 Molarity : IQuantity
-#else
- public partial struct Molarity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly MolarityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public MolarityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Molarity()
- {
- BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit MolesPerCubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Molarity(double molespercubicmeter)
- {
- _value = Convert.ToDouble(molespercubicmeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Molarity(double numericValue, MolarityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MolesPerCubicMeter.
- ///
- /// Value assuming base unit MolesPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Molarity(long molespercubicmeter) : this(Convert.ToDouble(molespercubicmeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MolesPerCubicMeter.
- ///
- /// Value assuming base unit MolesPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Molarity(decimal molespercubicmeter) : this(Convert.ToDouble(molespercubicmeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Molarity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static MolarityUnit BaseUnit => MolarityUnit.MolesPerCubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Molarity quantity.
- ///
- public static MolarityUnit[] Units { get; } = Enum.GetValues(typeof(MolarityUnit)).Cast().Except(new MolarityUnit[]{ MolarityUnit.Undefined }).ToArray();
-
- ///
- /// Get Molarity in CentimolesPerLiter.
- ///
- public double CentimolesPerLiter => As(MolarityUnit.CentimolesPerLiter);
-
- ///
- /// Get Molarity in DecimolesPerLiter.
- ///
- public double DecimolesPerLiter => As(MolarityUnit.DecimolesPerLiter);
-
- ///
- /// Get Molarity in MicromolesPerLiter.
- ///
- public double MicromolesPerLiter => As(MolarityUnit.MicromolesPerLiter);
-
- ///
- /// Get Molarity in MillimolesPerLiter.
- ///
- public double MillimolesPerLiter => As(MolarityUnit.MillimolesPerLiter);
-
- ///
- /// Get Molarity in MolesPerCubicMeter.
- ///
- public double MolesPerCubicMeter => As(MolarityUnit.MolesPerCubicMeter);
-
- ///
- /// Get Molarity in MolesPerLiter.
- ///
- public double MolesPerLiter => As(MolarityUnit.MolesPerLiter);
-
- ///
- /// Get Molarity in NanomolesPerLiter.
- ///
- public double NanomolesPerLiter => As(MolarityUnit.NanomolesPerLiter);
-
- ///
- /// Get Molarity in PicomolesPerLiter.
- ///
- public double PicomolesPerLiter => As(MolarityUnit.PicomolesPerLiter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit MolesPerCubicMeter.
- ///
- public static Molarity Zero => new Molarity(0, BaseUnit);
-
- ///
- /// Get Molarity from CentimolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromCentimolesPerLiter(double centimolesperliter)
-#else
- public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter)
-#endif
- {
- double value = (double) centimolesperliter;
- return new Molarity(value, MolarityUnit.CentimolesPerLiter);
- }
-
- ///
- /// Get Molarity from DecimolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromDecimolesPerLiter(double decimolesperliter)
-#else
- public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter)
-#endif
- {
- double value = (double) decimolesperliter;
- return new Molarity(value, MolarityUnit.DecimolesPerLiter);
- }
-
- ///
- /// Get Molarity from MicromolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromMicromolesPerLiter(double micromolesperliter)
-#else
- public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter)
-#endif
- {
- double value = (double) micromolesperliter;
- return new Molarity(value, MolarityUnit.MicromolesPerLiter);
- }
-
- ///
- /// Get Molarity from MillimolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromMillimolesPerLiter(double millimolesperliter)
-#else
- public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter)
-#endif
- {
- double value = (double) millimolesperliter;
- return new Molarity(value, MolarityUnit.MillimolesPerLiter);
- }
-
- ///
- /// Get Molarity from MolesPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromMolesPerCubicMeter(double molespercubicmeter)
-#else
- public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter)
-#endif
- {
- double value = (double) molespercubicmeter;
- return new Molarity(value, MolarityUnit.MolesPerCubicMeter);
- }
-
- ///
- /// Get Molarity from MolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromMolesPerLiter(double molesperliter)
-#else
- public static Molarity FromMolesPerLiter(QuantityValue molesperliter)
-#endif
- {
- double value = (double) molesperliter;
- return new Molarity(value, MolarityUnit.MolesPerLiter);
- }
-
- ///
- /// Get Molarity from NanomolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromNanomolesPerLiter(double nanomolesperliter)
-#else
- public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter)
-#endif
- {
- double value = (double) nanomolesperliter;
- return new Molarity(value, MolarityUnit.NanomolesPerLiter);
- }
-
- ///
- /// Get Molarity from PicomolesPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Molarity FromPicomolesPerLiter(double picomolesperliter)
-#else
- public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter)
-#endif
- {
- double value = (double) picomolesperliter;
- return new Molarity(value, MolarityUnit.PicomolesPerLiter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Molarity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Molarity From(double value, MolarityUnit fromUnit)
-#else
- public static Molarity From(QuantityValue value, MolarityUnit fromUnit)
-#endif
- {
- return new Molarity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(MolarityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Molarity)) throw new ArgumentException("Expected type Molarity.", nameof(obj));
-
- return CompareTo((Molarity)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(Molarity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Molarity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Molarity))
- return false;
-
- var objQuantity = (Molarity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Molarity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Molarity 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.
- [Obsolete("Please use the Equals(Molarity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Molarity other, Molarity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Molarity.
- public override int GetHashCode()
- {
- return new { type = typeof(Molarity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(MolarityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Molarity to another Molarity with the unit representation .
- ///
- /// A Molarity with the specified unit.
- public Molarity ToUnit(MolarityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Molarity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case MolarityUnit.CentimolesPerLiter: return (_value/1e-3) * 1e-2d;
- case MolarityUnit.DecimolesPerLiter: return (_value/1e-3) * 1e-1d;
- case MolarityUnit.MicromolesPerLiter: return (_value/1e-3) * 1e-6d;
- case MolarityUnit.MillimolesPerLiter: return (_value/1e-3) * 1e-3d;
- case MolarityUnit.MolesPerCubicMeter: return _value;
- case MolarityUnit.MolesPerLiter: return _value/1e-3;
- case MolarityUnit.NanomolesPerLiter: return (_value/1e-3) * 1e-9d;
- case MolarityUnit.PicomolesPerLiter: return (_value/1e-3) * 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(MolarityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case MolarityUnit.CentimolesPerLiter: return (baseUnitValue*1e-3) / 1e-2d;
- case MolarityUnit.DecimolesPerLiter: return (baseUnitValue*1e-3) / 1e-1d;
- case MolarityUnit.MicromolesPerLiter: return (baseUnitValue*1e-3) / 1e-6d;
- case MolarityUnit.MillimolesPerLiter: return (baseUnitValue*1e-3) / 1e-3d;
- case MolarityUnit.MolesPerCubicMeter: return baseUnitValue;
- case MolarityUnit.MolesPerLiter: return baseUnitValue*1e-3;
- case MolarityUnit.NanomolesPerLiter: return (baseUnitValue*1e-3) / 1e-9d;
- case MolarityUnit.PicomolesPerLiter: return (baseUnitValue*1e-3) / 1e-12d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Molarity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Molarity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static MolarityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is MolesPerCubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static MolarityUnit ToStringDefaultUnit { get; set; } = MolarityUnit.MolesPerCubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(MolarityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Molarity
- ///
- public static Molarity MaxValue => new Molarity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Molarity
- ///
- public static Molarity MinValue => new Molarity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Molarity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Molarity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Permeability.Common.g.cs b/Common/GeneratedCode/Quantities/Permeability.Common.g.cs
deleted file mode 100644
index c49a813a9b..0000000000
--- a/Common/GeneratedCode/Quantities/Permeability.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself.
- ///
- // 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 Permeability : IQuantity
-#else
- public partial struct Permeability : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PermeabilityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PermeabilityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Permeability()
- {
- BaseDimensions = new BaseDimensions(1, 1, -2, -2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit HenryPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Permeability(double henriespermeter)
- {
- _value = Convert.ToDouble(henriespermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Permeability(double numericValue, PermeabilityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit HenryPerMeter.
- ///
- /// Value assuming base unit HenryPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Permeability(long henriespermeter) : this(Convert.ToDouble(henriespermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit HenryPerMeter.
- ///
- /// Value assuming base unit HenryPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Permeability(decimal henriespermeter) : this(Convert.ToDouble(henriespermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Permeability;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PermeabilityUnit BaseUnit => PermeabilityUnit.HenryPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Permeability quantity.
- ///
- public static PermeabilityUnit[] Units { get; } = Enum.GetValues(typeof(PermeabilityUnit)).Cast().Except(new PermeabilityUnit[]{ PermeabilityUnit.Undefined }).ToArray();
-
- ///
- /// Get Permeability in HenriesPerMeter.
- ///
- public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit HenryPerMeter.
- ///
- public static Permeability Zero => new Permeability(0, BaseUnit);
-
- ///
- /// Get Permeability from HenriesPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Permeability FromHenriesPerMeter(double henriespermeter)
-#else
- public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter)
-#endif
- {
- double value = (double) henriespermeter;
- return new Permeability(value, PermeabilityUnit.HenryPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Permeability unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Permeability From(double value, PermeabilityUnit fromUnit)
-#else
- public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit)
-#endif
- {
- return new Permeability((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PermeabilityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Permeability)) throw new ArgumentException("Expected type Permeability.", nameof(obj));
-
- return CompareTo((Permeability)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(Permeability other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Permeability, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Permeability))
- return false;
-
- var objQuantity = (Permeability)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Permeability within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Permeability 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.
- [Obsolete("Please use the Equals(Permeability, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Permeability other, Permeability maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Permeability.
- public override int GetHashCode()
- {
- return new { type = typeof(Permeability), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PermeabilityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Permeability to another Permeability with the unit representation .
- ///
- /// A Permeability with the specified unit.
- public Permeability ToUnit(PermeabilityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Permeability(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PermeabilityUnit.HenryPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PermeabilityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PermeabilityUnit.HenryPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Permeability Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Permeability result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PermeabilityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is HenryPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PermeabilityUnit ToStringDefaultUnit { get; set; } = PermeabilityUnit.HenryPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PermeabilityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Permeability
- ///
- public static Permeability MaxValue => new Permeability(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Permeability
- ///
- public static Permeability MinValue => new Permeability(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Permeability.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Permeability.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Permittivity.Common.g.cs b/Common/GeneratedCode/Quantities/Permittivity.Common.g.cs
deleted file mode 100644
index 7df7c4a6a4..0000000000
--- a/Common/GeneratedCode/Quantities/Permittivity.Common.g.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium.
- ///
- // 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 Permittivity : IQuantity
-#else
- public partial struct Permittivity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PermittivityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PermittivityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Permittivity()
- {
- BaseDimensions = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit FaradPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Permittivity(double faradspermeter)
- {
- _value = Convert.ToDouble(faradspermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Permittivity(double numericValue, PermittivityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit FaradPerMeter.
- ///
- /// Value assuming base unit FaradPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Permittivity(long faradspermeter) : this(Convert.ToDouble(faradspermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit FaradPerMeter.
- ///
- /// Value assuming base unit FaradPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Permittivity(decimal faradspermeter) : this(Convert.ToDouble(faradspermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Permittivity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PermittivityUnit BaseUnit => PermittivityUnit.FaradPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Permittivity quantity.
- ///
- public static PermittivityUnit[] Units { get; } = Enum.GetValues(typeof(PermittivityUnit)).Cast().Except(new PermittivityUnit[]{ PermittivityUnit.Undefined }).ToArray();
-
- ///
- /// Get Permittivity in FaradsPerMeter.
- ///
- public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit FaradPerMeter.
- ///
- public static Permittivity Zero => new Permittivity(0, BaseUnit);
-
- ///
- /// Get Permittivity from FaradsPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Permittivity FromFaradsPerMeter(double faradspermeter)
-#else
- public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter)
-#endif
- {
- double value = (double) faradspermeter;
- return new Permittivity(value, PermittivityUnit.FaradPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Permittivity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Permittivity From(double value, PermittivityUnit fromUnit)
-#else
- public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit)
-#endif
- {
- return new Permittivity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PermittivityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Permittivity)) throw new ArgumentException("Expected type Permittivity.", nameof(obj));
-
- return CompareTo((Permittivity)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(Permittivity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Permittivity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Permittivity))
- return false;
-
- var objQuantity = (Permittivity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Permittivity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Permittivity 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.
- [Obsolete("Please use the Equals(Permittivity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Permittivity other, Permittivity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Permittivity.
- public override int GetHashCode()
- {
- return new { type = typeof(Permittivity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PermittivityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Permittivity to another Permittivity with the unit representation .
- ///
- /// A Permittivity with the specified unit.
- public Permittivity ToUnit(PermittivityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Permittivity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PermittivityUnit.FaradPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PermittivityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PermittivityUnit.FaradPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Permittivity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Permittivity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PermittivityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is FaradPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PermittivityUnit ToStringDefaultUnit { get; set; } = PermittivityUnit.FaradPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PermittivityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Permittivity
- ///
- public static Permittivity MaxValue => new Permittivity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Permittivity
- ///
- public static Permittivity MinValue => new Permittivity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Permittivity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Permittivity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Power.Common.g.cs b/Common/GeneratedCode/Quantities/Power.Common.g.cs
deleted file mode 100644
index 146d3f210b..0000000000
--- a/Common/GeneratedCode/Quantities/Power.Common.g.cs
+++ /dev/null
@@ -1,888 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.
- ///
- // 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 Power : IQuantity
-#else
- public partial struct Power : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly decimal _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PowerUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PowerUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Power()
- {
- BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Watt.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Power(double watts)
- {
- _value = Convert.ToDecimal(watts);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Power(decimal numericValue, PowerUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Watt.
- ///
- /// Value assuming base unit Watt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Power(long watts) : this(Convert.ToDecimal(watts), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Watt.
- ///
- /// Value assuming base unit Watt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Power(decimal watts) : this(Convert.ToDecimal(watts), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Power;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PowerUnit BaseUnit => PowerUnit.Watt;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Power quantity.
- ///
- public static PowerUnit[] Units { get; } = Enum.GetValues(typeof(PowerUnit)).Cast().Except(new PowerUnit[]{ PowerUnit.Undefined }).ToArray();
-
- ///
- /// Get Power in BoilerHorsepower.
- ///
- public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower);
-
- ///
- /// Get Power in BritishThermalUnitsPerHour.
- ///
- public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour);
-
- ///
- /// Get Power in Decawatts.
- ///
- public double Decawatts => As(PowerUnit.Decawatt);
-
- ///
- /// Get Power in Deciwatts.
- ///
- public double Deciwatts => As(PowerUnit.Deciwatt);
-
- ///
- /// Get Power in ElectricalHorsepower.
- ///
- public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower);
-
- ///
- /// Get Power in Femtowatts.
- ///
- public double Femtowatts => As(PowerUnit.Femtowatt);
-
- ///
- /// Get Power in Gigawatts.
- ///
- public double Gigawatts => As(PowerUnit.Gigawatt);
-
- ///
- /// Get Power in HydraulicHorsepower.
- ///
- public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower);
-
- ///
- /// Get Power in KilobritishThermalUnitsPerHour.
- ///
- public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour);
-
- ///
- /// Get Power in Kilowatts.
- ///
- public double Kilowatts => As(PowerUnit.Kilowatt);
-
- ///
- /// Get Power in MechanicalHorsepower.
- ///
- public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower);
-
- ///
- /// Get Power in Megawatts.
- ///
- public double Megawatts => As(PowerUnit.Megawatt);
-
- ///
- /// Get Power in MetricHorsepower.
- ///
- public double MetricHorsepower => As(PowerUnit.MetricHorsepower);
-
- ///
- /// Get Power in Microwatts.
- ///
- public double Microwatts => As(PowerUnit.Microwatt);
-
- ///
- /// Get Power in Milliwatts.
- ///
- public double Milliwatts => As(PowerUnit.Milliwatt);
-
- ///
- /// Get Power in Nanowatts.
- ///
- public double Nanowatts => As(PowerUnit.Nanowatt);
-
- ///
- /// Get Power in Petawatts.
- ///
- public double Petawatts => As(PowerUnit.Petawatt);
-
- ///
- /// Get Power in Picowatts.
- ///
- public double Picowatts => As(PowerUnit.Picowatt);
-
- ///
- /// Get Power in Terawatts.
- ///
- public double Terawatts => As(PowerUnit.Terawatt);
-
- ///
- /// Get Power in Watts.
- ///
- public double Watts => As(PowerUnit.Watt);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Watt.
- ///
- public static Power Zero => new Power(0, BaseUnit);
-
- ///
- /// Get Power from BoilerHorsepower.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromBoilerHorsepower(double boilerhorsepower)
-#else
- public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower)
-#endif
- {
- decimal value = (decimal) boilerhorsepower;
- return new Power(value, PowerUnit.BoilerHorsepower);
- }
-
- ///
- /// Get Power from BritishThermalUnitsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromBritishThermalUnitsPerHour(double britishthermalunitsperhour)
-#else
- public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalunitsperhour)
-#endif
- {
- decimal value = (decimal) britishthermalunitsperhour;
- return new Power(value, PowerUnit.BritishThermalUnitPerHour);
- }
-
- ///
- /// Get Power from Decawatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromDecawatts(double decawatts)
-#else
- public static Power FromDecawatts(QuantityValue decawatts)
-#endif
- {
- decimal value = (decimal) decawatts;
- return new Power(value, PowerUnit.Decawatt);
- }
-
- ///
- /// Get Power from Deciwatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromDeciwatts(double deciwatts)
-#else
- public static Power FromDeciwatts(QuantityValue deciwatts)
-#endif
- {
- decimal value = (decimal) deciwatts;
- return new Power(value, PowerUnit.Deciwatt);
- }
-
- ///
- /// Get Power from ElectricalHorsepower.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromElectricalHorsepower(double electricalhorsepower)
-#else
- public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower)
-#endif
- {
- decimal value = (decimal) electricalhorsepower;
- return new Power(value, PowerUnit.ElectricalHorsepower);
- }
-
- ///
- /// Get Power from Femtowatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromFemtowatts(double femtowatts)
-#else
- public static Power FromFemtowatts(QuantityValue femtowatts)
-#endif
- {
- decimal value = (decimal) femtowatts;
- return new Power(value, PowerUnit.Femtowatt);
- }
-
- ///
- /// Get Power from Gigawatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromGigawatts(double gigawatts)
-#else
- public static Power FromGigawatts(QuantityValue gigawatts)
-#endif
- {
- decimal value = (decimal) gigawatts;
- return new Power(value, PowerUnit.Gigawatt);
- }
-
- ///
- /// Get Power from HydraulicHorsepower.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromHydraulicHorsepower(double hydraulichorsepower)
-#else
- public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower)
-#endif
- {
- decimal value = (decimal) hydraulichorsepower;
- return new Power(value, PowerUnit.HydraulicHorsepower);
- }
-
- ///
- /// Get Power from KilobritishThermalUnitsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromKilobritishThermalUnitsPerHour(double kilobritishthermalunitsperhour)
-#else
- public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritishthermalunitsperhour)
-#endif
- {
- decimal value = (decimal) kilobritishthermalunitsperhour;
- return new Power(value, PowerUnit.KilobritishThermalUnitPerHour);
- }
-
- ///
- /// Get Power from Kilowatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromKilowatts(double kilowatts)
-#else
- public static Power FromKilowatts(QuantityValue kilowatts)
-#endif
- {
- decimal value = (decimal) kilowatts;
- return new Power(value, PowerUnit.Kilowatt);
- }
-
- ///
- /// Get Power from MechanicalHorsepower.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromMechanicalHorsepower(double mechanicalhorsepower)
-#else
- public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower)
-#endif
- {
- decimal value = (decimal) mechanicalhorsepower;
- return new Power(value, PowerUnit.MechanicalHorsepower);
- }
-
- ///
- /// Get Power from Megawatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromMegawatts(double megawatts)
-#else
- public static Power FromMegawatts(QuantityValue megawatts)
-#endif
- {
- decimal value = (decimal) megawatts;
- return new Power(value, PowerUnit.Megawatt);
- }
-
- ///
- /// Get Power from MetricHorsepower.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromMetricHorsepower(double metrichorsepower)
-#else
- public static Power FromMetricHorsepower(QuantityValue metrichorsepower)
-#endif
- {
- decimal value = (decimal) metrichorsepower;
- return new Power(value, PowerUnit.MetricHorsepower);
- }
-
- ///
- /// Get Power from Microwatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromMicrowatts(double microwatts)
-#else
- public static Power FromMicrowatts(QuantityValue microwatts)
-#endif
- {
- decimal value = (decimal) microwatts;
- return new Power(value, PowerUnit.Microwatt);
- }
-
- ///
- /// Get Power from Milliwatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromMilliwatts(double milliwatts)
-#else
- public static Power FromMilliwatts(QuantityValue milliwatts)
-#endif
- {
- decimal value = (decimal) milliwatts;
- return new Power(value, PowerUnit.Milliwatt);
- }
-
- ///
- /// Get Power from Nanowatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromNanowatts(double nanowatts)
-#else
- public static Power FromNanowatts(QuantityValue nanowatts)
-#endif
- {
- decimal value = (decimal) nanowatts;
- return new Power(value, PowerUnit.Nanowatt);
- }
-
- ///
- /// Get Power from Petawatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromPetawatts(double petawatts)
-#else
- public static Power FromPetawatts(QuantityValue petawatts)
-#endif
- {
- decimal value = (decimal) petawatts;
- return new Power(value, PowerUnit.Petawatt);
- }
-
- ///
- /// Get Power from Picowatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromPicowatts(double picowatts)
-#else
- public static Power FromPicowatts(QuantityValue picowatts)
-#endif
- {
- decimal value = (decimal) picowatts;
- return new Power(value, PowerUnit.Picowatt);
- }
-
- ///
- /// Get Power from Terawatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromTerawatts(double terawatts)
-#else
- public static Power FromTerawatts(QuantityValue terawatts)
-#endif
- {
- decimal value = (decimal) terawatts;
- return new Power(value, PowerUnit.Terawatt);
- }
-
- ///
- /// Get Power from Watts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Power FromWatts(double watts)
-#else
- public static Power FromWatts(QuantityValue watts)
-#endif
- {
- decimal value = (decimal) watts;
- return new Power(value, PowerUnit.Watt);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Power unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Power From(double value, PowerUnit fromUnit)
-#else
- public static Power From(QuantityValue value, PowerUnit fromUnit)
-#endif
- {
- return new Power((decimal)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PowerUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Power)) throw new ArgumentException("Expected type Power.", nameof(obj));
-
- return CompareTo((Power)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(Power other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Power))
- return false;
-
- var objQuantity = (Power)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Power within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Power other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Power 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.
- [Obsolete("Please use the Equals(Power, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Power other, Power maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Power.
- public override int GetHashCode()
- {
- return new { type = typeof(Power), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PowerUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Power to another Power with the unit representation .
- ///
- /// A Power with the specified unit.
- public Power ToUnit(PowerUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Power(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private decimal AsBaseUnit()
- {
- switch(Unit)
- {
- case PowerUnit.BoilerHorsepower: return _value*9812.5m;
- case PowerUnit.BritishThermalUnitPerHour: return _value*0.293071m;
- case PowerUnit.Decawatt: return (_value) * 1e1m;
- case PowerUnit.Deciwatt: return (_value) * 1e-1m;
- case PowerUnit.ElectricalHorsepower: return _value*746m;
- case PowerUnit.Femtowatt: return (_value) * 1e-15m;
- case PowerUnit.Gigawatt: return (_value) * 1e9m;
- case PowerUnit.HydraulicHorsepower: return _value*745.69988145m;
- case PowerUnit.KilobritishThermalUnitPerHour: return (_value*0.293071m) * 1e3m;
- case PowerUnit.Kilowatt: return (_value) * 1e3m;
- case PowerUnit.MechanicalHorsepower: return _value*745.69m;
- case PowerUnit.Megawatt: return (_value) * 1e6m;
- case PowerUnit.MetricHorsepower: return _value*735.49875m;
- case PowerUnit.Microwatt: return (_value) * 1e-6m;
- case PowerUnit.Milliwatt: return (_value) * 1e-3m;
- case PowerUnit.Nanowatt: return (_value) * 1e-9m;
- case PowerUnit.Petawatt: return (_value) * 1e15m;
- case PowerUnit.Picowatt: return (_value) * 1e-12m;
- case PowerUnit.Terawatt: return (_value) * 1e12m;
- case PowerUnit.Watt: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private decimal AsBaseNumericType(PowerUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PowerUnit.BoilerHorsepower: return baseUnitValue/9812.5m;
- case PowerUnit.BritishThermalUnitPerHour: return baseUnitValue/0.293071m;
- case PowerUnit.Decawatt: return (baseUnitValue) / 1e1m;
- case PowerUnit.Deciwatt: return (baseUnitValue) / 1e-1m;
- case PowerUnit.ElectricalHorsepower: return baseUnitValue/746m;
- case PowerUnit.Femtowatt: return (baseUnitValue) / 1e-15m;
- case PowerUnit.Gigawatt: return (baseUnitValue) / 1e9m;
- case PowerUnit.HydraulicHorsepower: return baseUnitValue/745.69988145m;
- case PowerUnit.KilobritishThermalUnitPerHour: return (baseUnitValue/0.293071m) / 1e3m;
- case PowerUnit.Kilowatt: return (baseUnitValue) / 1e3m;
- case PowerUnit.MechanicalHorsepower: return baseUnitValue/745.69m;
- case PowerUnit.Megawatt: return (baseUnitValue) / 1e6m;
- case PowerUnit.MetricHorsepower: return baseUnitValue/735.49875m;
- case PowerUnit.Microwatt: return (baseUnitValue) / 1e-6m;
- case PowerUnit.Milliwatt: return (baseUnitValue) / 1e-3m;
- case PowerUnit.Nanowatt: return (baseUnitValue) / 1e-9m;
- case PowerUnit.Petawatt: return (baseUnitValue) / 1e15m;
- case PowerUnit.Picowatt: return (baseUnitValue) / 1e-12m;
- case PowerUnit.Terawatt: return (baseUnitValue) / 1e12m;
- case PowerUnit.Watt: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Power Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Power result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PowerUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Watt
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PowerUnit ToStringDefaultUnit { get; set; } = PowerUnit.Watt;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PowerUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Power
- ///
- public static Power MaxValue => new Power(decimal.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Power
- ///
- public static Power MinValue => new Power(decimal.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Power.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Power.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/PowerDensity.Common.g.cs b/Common/GeneratedCode/Quantities/PowerDensity.Common.g.cs
deleted file mode 100644
index 6e8e0e010c..0000000000
--- a/Common/GeneratedCode/Quantities/PowerDensity.Common.g.cs
+++ /dev/null
@@ -1,1393 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The amount of power in a volume.
- ///
- // 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 PowerDensity : IQuantity
-#else
- public partial struct PowerDensity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PowerDensityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static PowerDensity()
- {
- BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit WattPerCubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public PowerDensity(double wattspercubicmeter)
- {
- _value = Convert.ToDouble(wattspercubicmeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- PowerDensity(double numericValue, PowerDensityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerCubicMeter.
- ///
- /// Value assuming base unit WattPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PowerDensity(long wattspercubicmeter) : this(Convert.ToDouble(wattspercubicmeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerCubicMeter.
- ///
- /// Value assuming base unit WattPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PowerDensity(decimal wattspercubicmeter) : this(Convert.ToDouble(wattspercubicmeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.PowerDensity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PowerDensityUnit BaseUnit => PowerDensityUnit.WattPerCubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the PowerDensity quantity.
- ///
- public static PowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(PowerDensityUnit)).Cast().Except(new PowerDensityUnit[]{ PowerDensityUnit.Undefined }).ToArray();
-
- ///
- /// Get PowerDensity in DecawattsPerCubicFoot.
- ///
- public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot);
-
- ///
- /// Get PowerDensity in DecawattsPerCubicInch.
- ///
- public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch);
-
- ///
- /// Get PowerDensity in DecawattsPerCubicMeter.
- ///
- public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter);
-
- ///
- /// Get PowerDensity in DecawattsPerLiter.
- ///
- public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter);
-
- ///
- /// Get PowerDensity in DeciwattsPerCubicFoot.
- ///
- public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot);
-
- ///
- /// Get PowerDensity in DeciwattsPerCubicInch.
- ///
- public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch);
-
- ///
- /// Get PowerDensity in DeciwattsPerCubicMeter.
- ///
- public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter);
-
- ///
- /// Get PowerDensity in DeciwattsPerLiter.
- ///
- public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter);
-
- ///
- /// Get PowerDensity in GigawattsPerCubicFoot.
- ///
- public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot);
-
- ///
- /// Get PowerDensity in GigawattsPerCubicInch.
- ///
- public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch);
-
- ///
- /// Get PowerDensity in GigawattsPerCubicMeter.
- ///
- public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter);
-
- ///
- /// Get PowerDensity in GigawattsPerLiter.
- ///
- public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter);
-
- ///
- /// Get PowerDensity in KilowattsPerCubicFoot.
- ///
- public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot);
-
- ///
- /// Get PowerDensity in KilowattsPerCubicInch.
- ///
- public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch);
-
- ///
- /// Get PowerDensity in KilowattsPerCubicMeter.
- ///
- public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter);
-
- ///
- /// Get PowerDensity in KilowattsPerLiter.
- ///
- public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter);
-
- ///
- /// Get PowerDensity in MegawattsPerCubicFoot.
- ///
- public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot);
-
- ///
- /// Get PowerDensity in MegawattsPerCubicInch.
- ///
- public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch);
-
- ///
- /// Get PowerDensity in MegawattsPerCubicMeter.
- ///
- public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter);
-
- ///
- /// Get PowerDensity in MegawattsPerLiter.
- ///
- public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter);
-
- ///
- /// Get PowerDensity in MicrowattsPerCubicFoot.
- ///
- public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot);
-
- ///
- /// Get PowerDensity in MicrowattsPerCubicInch.
- ///
- public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch);
-
- ///
- /// Get PowerDensity in MicrowattsPerCubicMeter.
- ///
- public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter);
-
- ///
- /// Get PowerDensity in MicrowattsPerLiter.
- ///
- public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter);
-
- ///
- /// Get PowerDensity in MilliwattsPerCubicFoot.
- ///
- public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot);
-
- ///
- /// Get PowerDensity in MilliwattsPerCubicInch.
- ///
- public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch);
-
- ///
- /// Get PowerDensity in MilliwattsPerCubicMeter.
- ///
- public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter);
-
- ///
- /// Get PowerDensity in MilliwattsPerLiter.
- ///
- public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter);
-
- ///
- /// Get PowerDensity in NanowattsPerCubicFoot.
- ///
- public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot);
-
- ///
- /// Get PowerDensity in NanowattsPerCubicInch.
- ///
- public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch);
-
- ///
- /// Get PowerDensity in NanowattsPerCubicMeter.
- ///
- public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter);
-
- ///
- /// Get PowerDensity in NanowattsPerLiter.
- ///
- public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter);
-
- ///
- /// Get PowerDensity in PicowattsPerCubicFoot.
- ///
- public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot);
-
- ///
- /// Get PowerDensity in PicowattsPerCubicInch.
- ///
- public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch);
-
- ///
- /// Get PowerDensity in PicowattsPerCubicMeter.
- ///
- public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter);
-
- ///
- /// Get PowerDensity in PicowattsPerLiter.
- ///
- public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter);
-
- ///
- /// Get PowerDensity in TerawattsPerCubicFoot.
- ///
- public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot);
-
- ///
- /// Get PowerDensity in TerawattsPerCubicInch.
- ///
- public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch);
-
- ///
- /// Get PowerDensity in TerawattsPerCubicMeter.
- ///
- public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter);
-
- ///
- /// Get PowerDensity in TerawattsPerLiter.
- ///
- public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter);
-
- ///
- /// Get PowerDensity in WattsPerCubicFoot.
- ///
- public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot);
-
- ///
- /// Get PowerDensity in WattsPerCubicInch.
- ///
- public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch);
-
- ///
- /// Get PowerDensity in WattsPerCubicMeter.
- ///
- public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter);
-
- ///
- /// Get PowerDensity in WattsPerLiter.
- ///
- public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit WattPerCubicMeter.
- ///
- public static PowerDensity Zero => new PowerDensity(0, BaseUnit);
-
- ///
- /// Get PowerDensity from DecawattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDecawattsPerCubicFoot(double decawattspercubicfoot)
-#else
- public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattspercubicfoot)
-#endif
- {
- double value = (double) decawattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from DecawattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDecawattsPerCubicInch(double decawattspercubicinch)
-#else
- public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattspercubicinch)
-#endif
- {
- double value = (double) decawattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from DecawattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDecawattsPerCubicMeter(double decawattspercubicmeter)
-#else
- public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattspercubicmeter)
-#endif
- {
- double value = (double) decawattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from DecawattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDecawattsPerLiter(double decawattsperliter)
-#else
- public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter)
-#endif
- {
- double value = (double) decawattsperliter;
- return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter);
- }
-
- ///
- /// Get PowerDensity from DeciwattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDeciwattsPerCubicFoot(double deciwattspercubicfoot)
-#else
- public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattspercubicfoot)
-#endif
- {
- double value = (double) deciwattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from DeciwattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDeciwattsPerCubicInch(double deciwattspercubicinch)
-#else
- public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattspercubicinch)
-#endif
- {
- double value = (double) deciwattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from DeciwattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDeciwattsPerCubicMeter(double deciwattspercubicmeter)
-#else
- public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattspercubicmeter)
-#endif
- {
- double value = (double) deciwattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from DeciwattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromDeciwattsPerLiter(double deciwattsperliter)
-#else
- public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter)
-#endif
- {
- double value = (double) deciwattsperliter;
- return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter);
- }
-
- ///
- /// Get PowerDensity from GigawattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromGigawattsPerCubicFoot(double gigawattspercubicfoot)
-#else
- public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattspercubicfoot)
-#endif
- {
- double value = (double) gigawattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from GigawattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromGigawattsPerCubicInch(double gigawattspercubicinch)
-#else
- public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattspercubicinch)
-#endif
- {
- double value = (double) gigawattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from GigawattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromGigawattsPerCubicMeter(double gigawattspercubicmeter)
-#else
- public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattspercubicmeter)
-#endif
- {
- double value = (double) gigawattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from GigawattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromGigawattsPerLiter(double gigawattsperliter)
-#else
- public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter)
-#endif
- {
- double value = (double) gigawattsperliter;
- return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter);
- }
-
- ///
- /// Get PowerDensity from KilowattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromKilowattsPerCubicFoot(double kilowattspercubicfoot)
-#else
- public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattspercubicfoot)
-#endif
- {
- double value = (double) kilowattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from KilowattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromKilowattsPerCubicInch(double kilowattspercubicinch)
-#else
- public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattspercubicinch)
-#endif
- {
- double value = (double) kilowattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from KilowattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromKilowattsPerCubicMeter(double kilowattspercubicmeter)
-#else
- public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattspercubicmeter)
-#endif
- {
- double value = (double) kilowattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from KilowattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromKilowattsPerLiter(double kilowattsperliter)
-#else
- public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter)
-#endif
- {
- double value = (double) kilowattsperliter;
- return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter);
- }
-
- ///
- /// Get PowerDensity from MegawattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMegawattsPerCubicFoot(double megawattspercubicfoot)
-#else
- public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattspercubicfoot)
-#endif
- {
- double value = (double) megawattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from MegawattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMegawattsPerCubicInch(double megawattspercubicinch)
-#else
- public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattspercubicinch)
-#endif
- {
- double value = (double) megawattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from MegawattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMegawattsPerCubicMeter(double megawattspercubicmeter)
-#else
- public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattspercubicmeter)
-#endif
- {
- double value = (double) megawattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from MegawattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMegawattsPerLiter(double megawattsperliter)
-#else
- public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter)
-#endif
- {
- double value = (double) megawattsperliter;
- return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter);
- }
-
- ///
- /// Get PowerDensity from MicrowattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMicrowattsPerCubicFoot(double microwattspercubicfoot)
-#else
- public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspercubicfoot)
-#endif
- {
- double value = (double) microwattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from MicrowattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMicrowattsPerCubicInch(double microwattspercubicinch)
-#else
- public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspercubicinch)
-#endif
- {
- double value = (double) microwattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from MicrowattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMicrowattsPerCubicMeter(double microwattspercubicmeter)
-#else
- public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattspercubicmeter)
-#endif
- {
- double value = (double) microwattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from MicrowattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMicrowattsPerLiter(double microwattsperliter)
-#else
- public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperliter)
-#endif
- {
- double value = (double) microwattsperliter;
- return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter);
- }
-
- ///
- /// Get PowerDensity from MilliwattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMilliwattsPerCubicFoot(double milliwattspercubicfoot)
-#else
- public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspercubicfoot)
-#endif
- {
- double value = (double) milliwattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from MilliwattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMilliwattsPerCubicInch(double milliwattspercubicinch)
-#else
- public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspercubicinch)
-#endif
- {
- double value = (double) milliwattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from MilliwattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMilliwattsPerCubicMeter(double milliwattspercubicmeter)
-#else
- public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattspercubicmeter)
-#endif
- {
- double value = (double) milliwattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from MilliwattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromMilliwattsPerLiter(double milliwattsperliter)
-#else
- public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperliter)
-#endif
- {
- double value = (double) milliwattsperliter;
- return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter);
- }
-
- ///
- /// Get PowerDensity from NanowattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromNanowattsPerCubicFoot(double nanowattspercubicfoot)
-#else
- public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattspercubicfoot)
-#endif
- {
- double value = (double) nanowattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from NanowattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromNanowattsPerCubicInch(double nanowattspercubicinch)
-#else
- public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattspercubicinch)
-#endif
- {
- double value = (double) nanowattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from NanowattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromNanowattsPerCubicMeter(double nanowattspercubicmeter)
-#else
- public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattspercubicmeter)
-#endif
- {
- double value = (double) nanowattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from NanowattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromNanowattsPerLiter(double nanowattsperliter)
-#else
- public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter)
-#endif
- {
- double value = (double) nanowattsperliter;
- return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter);
- }
-
- ///
- /// Get PowerDensity from PicowattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromPicowattsPerCubicFoot(double picowattspercubicfoot)
-#else
- public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattspercubicfoot)
-#endif
- {
- double value = (double) picowattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from PicowattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromPicowattsPerCubicInch(double picowattspercubicinch)
-#else
- public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattspercubicinch)
-#endif
- {
- double value = (double) picowattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from PicowattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromPicowattsPerCubicMeter(double picowattspercubicmeter)
-#else
- public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattspercubicmeter)
-#endif
- {
- double value = (double) picowattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from PicowattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromPicowattsPerLiter(double picowattsperliter)
-#else
- public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter)
-#endif
- {
- double value = (double) picowattsperliter;
- return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter);
- }
-
- ///
- /// Get PowerDensity from TerawattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromTerawattsPerCubicFoot(double terawattspercubicfoot)
-#else
- public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattspercubicfoot)
-#endif
- {
- double value = (double) terawattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from TerawattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromTerawattsPerCubicInch(double terawattspercubicinch)
-#else
- public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattspercubicinch)
-#endif
- {
- double value = (double) terawattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from TerawattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromTerawattsPerCubicMeter(double terawattspercubicmeter)
-#else
- public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattspercubicmeter)
-#endif
- {
- double value = (double) terawattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from TerawattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromTerawattsPerLiter(double terawattsperliter)
-#else
- public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter)
-#endif
- {
- double value = (double) terawattsperliter;
- return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter);
- }
-
- ///
- /// Get PowerDensity from WattsPerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromWattsPerCubicFoot(double wattspercubicfoot)
-#else
- public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot)
-#endif
- {
- double value = (double) wattspercubicfoot;
- return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot);
- }
-
- ///
- /// Get PowerDensity from WattsPerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromWattsPerCubicInch(double wattspercubicinch)
-#else
- public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch)
-#endif
- {
- double value = (double) wattspercubicinch;
- return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch);
- }
-
- ///
- /// Get PowerDensity from WattsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromWattsPerCubicMeter(double wattspercubicmeter)
-#else
- public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmeter)
-#endif
- {
- double value = (double) wattspercubicmeter;
- return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter);
- }
-
- ///
- /// Get PowerDensity from WattsPerLiter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerDensity FromWattsPerLiter(double wattsperliter)
-#else
- public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter)
-#endif
- {
- double value = (double) wattsperliter;
- return new PowerDensity(value, PowerDensityUnit.WattPerLiter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// PowerDensity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static PowerDensity From(double value, PowerDensityUnit fromUnit)
-#else
- public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit)
-#endif
- {
- return new PowerDensity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PowerDensityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is PowerDensity)) throw new ArgumentException("Expected type PowerDensity.", nameof(obj));
-
- return CompareTo((PowerDensity)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(PowerDensity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(PowerDensity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is PowerDensity))
- return false;
-
- var objQuantity = (PowerDensity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another PowerDensity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another PowerDensity 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.
- [Obsolete("Please use the Equals(PowerDensity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(PowerDensity other, PowerDensity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current PowerDensity.
- public override int GetHashCode()
- {
- return new { type = typeof(PowerDensity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PowerDensityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this PowerDensity to another PowerDensity with the unit representation .
- ///
- /// A PowerDensity with the specified unit.
- public PowerDensity ToUnit(PowerDensityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new PowerDensity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PowerDensityUnit.DecawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e1d;
- case PowerDensityUnit.DecawattPerCubicInch: return (_value*6.102374409473228e4) * 1e1d;
- case PowerDensityUnit.DecawattPerCubicMeter: return (_value) * 1e1d;
- case PowerDensityUnit.DecawattPerLiter: return (_value*1.0e3) * 1e1d;
- case PowerDensityUnit.DeciwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-1d;
- case PowerDensityUnit.DeciwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-1d;
- case PowerDensityUnit.DeciwattPerCubicMeter: return (_value) * 1e-1d;
- case PowerDensityUnit.DeciwattPerLiter: return (_value*1.0e3) * 1e-1d;
- case PowerDensityUnit.GigawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e9d;
- case PowerDensityUnit.GigawattPerCubicInch: return (_value*6.102374409473228e4) * 1e9d;
- case PowerDensityUnit.GigawattPerCubicMeter: return (_value) * 1e9d;
- case PowerDensityUnit.GigawattPerLiter: return (_value*1.0e3) * 1e9d;
- case PowerDensityUnit.KilowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e3d;
- case PowerDensityUnit.KilowattPerCubicInch: return (_value*6.102374409473228e4) * 1e3d;
- case PowerDensityUnit.KilowattPerCubicMeter: return (_value) * 1e3d;
- case PowerDensityUnit.KilowattPerLiter: return (_value*1.0e3) * 1e3d;
- case PowerDensityUnit.MegawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e6d;
- case PowerDensityUnit.MegawattPerCubicInch: return (_value*6.102374409473228e4) * 1e6d;
- case PowerDensityUnit.MegawattPerCubicMeter: return (_value) * 1e6d;
- case PowerDensityUnit.MegawattPerLiter: return (_value*1.0e3) * 1e6d;
- case PowerDensityUnit.MicrowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-6d;
- case PowerDensityUnit.MicrowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-6d;
- case PowerDensityUnit.MicrowattPerCubicMeter: return (_value) * 1e-6d;
- case PowerDensityUnit.MicrowattPerLiter: return (_value*1.0e3) * 1e-6d;
- case PowerDensityUnit.MilliwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-3d;
- case PowerDensityUnit.MilliwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-3d;
- case PowerDensityUnit.MilliwattPerCubicMeter: return (_value) * 1e-3d;
- case PowerDensityUnit.MilliwattPerLiter: return (_value*1.0e3) * 1e-3d;
- case PowerDensityUnit.NanowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-9d;
- case PowerDensityUnit.NanowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-9d;
- case PowerDensityUnit.NanowattPerCubicMeter: return (_value) * 1e-9d;
- case PowerDensityUnit.NanowattPerLiter: return (_value*1.0e3) * 1e-9d;
- case PowerDensityUnit.PicowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-12d;
- case PowerDensityUnit.PicowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-12d;
- case PowerDensityUnit.PicowattPerCubicMeter: return (_value) * 1e-12d;
- case PowerDensityUnit.PicowattPerLiter: return (_value*1.0e3) * 1e-12d;
- case PowerDensityUnit.TerawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e12d;
- case PowerDensityUnit.TerawattPerCubicInch: return (_value*6.102374409473228e4) * 1e12d;
- case PowerDensityUnit.TerawattPerCubicMeter: return (_value) * 1e12d;
- case PowerDensityUnit.TerawattPerLiter: return (_value*1.0e3) * 1e12d;
- case PowerDensityUnit.WattPerCubicFoot: return _value*3.531466672148859e1;
- case PowerDensityUnit.WattPerCubicInch: return _value*6.102374409473228e4;
- case PowerDensityUnit.WattPerCubicMeter: return _value;
- case PowerDensityUnit.WattPerLiter: return _value*1.0e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PowerDensityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PowerDensityUnit.DecawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e1d;
- case PowerDensityUnit.DecawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e1d;
- case PowerDensityUnit.DecawattPerCubicMeter: return (baseUnitValue) / 1e1d;
- case PowerDensityUnit.DecawattPerLiter: return (baseUnitValue/1.0e3) / 1e1d;
- case PowerDensityUnit.DeciwattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-1d;
- case PowerDensityUnit.DeciwattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-1d;
- case PowerDensityUnit.DeciwattPerCubicMeter: return (baseUnitValue) / 1e-1d;
- case PowerDensityUnit.DeciwattPerLiter: return (baseUnitValue/1.0e3) / 1e-1d;
- case PowerDensityUnit.GigawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e9d;
- case PowerDensityUnit.GigawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e9d;
- case PowerDensityUnit.GigawattPerCubicMeter: return (baseUnitValue) / 1e9d;
- case PowerDensityUnit.GigawattPerLiter: return (baseUnitValue/1.0e3) / 1e9d;
- case PowerDensityUnit.KilowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e3d;
- case PowerDensityUnit.KilowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e3d;
- case PowerDensityUnit.KilowattPerCubicMeter: return (baseUnitValue) / 1e3d;
- case PowerDensityUnit.KilowattPerLiter: return (baseUnitValue/1.0e3) / 1e3d;
- case PowerDensityUnit.MegawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e6d;
- case PowerDensityUnit.MegawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e6d;
- case PowerDensityUnit.MegawattPerCubicMeter: return (baseUnitValue) / 1e6d;
- case PowerDensityUnit.MegawattPerLiter: return (baseUnitValue/1.0e3) / 1e6d;
- case PowerDensityUnit.MicrowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-6d;
- case PowerDensityUnit.MicrowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-6d;
- case PowerDensityUnit.MicrowattPerCubicMeter: return (baseUnitValue) / 1e-6d;
- case PowerDensityUnit.MicrowattPerLiter: return (baseUnitValue/1.0e3) / 1e-6d;
- case PowerDensityUnit.MilliwattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-3d;
- case PowerDensityUnit.MilliwattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-3d;
- case PowerDensityUnit.MilliwattPerCubicMeter: return (baseUnitValue) / 1e-3d;
- case PowerDensityUnit.MilliwattPerLiter: return (baseUnitValue/1.0e3) / 1e-3d;
- case PowerDensityUnit.NanowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-9d;
- case PowerDensityUnit.NanowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-9d;
- case PowerDensityUnit.NanowattPerCubicMeter: return (baseUnitValue) / 1e-9d;
- case PowerDensityUnit.NanowattPerLiter: return (baseUnitValue/1.0e3) / 1e-9d;
- case PowerDensityUnit.PicowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-12d;
- case PowerDensityUnit.PicowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-12d;
- case PowerDensityUnit.PicowattPerCubicMeter: return (baseUnitValue) / 1e-12d;
- case PowerDensityUnit.PicowattPerLiter: return (baseUnitValue/1.0e3) / 1e-12d;
- case PowerDensityUnit.TerawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e12d;
- case PowerDensityUnit.TerawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e12d;
- case PowerDensityUnit.TerawattPerCubicMeter: return (baseUnitValue) / 1e12d;
- case PowerDensityUnit.TerawattPerLiter: return (baseUnitValue/1.0e3) / 1e12d;
- case PowerDensityUnit.WattPerCubicFoot: return baseUnitValue/3.531466672148859e1;
- case PowerDensityUnit.WattPerCubicInch: return baseUnitValue/6.102374409473228e4;
- case PowerDensityUnit.WattPerCubicMeter: return baseUnitValue;
- case PowerDensityUnit.WattPerLiter: return baseUnitValue/1.0e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 PowerDensity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 PowerDensity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PowerDensityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is WattPerCubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PowerDensityUnit ToStringDefaultUnit { get; set; } = PowerDensityUnit.WattPerCubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PowerDensityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of PowerDensity
- ///
- public static PowerDensity MaxValue => new PowerDensity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of PowerDensity
- ///
- public static PowerDensity MinValue => new PowerDensity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => PowerDensity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => PowerDensity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/PowerRatio.Common.g.cs b/Common/GeneratedCode/Quantities/PowerRatio.Common.g.cs
deleted file mode 100644
index cc084e1ab1..0000000000
--- a/Common/GeneratedCode/Quantities/PowerRatio.Common.g.cs
+++ /dev/null
@@ -1,510 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The strength of a signal expressed in decibels (dB) relative to one watt.
- ///
- // 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 PowerRatio : IQuantity
-#else
- public partial struct PowerRatio : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PowerRatioUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PowerRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static PowerRatio()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit DecibelWatt.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public PowerRatio(double decibelwatts)
- {
- _value = Convert.ToDouble(decibelwatts);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- PowerRatio(double numericValue, PowerRatioUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecibelWatt.
- ///
- /// Value assuming base unit DecibelWatt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PowerRatio(long decibelwatts) : this(Convert.ToDouble(decibelwatts), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecibelWatt.
- ///
- /// Value assuming base unit DecibelWatt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PowerRatio(decimal decibelwatts) : this(Convert.ToDouble(decibelwatts), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.PowerRatio;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PowerRatioUnit BaseUnit => PowerRatioUnit.DecibelWatt;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the PowerRatio quantity.
- ///
- public static PowerRatioUnit[] Units { get; } = Enum.GetValues(typeof(PowerRatioUnit)).Cast().Except(new PowerRatioUnit[]{ PowerRatioUnit.Undefined }).ToArray();
-
- ///
- /// Get PowerRatio in DecibelMilliwatts.
- ///
- public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt);
-
- ///
- /// Get PowerRatio in DecibelWatts.
- ///
- public double DecibelWatts => As(PowerRatioUnit.DecibelWatt);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit DecibelWatt.
- ///
- public static PowerRatio Zero => new PowerRatio(0, BaseUnit);
-
- ///
- /// Get PowerRatio from DecibelMilliwatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerRatio FromDecibelMilliwatts(double decibelmilliwatts)
-#else
- public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts)
-#endif
- {
- double value = (double) decibelmilliwatts;
- return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt);
- }
-
- ///
- /// Get PowerRatio from DecibelWatts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PowerRatio FromDecibelWatts(double decibelwatts)
-#else
- public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts)
-#endif
- {
- double value = (double) decibelwatts;
- return new PowerRatio(value, PowerRatioUnit.DecibelWatt);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// PowerRatio unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static PowerRatio From(double value, PowerRatioUnit fromUnit)
-#else
- public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit)
-#endif
- {
- return new PowerRatio((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PowerRatioUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is PowerRatio)) throw new ArgumentException("Expected type PowerRatio.", nameof(obj));
-
- return CompareTo((PowerRatio)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(PowerRatio other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(PowerRatio, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is PowerRatio))
- return false;
-
- var objQuantity = (PowerRatio)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another PowerRatio within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another PowerRatio 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.
- [Obsolete("Please use the Equals(PowerRatio, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(PowerRatio other, PowerRatio maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current PowerRatio.
- public override int GetHashCode()
- {
- return new { type = typeof(PowerRatio), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PowerRatioUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this PowerRatio to another PowerRatio with the unit representation .
- ///
- /// A PowerRatio with the specified unit.
- public PowerRatio ToUnit(PowerRatioUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new PowerRatio(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PowerRatioUnit.DecibelMilliwatt: return _value - 30;
- case PowerRatioUnit.DecibelWatt: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PowerRatioUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PowerRatioUnit.DecibelMilliwatt: return baseUnitValue + 30;
- case PowerRatioUnit.DecibelWatt: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 PowerRatio Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 PowerRatio result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PowerRatioUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is DecibelWatt
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PowerRatioUnit ToStringDefaultUnit { get; set; } = PowerRatioUnit.DecibelWatt;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PowerRatioUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of PowerRatio
- ///
- public static PowerRatio MaxValue => new PowerRatio(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of PowerRatio
- ///
- public static PowerRatio MinValue => new PowerRatio(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => PowerRatio.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => PowerRatio.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Pressure.Common.g.cs b/Common/GeneratedCode/Quantities/Pressure.Common.g.cs
deleted file mode 100644
index 6ba6f03a84..0000000000
--- a/Common/GeneratedCode/Quantities/Pressure.Common.g.cs
+++ /dev/null
@@ -1,1353 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).
- ///
- // 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 Pressure : IQuantity
-#else
- public partial struct Pressure : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PressureUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PressureUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Pressure()
- {
- BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Pascal.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Pressure(double pascals)
- {
- _value = Convert.ToDouble(pascals);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Pressure(double numericValue, PressureUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Pascal.
- ///
- /// Value assuming base unit Pascal.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Pressure(long pascals) : this(Convert.ToDouble(pascals), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Pascal.
- ///
- /// Value assuming base unit Pascal.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Pressure(decimal pascals) : this(Convert.ToDouble(pascals), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Pressure;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PressureUnit BaseUnit => PressureUnit.Pascal;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Pressure quantity.
- ///
- public static PressureUnit[] Units { get; } = Enum.GetValues(typeof(PressureUnit)).Cast().Except(new PressureUnit[]{ PressureUnit.Undefined }).ToArray();
-
- ///
- /// Get Pressure in Atmospheres.
- ///
- public double Atmospheres => As(PressureUnit.Atmosphere);
-
- ///
- /// Get Pressure in Bars.
- ///
- public double Bars => As(PressureUnit.Bar);
-
- ///
- /// Get Pressure in Centibars.
- ///
- public double Centibars => As(PressureUnit.Centibar);
-
- ///
- /// Get Pressure in Decapascals.
- ///
- public double Decapascals => As(PressureUnit.Decapascal);
-
- ///
- /// Get Pressure in Decibars.
- ///
- public double Decibars => As(PressureUnit.Decibar);
-
- ///
- /// Get Pressure in DynesPerSquareCentimeter.
- ///
- public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter);
-
- ///
- /// Get Pressure in FeetOfHead.
- ///
- public double FeetOfHead => As(PressureUnit.FootOfHead);
-
- ///
- /// Get Pressure in Gigapascals.
- ///
- public double Gigapascals => As(PressureUnit.Gigapascal);
-
- ///
- /// Get Pressure in Hectopascals.
- ///
- public double Hectopascals => As(PressureUnit.Hectopascal);
-
- ///
- /// Get Pressure in InchesOfMercury.
- ///
- public double InchesOfMercury => As(PressureUnit.InchOfMercury);
-
- ///
- /// Get Pressure in Kilobars.
- ///
- public double Kilobars => As(PressureUnit.Kilobar);
-
- ///
- /// Get Pressure in KilogramsForcePerSquareCentimeter.
- ///
- public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter);
-
- ///
- /// Get Pressure in KilogramsForcePerSquareMeter.
- ///
- public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter);
-
- ///
- /// Get Pressure in KilogramsForcePerSquareMillimeter.
- ///
- public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter);
-
- ///
- /// Get Pressure in KilonewtonsPerSquareCentimeter.
- ///
- public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter);
-
- ///
- /// Get Pressure in KilonewtonsPerSquareMeter.
- ///
- public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter);
-
- ///
- /// Get Pressure in KilonewtonsPerSquareMillimeter.
- ///
- public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter);
-
- ///
- /// Get Pressure in Kilopascals.
- ///
- public double Kilopascals => As(PressureUnit.Kilopascal);
-
- ///
- /// Get Pressure in KilopoundsForcePerSquareFoot.
- ///
- public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot);
-
- ///
- /// Get Pressure in KilopoundsForcePerSquareInch.
- ///
- public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch);
-
- ///
- /// Get Pressure in Megabars.
- ///
- public double Megabars => As(PressureUnit.Megabar);
-
- ///
- /// Get Pressure in MeganewtonsPerSquareMeter.
- ///
- public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter);
-
- ///
- /// Get Pressure in Megapascals.
- ///
- public double Megapascals => As(PressureUnit.Megapascal);
-
- ///
- /// Get Pressure in MetersOfHead.
- ///
- public double MetersOfHead => As(PressureUnit.MeterOfHead);
-
- ///
- /// Get Pressure in Microbars.
- ///
- public double Microbars => As(PressureUnit.Microbar);
-
- ///
- /// Get Pressure in Micropascals.
- ///
- public double Micropascals => As(PressureUnit.Micropascal);
-
- ///
- /// Get Pressure in Millibars.
- ///
- public double Millibars => As(PressureUnit.Millibar);
-
- ///
- /// Get Pressure in MillimetersOfMercury.
- ///
- public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury);
-
- ///
- /// Get Pressure in Millipascals.
- ///
- public double Millipascals => As(PressureUnit.Millipascal);
-
- ///
- /// Get Pressure in NewtonsPerSquareCentimeter.
- ///
- public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter);
-
- ///
- /// Get Pressure in NewtonsPerSquareMeter.
- ///
- public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter);
-
- ///
- /// Get Pressure in NewtonsPerSquareMillimeter.
- ///
- public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter);
-
- ///
- /// Get Pressure in Pascals.
- ///
- public double Pascals => As(PressureUnit.Pascal);
-
- ///
- /// Get Pressure in PoundsForcePerSquareFoot.
- ///
- public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot);
-
- ///
- /// Get Pressure in PoundsForcePerSquareInch.
- ///
- public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch);
-
- ///
- /// Get Pressure in PoundsPerInchSecondSquared.
- ///
- public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared);
-
- ///
- /// Get Pressure in Psi.
- ///
- [System.Obsolete("Deprecated due to github issue #215, please use PoundForcePerSquareInch instead")]
- public double Psi => As(PressureUnit.Psi);
-
- ///
- /// Get Pressure in TechnicalAtmospheres.
- ///
- public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere);
-
- ///
- /// Get Pressure in TonnesForcePerSquareCentimeter.
- ///
- public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter);
-
- ///
- /// Get Pressure in TonnesForcePerSquareMeter.
- ///
- public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter);
-
- ///
- /// Get Pressure in TonnesForcePerSquareMillimeter.
- ///
- public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter);
-
- ///
- /// Get Pressure in Torrs.
- ///
- public double Torrs => As(PressureUnit.Torr);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Pascal.
- ///
- public static Pressure Zero => new Pressure(0, BaseUnit);
-
- ///
- /// Get Pressure from Atmospheres.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromAtmospheres(double atmospheres)
-#else
- public static Pressure FromAtmospheres(QuantityValue atmospheres)
-#endif
- {
- double value = (double) atmospheres;
- return new Pressure(value, PressureUnit.Atmosphere);
- }
-
- ///
- /// Get Pressure from Bars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromBars(double bars)
-#else
- public static Pressure FromBars(QuantityValue bars)
-#endif
- {
- double value = (double) bars;
- return new Pressure(value, PressureUnit.Bar);
- }
-
- ///
- /// Get Pressure from Centibars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromCentibars(double centibars)
-#else
- public static Pressure FromCentibars(QuantityValue centibars)
-#endif
- {
- double value = (double) centibars;
- return new Pressure(value, PressureUnit.Centibar);
- }
-
- ///
- /// Get Pressure from Decapascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromDecapascals(double decapascals)
-#else
- public static Pressure FromDecapascals(QuantityValue decapascals)
-#endif
- {
- double value = (double) decapascals;
- return new Pressure(value, PressureUnit.Decapascal);
- }
-
- ///
- /// Get Pressure from Decibars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromDecibars(double decibars)
-#else
- public static Pressure FromDecibars(QuantityValue decibars)
-#endif
- {
- double value = (double) decibars;
- return new Pressure(value, PressureUnit.Decibar);
- }
-
- ///
- /// Get Pressure from DynesPerSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromDynesPerSquareCentimeter(double dynespersquarecentimeter)
-#else
- public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquarecentimeter)
-#endif
- {
- double value = (double) dynespersquarecentimeter;
- return new Pressure(value, PressureUnit.DynePerSquareCentimeter);
- }
-
- ///
- /// Get Pressure from FeetOfHead.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromFeetOfHead(double feetofhead)
-#else
- public static Pressure FromFeetOfHead(QuantityValue feetofhead)
-#endif
- {
- double value = (double) feetofhead;
- return new Pressure(value, PressureUnit.FootOfHead);
- }
-
- ///
- /// Get Pressure from Gigapascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromGigapascals(double gigapascals)
-#else
- public static Pressure FromGigapascals(QuantityValue gigapascals)
-#endif
- {
- double value = (double) gigapascals;
- return new Pressure(value, PressureUnit.Gigapascal);
- }
-
- ///
- /// Get Pressure from Hectopascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromHectopascals(double hectopascals)
-#else
- public static Pressure FromHectopascals(QuantityValue hectopascals)
-#endif
- {
- double value = (double) hectopascals;
- return new Pressure(value, PressureUnit.Hectopascal);
- }
-
- ///
- /// Get Pressure from InchesOfMercury.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromInchesOfMercury(double inchesofmercury)
-#else
- public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury)
-#endif
- {
- double value = (double) inchesofmercury;
- return new Pressure(value, PressureUnit.InchOfMercury);
- }
-
- ///
- /// Get Pressure from Kilobars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilobars(double kilobars)
-#else
- public static Pressure FromKilobars(QuantityValue kilobars)
-#endif
- {
- double value = (double) kilobars;
- return new Pressure(value, PressureUnit.Kilobar);
- }
-
- ///
- /// Get Pressure from KilogramsForcePerSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilogramsForcePerSquareCentimeter(double kilogramsforcepersquarecentimeter)
-#else
- public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilogramsforcepersquarecentimeter)
-#endif
- {
- double value = (double) kilogramsforcepersquarecentimeter;
- return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter);
- }
-
- ///
- /// Get Pressure from KilogramsForcePerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilogramsForcePerSquareMeter(double kilogramsforcepersquaremeter)
-#else
- public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsforcepersquaremeter)
-#endif
- {
- double value = (double) kilogramsforcepersquaremeter;
- return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter);
- }
-
- ///
- /// Get Pressure from KilogramsForcePerSquareMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilogramsForcePerSquareMillimeter(double kilogramsforcepersquaremillimeter)
-#else
- public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilogramsforcepersquaremillimeter)
-#endif
- {
- double value = (double) kilogramsforcepersquaremillimeter;
- return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter);
- }
-
- ///
- /// Get Pressure from KilonewtonsPerSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilonewtonsPerSquareCentimeter(double kilonewtonspersquarecentimeter)
-#else
- public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewtonspersquarecentimeter)
-#endif
- {
- double value = (double) kilonewtonspersquarecentimeter;
- return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter);
- }
-
- ///
- /// Get Pressure from KilonewtonsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilonewtonsPerSquareMeter(double kilonewtonspersquaremeter)
-#else
- public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspersquaremeter)
-#endif
- {
- double value = (double) kilonewtonspersquaremeter;
- return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter);
- }
-
- ///
- /// Get Pressure from KilonewtonsPerSquareMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilonewtonsPerSquareMillimeter(double kilonewtonspersquaremillimeter)
-#else
- public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewtonspersquaremillimeter)
-#endif
- {
- double value = (double) kilonewtonspersquaremillimeter;
- return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter);
- }
-
- ///
- /// Get Pressure from Kilopascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilopascals(double kilopascals)
-#else
- public static Pressure FromKilopascals(QuantityValue kilopascals)
-#endif
- {
- double value = (double) kilopascals;
- return new Pressure(value, PressureUnit.Kilopascal);
- }
-
- ///
- /// Get Pressure from KilopoundsForcePerSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilopoundsForcePerSquareFoot(double kilopoundsforcepersquarefoot)
-#else
- public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopoundsforcepersquarefoot)
-#endif
- {
- double value = (double) kilopoundsforcepersquarefoot;
- return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot);
- }
-
- ///
- /// Get Pressure from KilopoundsForcePerSquareInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromKilopoundsForcePerSquareInch(double kilopoundsforcepersquareinch)
-#else
- public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopoundsforcepersquareinch)
-#endif
- {
- double value = (double) kilopoundsforcepersquareinch;
- return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch);
- }
-
- ///
- /// Get Pressure from Megabars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMegabars(double megabars)
-#else
- public static Pressure FromMegabars(QuantityValue megabars)
-#endif
- {
- double value = (double) megabars;
- return new Pressure(value, PressureUnit.Megabar);
- }
-
- ///
- /// Get Pressure from MeganewtonsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMeganewtonsPerSquareMeter(double meganewtonspersquaremeter)
-#else
- public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspersquaremeter)
-#endif
- {
- double value = (double) meganewtonspersquaremeter;
- return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter);
- }
-
- ///
- /// Get Pressure from Megapascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMegapascals(double megapascals)
-#else
- public static Pressure FromMegapascals(QuantityValue megapascals)
-#endif
- {
- double value = (double) megapascals;
- return new Pressure(value, PressureUnit.Megapascal);
- }
-
- ///
- /// Get Pressure from MetersOfHead.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMetersOfHead(double metersofhead)
-#else
- public static Pressure FromMetersOfHead(QuantityValue metersofhead)
-#endif
- {
- double value = (double) metersofhead;
- return new Pressure(value, PressureUnit.MeterOfHead);
- }
-
- ///
- /// Get Pressure from Microbars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMicrobars(double microbars)
-#else
- public static Pressure FromMicrobars(QuantityValue microbars)
-#endif
- {
- double value = (double) microbars;
- return new Pressure(value, PressureUnit.Microbar);
- }
-
- ///
- /// Get Pressure from Micropascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMicropascals(double micropascals)
-#else
- public static Pressure FromMicropascals(QuantityValue micropascals)
-#endif
- {
- double value = (double) micropascals;
- return new Pressure(value, PressureUnit.Micropascal);
- }
-
- ///
- /// Get Pressure from Millibars.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMillibars(double millibars)
-#else
- public static Pressure FromMillibars(QuantityValue millibars)
-#endif
- {
- double value = (double) millibars;
- return new Pressure(value, PressureUnit.Millibar);
- }
-
- ///
- /// Get Pressure from MillimetersOfMercury.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMillimetersOfMercury(double millimetersofmercury)
-#else
- public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercury)
-#endif
- {
- double value = (double) millimetersofmercury;
- return new Pressure(value, PressureUnit.MillimeterOfMercury);
- }
-
- ///
- /// Get Pressure from Millipascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromMillipascals(double millipascals)
-#else
- public static Pressure FromMillipascals(QuantityValue millipascals)
-#endif
- {
- double value = (double) millipascals;
- return new Pressure(value, PressureUnit.Millipascal);
- }
-
- ///
- /// Get Pressure from NewtonsPerSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromNewtonsPerSquareCentimeter(double newtonspersquarecentimeter)
-#else
- public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersquarecentimeter)
-#endif
- {
- double value = (double) newtonspersquarecentimeter;
- return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter);
- }
-
- ///
- /// Get Pressure from NewtonsPerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromNewtonsPerSquareMeter(double newtonspersquaremeter)
-#else
- public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquaremeter)
-#endif
- {
- double value = (double) newtonspersquaremeter;
- return new Pressure(value, PressureUnit.NewtonPerSquareMeter);
- }
-
- ///
- /// Get Pressure from NewtonsPerSquareMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromNewtonsPerSquareMillimeter(double newtonspersquaremillimeter)
-#else
- public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersquaremillimeter)
-#endif
- {
- double value = (double) newtonspersquaremillimeter;
- return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter);
- }
-
- ///
- /// Get Pressure from Pascals.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromPascals(double pascals)
-#else
- public static Pressure FromPascals(QuantityValue pascals)
-#endif
- {
- double value = (double) pascals;
- return new Pressure(value, PressureUnit.Pascal);
- }
-
- ///
- /// Get Pressure from PoundsForcePerSquareFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromPoundsForcePerSquareFoot(double poundsforcepersquarefoot)
-#else
- public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforcepersquarefoot)
-#endif
- {
- double value = (double) poundsforcepersquarefoot;
- return new Pressure(value, PressureUnit.PoundForcePerSquareFoot);
- }
-
- ///
- /// Get Pressure from PoundsForcePerSquareInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromPoundsForcePerSquareInch(double poundsforcepersquareinch)
-#else
- public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforcepersquareinch)
-#endif
- {
- double value = (double) poundsforcepersquareinch;
- return new Pressure(value, PressureUnit.PoundForcePerSquareInch);
- }
-
- ///
- /// Get Pressure from PoundsPerInchSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromPoundsPerInchSecondSquared(double poundsperinchsecondsquared)
-#else
- public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinchsecondsquared)
-#endif
- {
- double value = (double) poundsperinchsecondsquared;
- return new Pressure(value, PressureUnit.PoundPerInchSecondSquared);
- }
-
- ///
- /// Get Pressure from Psi.
- ///
- [System.Obsolete("Deprecated due to github issue #215, please use PoundForcePerSquareInch instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromPsi(double psi)
-#else
- public static Pressure FromPsi(QuantityValue psi)
-#endif
- {
- double value = (double) psi;
- return new Pressure(value, PressureUnit.Psi);
- }
-
- ///
- /// Get Pressure from TechnicalAtmospheres.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromTechnicalAtmospheres(double technicalatmospheres)
-#else
- public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospheres)
-#endif
- {
- double value = (double) technicalatmospheres;
- return new Pressure(value, PressureUnit.TechnicalAtmosphere);
- }
-
- ///
- /// Get Pressure from TonnesForcePerSquareCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromTonnesForcePerSquareCentimeter(double tonnesforcepersquarecentimeter)
-#else
- public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesforcepersquarecentimeter)
-#endif
- {
- double value = (double) tonnesforcepersquarecentimeter;
- return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter);
- }
-
- ///
- /// Get Pressure from TonnesForcePerSquareMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromTonnesForcePerSquareMeter(double tonnesforcepersquaremeter)
-#else
- public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepersquaremeter)
-#endif
- {
- double value = (double) tonnesforcepersquaremeter;
- return new Pressure(value, PressureUnit.TonneForcePerSquareMeter);
- }
-
- ///
- /// Get Pressure from TonnesForcePerSquareMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromTonnesForcePerSquareMillimeter(double tonnesforcepersquaremillimeter)
-#else
- public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesforcepersquaremillimeter)
-#endif
- {
- double value = (double) tonnesforcepersquaremillimeter;
- return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter);
- }
-
- ///
- /// Get Pressure from Torrs.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Pressure FromTorrs(double torrs)
-#else
- public static Pressure FromTorrs(QuantityValue torrs)
-#endif
- {
- double value = (double) torrs;
- return new Pressure(value, PressureUnit.Torr);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Pressure unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Pressure From(double value, PressureUnit fromUnit)
-#else
- public static Pressure From(QuantityValue value, PressureUnit fromUnit)
-#endif
- {
- return new Pressure((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PressureUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Pressure)) throw new ArgumentException("Expected type Pressure.", nameof(obj));
-
- return CompareTo((Pressure)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(Pressure other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Pressure, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Pressure))
- return false;
-
- var objQuantity = (Pressure)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Pressure within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Pressure 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.
- [Obsolete("Please use the Equals(Pressure, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Pressure other, Pressure maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Pressure.
- public override int GetHashCode()
- {
- return new { type = typeof(Pressure), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PressureUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Pressure to another Pressure with the unit representation .
- ///
- /// A Pressure with the specified unit.
- public Pressure ToUnit(PressureUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Pressure(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PressureUnit.Atmosphere: return _value*1.01325*1e5;
- case PressureUnit.Bar: return _value*1e5;
- case PressureUnit.Centibar: return (_value*1e5) * 1e-2d;
- case PressureUnit.Decapascal: return (_value) * 1e1d;
- case PressureUnit.Decibar: return (_value*1e5) * 1e-1d;
- case PressureUnit.DynePerSquareCentimeter: return _value*1.0e-1;
- case PressureUnit.FootOfHead: return _value*2989.0669;
- case PressureUnit.Gigapascal: return (_value) * 1e9d;
- case PressureUnit.Hectopascal: return (_value) * 1e2d;
- case PressureUnit.InchOfMercury: return _value/2.95299830714159e-4;
- case PressureUnit.Kilobar: return (_value*1e5) * 1e3d;
- case PressureUnit.KilogramForcePerSquareCentimeter: return _value*9.80665e4;
- case PressureUnit.KilogramForcePerSquareMeter: return _value*9.80665019960652;
- case PressureUnit.KilogramForcePerSquareMillimeter: return _value*9.80665e6;
- case PressureUnit.KilonewtonPerSquareCentimeter: return (_value*1e4) * 1e3d;
- case PressureUnit.KilonewtonPerSquareMeter: return (_value) * 1e3d;
- case PressureUnit.KilonewtonPerSquareMillimeter: return (_value*1e6) * 1e3d;
- case PressureUnit.Kilopascal: return (_value) * 1e3d;
- case PressureUnit.KilopoundForcePerSquareFoot: return (_value*4.788025898033584e1) * 1e3d;
- case PressureUnit.KilopoundForcePerSquareInch: return (_value*6.894757293168361e3) * 1e3d;
- case PressureUnit.Megabar: return (_value*1e5) * 1e6d;
- case PressureUnit.MeganewtonPerSquareMeter: return (_value) * 1e6d;
- case PressureUnit.Megapascal: return (_value) * 1e6d;
- case PressureUnit.MeterOfHead: return _value*9804.139432;
- case PressureUnit.Microbar: return (_value*1e5) * 1e-6d;
- case PressureUnit.Micropascal: return (_value) * 1e-6d;
- case PressureUnit.Millibar: return (_value*1e5) * 1e-3d;
- case PressureUnit.MillimeterOfMercury: return _value/7.50061561302643e-3;
- case PressureUnit.Millipascal: return (_value) * 1e-3d;
- case PressureUnit.NewtonPerSquareCentimeter: return _value*1e4;
- case PressureUnit.NewtonPerSquareMeter: return _value;
- case PressureUnit.NewtonPerSquareMillimeter: return _value*1e6;
- case PressureUnit.Pascal: return _value;
- case PressureUnit.PoundForcePerSquareFoot: return _value*4.788025898033584e1;
- case PressureUnit.PoundForcePerSquareInch: return _value*6.894757293168361e3;
- case PressureUnit.PoundPerInchSecondSquared: return _value*1.785796732283465e1;
- case PressureUnit.Psi: return _value*6.894757293168361e3;
- case PressureUnit.TechnicalAtmosphere: return _value*9.80680592331*1e4;
- case PressureUnit.TonneForcePerSquareCentimeter: return _value*9.80665e7;
- case PressureUnit.TonneForcePerSquareMeter: return _value*9.80665e3;
- case PressureUnit.TonneForcePerSquareMillimeter: return _value*9.80665e9;
- case PressureUnit.Torr: return _value*1.3332266752*1e2;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PressureUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PressureUnit.Atmosphere: return baseUnitValue/(1.01325*1e5);
- case PressureUnit.Bar: return baseUnitValue/1e5;
- case PressureUnit.Centibar: return (baseUnitValue/1e5) / 1e-2d;
- case PressureUnit.Decapascal: return (baseUnitValue) / 1e1d;
- case PressureUnit.Decibar: return (baseUnitValue/1e5) / 1e-1d;
- case PressureUnit.DynePerSquareCentimeter: return baseUnitValue/1.0e-1;
- case PressureUnit.FootOfHead: return baseUnitValue*0.000334552565551;
- case PressureUnit.Gigapascal: return (baseUnitValue) / 1e9d;
- case PressureUnit.Hectopascal: return (baseUnitValue) / 1e2d;
- case PressureUnit.InchOfMercury: return baseUnitValue*2.95299830714159e-4;
- case PressureUnit.Kilobar: return (baseUnitValue/1e5) / 1e3d;
- case PressureUnit.KilogramForcePerSquareCentimeter: return baseUnitValue/9.80665e4;
- case PressureUnit.KilogramForcePerSquareMeter: return baseUnitValue*0.101971619222242;
- case PressureUnit.KilogramForcePerSquareMillimeter: return baseUnitValue/9.80665e6;
- case PressureUnit.KilonewtonPerSquareCentimeter: return (baseUnitValue/1e4) / 1e3d;
- case PressureUnit.KilonewtonPerSquareMeter: return (baseUnitValue) / 1e3d;
- case PressureUnit.KilonewtonPerSquareMillimeter: return (baseUnitValue/1e6) / 1e3d;
- case PressureUnit.Kilopascal: return (baseUnitValue) / 1e3d;
- case PressureUnit.KilopoundForcePerSquareFoot: return (baseUnitValue/4.788025898033584e1) / 1e3d;
- case PressureUnit.KilopoundForcePerSquareInch: return (baseUnitValue/6.894757293168361e3) / 1e3d;
- case PressureUnit.Megabar: return (baseUnitValue/1e5) / 1e6d;
- case PressureUnit.MeganewtonPerSquareMeter: return (baseUnitValue) / 1e6d;
- case PressureUnit.Megapascal: return (baseUnitValue) / 1e6d;
- case PressureUnit.MeterOfHead: return baseUnitValue*0.0001019977334;
- case PressureUnit.Microbar: return (baseUnitValue/1e5) / 1e-6d;
- case PressureUnit.Micropascal: return (baseUnitValue) / 1e-6d;
- case PressureUnit.Millibar: return (baseUnitValue/1e5) / 1e-3d;
- case PressureUnit.MillimeterOfMercury: return baseUnitValue*7.50061561302643e-3;
- case PressureUnit.Millipascal: return (baseUnitValue) / 1e-3d;
- case PressureUnit.NewtonPerSquareCentimeter: return baseUnitValue/1e4;
- case PressureUnit.NewtonPerSquareMeter: return baseUnitValue;
- case PressureUnit.NewtonPerSquareMillimeter: return baseUnitValue/1e6;
- case PressureUnit.Pascal: return baseUnitValue;
- case PressureUnit.PoundForcePerSquareFoot: return baseUnitValue/4.788025898033584e1;
- case PressureUnit.PoundForcePerSquareInch: return baseUnitValue/6.894757293168361e3;
- case PressureUnit.PoundPerInchSecondSquared: return baseUnitValue/1.785796732283465e1;
- case PressureUnit.Psi: return baseUnitValue/6.894757293168361e3;
- case PressureUnit.TechnicalAtmosphere: return baseUnitValue/(9.80680592331*1e4);
- case PressureUnit.TonneForcePerSquareCentimeter: return baseUnitValue/9.80665e7;
- case PressureUnit.TonneForcePerSquareMeter: return baseUnitValue/9.80665e3;
- case PressureUnit.TonneForcePerSquareMillimeter: return baseUnitValue/9.80665e9;
- case PressureUnit.Torr: return baseUnitValue/(1.3332266752*1e2);
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Pressure Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Pressure result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PressureUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Pascal
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PressureUnit ToStringDefaultUnit { get; set; } = PressureUnit.Pascal;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PressureUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Pressure
- ///
- public static Pressure MaxValue => new Pressure(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Pressure
- ///
- public static Pressure MinValue => new Pressure(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Pressure.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Pressure.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/PressureChangeRate.Common.g.cs b/Common/GeneratedCode/Quantities/PressureChangeRate.Common.g.cs
deleted file mode 100644
index 31f7294fd7..0000000000
--- a/Common/GeneratedCode/Quantities/PressureChangeRate.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time).
- ///
- // 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 PressureChangeRate : IQuantity
-#else
- public partial struct PressureChangeRate : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly PressureChangeRateUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static PressureChangeRate()
- {
- BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit PascalPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public PressureChangeRate(double pascalspersecond)
- {
- _value = Convert.ToDouble(pascalspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- PressureChangeRate(double numericValue, PressureChangeRateUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit PascalPerSecond.
- ///
- /// Value assuming base unit PascalPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PressureChangeRate(long pascalspersecond) : this(Convert.ToDouble(pascalspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit PascalPerSecond.
- ///
- /// Value assuming base unit PascalPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- PressureChangeRate(decimal pascalspersecond) : this(Convert.ToDouble(pascalspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.PressureChangeRate;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static PressureChangeRateUnit BaseUnit => PressureChangeRateUnit.PascalPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the PressureChangeRate quantity.
- ///
- public static PressureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().Except(new PressureChangeRateUnit[]{ PressureChangeRateUnit.Undefined }).ToArray();
-
- ///
- /// Get PressureChangeRate in AtmospheresPerSecond.
- ///
- public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond);
-
- ///
- /// Get PressureChangeRate in KilopascalsPerSecond.
- ///
- public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond);
-
- ///
- /// Get PressureChangeRate in MegapascalsPerSecond.
- ///
- public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond);
-
- ///
- /// Get PressureChangeRate in PascalsPerSecond.
- ///
- public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit PascalPerSecond.
- ///
- public static PressureChangeRate Zero => new PressureChangeRate(0, BaseUnit);
-
- ///
- /// Get PressureChangeRate from AtmospheresPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PressureChangeRate FromAtmospheresPerSecond(double atmospherespersecond)
-#else
- public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmospherespersecond)
-#endif
- {
- double value = (double) atmospherespersecond;
- return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond);
- }
-
- ///
- /// Get PressureChangeRate from KilopascalsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PressureChangeRate FromKilopascalsPerSecond(double kilopascalspersecond)
-#else
- public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopascalspersecond)
-#endif
- {
- double value = (double) kilopascalspersecond;
- return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond);
- }
-
- ///
- /// Get PressureChangeRate from MegapascalsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PressureChangeRate FromMegapascalsPerSecond(double megapascalspersecond)
-#else
- public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapascalspersecond)
-#endif
- {
- double value = (double) megapascalspersecond;
- return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond);
- }
-
- ///
- /// Get PressureChangeRate from PascalsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static PressureChangeRate FromPascalsPerSecond(double pascalspersecond)
-#else
- public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalspersecond)
-#endif
- {
- double value = (double) pascalspersecond;
- return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// PressureChangeRate unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static PressureChangeRate From(double value, PressureChangeRateUnit fromUnit)
-#else
- public static PressureChangeRate From(QuantityValue value, PressureChangeRateUnit fromUnit)
-#endif
- {
- return new PressureChangeRate((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(PressureChangeRateUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is PressureChangeRate)) throw new ArgumentException("Expected type PressureChangeRate.", nameof(obj));
-
- return CompareTo((PressureChangeRate)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(PressureChangeRate other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(PressureChangeRate, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is PressureChangeRate))
- return false;
-
- var objQuantity = (PressureChangeRate)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another PressureChangeRate 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.
- [Obsolete("Please use the Equals(PressureChangeRate, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(PressureChangeRate other, PressureChangeRate maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current PressureChangeRate.
- public override int GetHashCode()
- {
- return new { type = typeof(PressureChangeRate), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(PressureChangeRateUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation .
- ///
- /// A PressureChangeRate with the specified unit.
- public PressureChangeRate ToUnit(PressureChangeRateUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new PressureChangeRate(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case PressureChangeRateUnit.AtmospherePerSecond: return _value * 1.01325*1e5;
- case PressureChangeRateUnit.KilopascalPerSecond: return (_value) * 1e3d;
- case PressureChangeRateUnit.MegapascalPerSecond: return (_value) * 1e6d;
- case PressureChangeRateUnit.PascalPerSecond: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(PressureChangeRateUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case PressureChangeRateUnit.AtmospherePerSecond: return baseUnitValue / (1.01325*1e5);
- case PressureChangeRateUnit.KilopascalPerSecond: return (baseUnitValue) / 1e3d;
- case PressureChangeRateUnit.MegapascalPerSecond: return (baseUnitValue) / 1e6d;
- case PressureChangeRateUnit.PascalPerSecond: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 PressureChangeRate Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 PressureChangeRate result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static PressureChangeRateUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is PascalPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static PressureChangeRateUnit ToStringDefaultUnit { get; set; } = PressureChangeRateUnit.PascalPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(PressureChangeRateUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of PressureChangeRate
- ///
- public static PressureChangeRate MaxValue => new PressureChangeRate(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of PressureChangeRate
- ///
- public static PressureChangeRate MinValue => new PressureChangeRate(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => PressureChangeRate.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => PressureChangeRate.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Ratio.Common.g.cs b/Common/GeneratedCode/Quantities/Ratio.Common.g.cs
deleted file mode 100644
index 968ce10102..0000000000
--- a/Common/GeneratedCode/Quantities/Ratio.Common.g.cs
+++ /dev/null
@@ -1,594 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).
- ///
- // 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 Ratio : IQuantity
-#else
- public partial struct Ratio : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly RatioUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public RatioUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Ratio()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit DecimalFraction.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Ratio(double decimalfractions)
- {
- _value = Convert.ToDouble(decimalfractions);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Ratio(double numericValue, RatioUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecimalFraction.
- ///
- /// Value assuming base unit DecimalFraction.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Ratio(long decimalfractions) : this(Convert.ToDouble(decimalfractions), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DecimalFraction.
- ///
- /// Value assuming base unit DecimalFraction.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Ratio(decimal decimalfractions) : this(Convert.ToDouble(decimalfractions), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Ratio;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static RatioUnit BaseUnit => RatioUnit.DecimalFraction;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Ratio quantity.
- ///
- public static RatioUnit[] Units { get; } = Enum.GetValues(typeof(RatioUnit)).Cast().Except(new RatioUnit[]{ RatioUnit.Undefined }).ToArray();
-
- ///
- /// Get Ratio in DecimalFractions.
- ///
- public double DecimalFractions => As(RatioUnit.DecimalFraction);
-
- ///
- /// Get Ratio in PartsPerBillion.
- ///
- public double PartsPerBillion => As(RatioUnit.PartPerBillion);
-
- ///
- /// Get Ratio in PartsPerMillion.
- ///
- public double PartsPerMillion => As(RatioUnit.PartPerMillion);
-
- ///
- /// Get Ratio in PartsPerThousand.
- ///
- public double PartsPerThousand => As(RatioUnit.PartPerThousand);
-
- ///
- /// Get Ratio in PartsPerTrillion.
- ///
- public double PartsPerTrillion => As(RatioUnit.PartPerTrillion);
-
- ///
- /// Get Ratio in Percent.
- ///
- public double Percent => As(RatioUnit.Percent);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction.
- ///
- public static Ratio Zero => new Ratio(0, BaseUnit);
-
- ///
- /// Get Ratio from DecimalFractions.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromDecimalFractions(double decimalfractions)
-#else
- public static Ratio FromDecimalFractions(QuantityValue decimalfractions)
-#endif
- {
- double value = (double) decimalfractions;
- return new Ratio(value, RatioUnit.DecimalFraction);
- }
-
- ///
- /// Get Ratio from PartsPerBillion.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromPartsPerBillion(double partsperbillion)
-#else
- public static Ratio FromPartsPerBillion(QuantityValue partsperbillion)
-#endif
- {
- double value = (double) partsperbillion;
- return new Ratio(value, RatioUnit.PartPerBillion);
- }
-
- ///
- /// Get Ratio from PartsPerMillion.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromPartsPerMillion(double partspermillion)
-#else
- public static Ratio FromPartsPerMillion(QuantityValue partspermillion)
-#endif
- {
- double value = (double) partspermillion;
- return new Ratio(value, RatioUnit.PartPerMillion);
- }
-
- ///
- /// Get Ratio from PartsPerThousand.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromPartsPerThousand(double partsperthousand)
-#else
- public static Ratio FromPartsPerThousand(QuantityValue partsperthousand)
-#endif
- {
- double value = (double) partsperthousand;
- return new Ratio(value, RatioUnit.PartPerThousand);
- }
-
- ///
- /// Get Ratio from PartsPerTrillion.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromPartsPerTrillion(double partspertrillion)
-#else
- public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion)
-#endif
- {
- double value = (double) partspertrillion;
- return new Ratio(value, RatioUnit.PartPerTrillion);
- }
-
- ///
- /// Get Ratio from Percent.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Ratio FromPercent(double percent)
-#else
- public static Ratio FromPercent(QuantityValue percent)
-#endif
- {
- double value = (double) percent;
- return new Ratio(value, RatioUnit.Percent);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Ratio unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Ratio From(double value, RatioUnit fromUnit)
-#else
- public static Ratio From(QuantityValue value, RatioUnit fromUnit)
-#endif
- {
- return new Ratio((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(RatioUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Ratio)) throw new ArgumentException("Expected type Ratio.", nameof(obj));
-
- return CompareTo((Ratio)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(Ratio other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Ratio, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Ratio))
- return false;
-
- var objQuantity = (Ratio)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Ratio within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Ratio 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.
- [Obsolete("Please use the Equals(Ratio, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Ratio other, Ratio maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Ratio.
- public override int GetHashCode()
- {
- return new { type = typeof(Ratio), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(RatioUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Ratio to another Ratio with the unit representation .
- ///
- /// A Ratio with the specified unit.
- public Ratio ToUnit(RatioUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Ratio(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case RatioUnit.DecimalFraction: return _value;
- case RatioUnit.PartPerBillion: return _value/1e9;
- case RatioUnit.PartPerMillion: return _value/1e6;
- case RatioUnit.PartPerThousand: return _value/1e3;
- case RatioUnit.PartPerTrillion: return _value/1e12;
- case RatioUnit.Percent: return _value/1e2;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(RatioUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case RatioUnit.DecimalFraction: return baseUnitValue;
- case RatioUnit.PartPerBillion: return baseUnitValue*1e9;
- case RatioUnit.PartPerMillion: return baseUnitValue*1e6;
- case RatioUnit.PartPerThousand: return baseUnitValue*1e3;
- case RatioUnit.PartPerTrillion: return baseUnitValue*1e12;
- case RatioUnit.Percent: return baseUnitValue*1e2;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Ratio Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Ratio result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static RatioUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is DecimalFraction
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static RatioUnit ToStringDefaultUnit { get; set; } = RatioUnit.DecimalFraction;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(RatioUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Ratio
- ///
- public static Ratio MaxValue => new Ratio(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Ratio
- ///
- public static Ratio MinValue => new Ratio(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Ratio.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Ratio.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ReactiveEnergy.Common.g.cs b/Common/GeneratedCode/Quantities/ReactiveEnergy.Common.g.cs
deleted file mode 100644
index dc65fe6a37..0000000000
--- a/Common/GeneratedCode/Quantities/ReactiveEnergy.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.
- ///
- // 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 ReactiveEnergy : IQuantity
-#else
- public partial struct ReactiveEnergy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ReactiveEnergyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ReactiveEnergy()
- {
- BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltampereReactiveHour.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ReactiveEnergy(double voltamperereactivehours)
- {
- _value = Convert.ToDouble(voltamperereactivehours);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ReactiveEnergy(double numericValue, ReactiveEnergyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereReactiveHour.
- ///
- /// Value assuming base unit VoltampereReactiveHour.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ReactiveEnergy(long voltamperereactivehours) : this(Convert.ToDouble(voltamperereactivehours), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereReactiveHour.
- ///
- /// Value assuming base unit VoltampereReactiveHour.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ReactiveEnergy(decimal voltamperereactivehours) : this(Convert.ToDouble(voltamperereactivehours), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ReactiveEnergy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ReactiveEnergyUnit BaseUnit => ReactiveEnergyUnit.VoltampereReactiveHour;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ReactiveEnergy quantity.
- ///
- public static ReactiveEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().Except(new ReactiveEnergyUnit[]{ ReactiveEnergyUnit.Undefined }).ToArray();
-
- ///
- /// Get ReactiveEnergy in KilovoltampereReactiveHours.
- ///
- public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour);
-
- ///
- /// Get ReactiveEnergy in MegavoltampereReactiveHours.
- ///
- public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour);
-
- ///
- /// Get ReactiveEnergy in VoltampereReactiveHours.
- ///
- public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactiveHour.
- ///
- public static ReactiveEnergy Zero => new ReactiveEnergy(0, BaseUnit);
-
- ///
- /// Get ReactiveEnergy from KilovoltampereReactiveHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactiveEnergy FromKilovoltampereReactiveHours(double kilovoltamperereactivehours)
-#else
- public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilovoltamperereactivehours)
-#endif
- {
- double value = (double) kilovoltamperereactivehours;
- return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour);
- }
-
- ///
- /// Get ReactiveEnergy from MegavoltampereReactiveHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactiveEnergy FromMegavoltampereReactiveHours(double megavoltamperereactivehours)
-#else
- public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megavoltamperereactivehours)
-#endif
- {
- double value = (double) megavoltamperereactivehours;
- return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour);
- }
-
- ///
- /// Get ReactiveEnergy from VoltampereReactiveHours.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactiveEnergy FromVoltampereReactiveHours(double voltamperereactivehours)
-#else
- public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamperereactivehours)
-#endif
- {
- double value = (double) voltamperereactivehours;
- return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ReactiveEnergy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ReactiveEnergy From(double value, ReactiveEnergyUnit fromUnit)
-#else
- public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUnit)
-#endif
- {
- return new ReactiveEnergy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ReactiveEnergyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ReactiveEnergy)) throw new ArgumentException("Expected type ReactiveEnergy.", nameof(obj));
-
- return CompareTo((ReactiveEnergy)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(ReactiveEnergy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ReactiveEnergy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ReactiveEnergy))
- return false;
-
- var objQuantity = (ReactiveEnergy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ReactiveEnergy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ReactiveEnergy 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.
- [Obsolete("Please use the Equals(ReactiveEnergy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ReactiveEnergy other, ReactiveEnergy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ReactiveEnergy.
- public override int GetHashCode()
- {
- return new { type = typeof(ReactiveEnergy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ReactiveEnergyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ReactiveEnergy to another ReactiveEnergy with the unit representation .
- ///
- /// A ReactiveEnergy with the specified unit.
- public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ReactiveEnergy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (_value) * 1e3d;
- case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (_value) * 1e6d;
- case ReactiveEnergyUnit.VoltampereReactiveHour: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ReactiveEnergyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (baseUnitValue) / 1e3d;
- case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (baseUnitValue) / 1e6d;
- case ReactiveEnergyUnit.VoltampereReactiveHour: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ReactiveEnergy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ReactiveEnergy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ReactiveEnergyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltampereReactiveHour
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ReactiveEnergyUnit ToStringDefaultUnit { get; set; } = ReactiveEnergyUnit.VoltampereReactiveHour;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ReactiveEnergyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ReactiveEnergy
- ///
- public static ReactiveEnergy MaxValue => new ReactiveEnergy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ReactiveEnergy
- ///
- public static ReactiveEnergy MinValue => new ReactiveEnergy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ReactiveEnergy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ReactiveEnergy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ReactivePower.Common.g.cs b/Common/GeneratedCode/Quantities/ReactivePower.Common.g.cs
deleted file mode 100644
index 95fd1c5e60..0000000000
--- a/Common/GeneratedCode/Quantities/ReactivePower.Common.g.cs
+++ /dev/null
@@ -1,553 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.
- ///
- // 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 ReactivePower : IQuantity
-#else
- public partial struct ReactivePower : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ReactivePowerUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ReactivePowerUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ReactivePower()
- {
- BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit VoltampereReactive.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ReactivePower(double voltamperesreactive)
- {
- _value = Convert.ToDouble(voltamperesreactive);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ReactivePower(double numericValue, ReactivePowerUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereReactive.
- ///
- /// Value assuming base unit VoltampereReactive.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ReactivePower(long voltamperesreactive) : this(Convert.ToDouble(voltamperesreactive), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit VoltampereReactive.
- ///
- /// Value assuming base unit VoltampereReactive.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ReactivePower(decimal voltamperesreactive) : this(Convert.ToDouble(voltamperesreactive), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ReactivePower;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ReactivePowerUnit BaseUnit => ReactivePowerUnit.VoltampereReactive;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ReactivePower quantity.
- ///
- public static ReactivePowerUnit[] Units { get; } = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().Except(new ReactivePowerUnit[]{ ReactivePowerUnit.Undefined }).ToArray();
-
- ///
- /// Get ReactivePower in GigavoltamperesReactive.
- ///
- public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive);
-
- ///
- /// Get ReactivePower in KilovoltamperesReactive.
- ///
- public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive);
-
- ///
- /// Get ReactivePower in MegavoltamperesReactive.
- ///
- public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive);
-
- ///
- /// Get ReactivePower in VoltamperesReactive.
- ///
- public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactive.
- ///
- public static ReactivePower Zero => new ReactivePower(0, BaseUnit);
-
- ///
- /// Get ReactivePower from GigavoltamperesReactive.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactivePower FromGigavoltamperesReactive(double gigavoltamperesreactive)
-#else
- public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltamperesreactive)
-#endif
- {
- double value = (double) gigavoltamperesreactive;
- return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive);
- }
-
- ///
- /// Get ReactivePower from KilovoltamperesReactive.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactivePower FromKilovoltamperesReactive(double kilovoltamperesreactive)
-#else
- public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltamperesreactive)
-#endif
- {
- double value = (double) kilovoltamperesreactive;
- return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive);
- }
-
- ///
- /// Get ReactivePower from MegavoltamperesReactive.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactivePower FromMegavoltamperesReactive(double megavoltamperesreactive)
-#else
- public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltamperesreactive)
-#endif
- {
- double value = (double) megavoltamperesreactive;
- return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive);
- }
-
- ///
- /// Get ReactivePower from VoltamperesReactive.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ReactivePower FromVoltamperesReactive(double voltamperesreactive)
-#else
- public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesreactive)
-#endif
- {
- double value = (double) voltamperesreactive;
- return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ReactivePower unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ReactivePower From(double value, ReactivePowerUnit fromUnit)
-#else
- public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit)
-#endif
- {
- return new ReactivePower((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ReactivePowerUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ReactivePower)) throw new ArgumentException("Expected type ReactivePower.", nameof(obj));
-
- return CompareTo((ReactivePower)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(ReactivePower other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ReactivePower, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ReactivePower))
- return false;
-
- var objQuantity = (ReactivePower)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ReactivePower within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ReactivePower 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.
- [Obsolete("Please use the Equals(ReactivePower, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ReactivePower other, ReactivePower maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ReactivePower.
- public override int GetHashCode()
- {
- return new { type = typeof(ReactivePower), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ReactivePowerUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ReactivePower to another ReactivePower with the unit representation .
- ///
- /// A ReactivePower with the specified unit.
- public ReactivePower ToUnit(ReactivePowerUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ReactivePower(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ReactivePowerUnit.GigavoltampereReactive: return (_value) * 1e9d;
- case ReactivePowerUnit.KilovoltampereReactive: return (_value) * 1e3d;
- case ReactivePowerUnit.MegavoltampereReactive: return (_value) * 1e6d;
- case ReactivePowerUnit.VoltampereReactive: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ReactivePowerUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ReactivePowerUnit.GigavoltampereReactive: return (baseUnitValue) / 1e9d;
- case ReactivePowerUnit.KilovoltampereReactive: return (baseUnitValue) / 1e3d;
- case ReactivePowerUnit.MegavoltampereReactive: return (baseUnitValue) / 1e6d;
- case ReactivePowerUnit.VoltampereReactive: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ReactivePower Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ReactivePower result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ReactivePowerUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is VoltampereReactive
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ReactivePowerUnit ToStringDefaultUnit { get; set; } = ReactivePowerUnit.VoltampereReactive;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ReactivePowerUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ReactivePower
- ///
- public static ReactivePower MaxValue => new ReactivePower(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ReactivePower
- ///
- public static ReactivePower MinValue => new ReactivePower(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ReactivePower.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ReactivePower.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/RotationalAcceleration.Common.g.cs b/Common/GeneratedCode/Quantities/RotationalAcceleration.Common.g.cs
deleted file mode 100644
index cbc6b16d45..0000000000
--- a/Common/GeneratedCode/Quantities/RotationalAcceleration.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Angular acceleration is the rate of change of rotational speed.
- ///
- // 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 RotationalAcceleration : IQuantity
-#else
- public partial struct RotationalAcceleration : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly RotationalAccelerationUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static RotationalAcceleration()
- {
- BaseDimensions = new BaseDimensions(0, 0, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit RadianPerSecondSquared.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public RotationalAcceleration(double radianspersecondsquared)
- {
- _value = Convert.ToDouble(radianspersecondsquared);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- RotationalAcceleration(double numericValue, RotationalAccelerationUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit RadianPerSecondSquared.
- ///
- /// Value assuming base unit RadianPerSecondSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalAcceleration(long radianspersecondsquared) : this(Convert.ToDouble(radianspersecondsquared), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit RadianPerSecondSquared.
- ///
- /// Value assuming base unit RadianPerSecondSquared.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalAcceleration(decimal radianspersecondsquared) : this(Convert.ToDouble(radianspersecondsquared), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.RotationalAcceleration;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static RotationalAccelerationUnit BaseUnit => RotationalAccelerationUnit.RadianPerSecondSquared;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the RotationalAcceleration quantity.
- ///
- public static RotationalAccelerationUnit[] Units { get; } = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().Except(new RotationalAccelerationUnit[]{ RotationalAccelerationUnit.Undefined }).ToArray();
-
- ///
- /// Get RotationalAcceleration in DegreesPerSecondSquared.
- ///
- public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared);
-
- ///
- /// Get RotationalAcceleration in RadiansPerSecondSquared.
- ///
- public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared);
-
- ///
- /// Get RotationalAcceleration in RevolutionsPerMinutePerSecond.
- ///
- public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecondSquared.
- ///
- public static RotationalAcceleration Zero => new RotationalAcceleration(0, BaseUnit);
-
- ///
- /// Get RotationalAcceleration from DegreesPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalAcceleration FromDegreesPerSecondSquared(double degreespersecondsquared)
-#else
- public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue degreespersecondsquared)
-#endif
- {
- double value = (double) degreespersecondsquared;
- return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared);
- }
-
- ///
- /// Get RotationalAcceleration from RadiansPerSecondSquared.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalAcceleration FromRadiansPerSecondSquared(double radianspersecondsquared)
-#else
- public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue radianspersecondsquared)
-#endif
- {
- double value = (double) radianspersecondsquared;
- return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared);
- }
-
- ///
- /// Get RotationalAcceleration from RevolutionsPerMinutePerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(double revolutionsperminutepersecond)
-#else
- public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityValue revolutionsperminutepersecond)
-#endif
- {
- double value = (double) revolutionsperminutepersecond;
- return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// RotationalAcceleration unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static RotationalAcceleration From(double value, RotationalAccelerationUnit fromUnit)
-#else
- public static RotationalAcceleration From(QuantityValue value, RotationalAccelerationUnit fromUnit)
-#endif
- {
- return new RotationalAcceleration((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(RotationalAccelerationUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is RotationalAcceleration)) throw new ArgumentException("Expected type RotationalAcceleration.", nameof(obj));
-
- return CompareTo((RotationalAcceleration)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(RotationalAcceleration other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(RotationalAcceleration, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is RotationalAcceleration))
- return false;
-
- var objQuantity = (RotationalAcceleration)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another RotationalAcceleration 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.
- [Obsolete("Please use the Equals(RotationalAcceleration, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(RotationalAcceleration other, RotationalAcceleration maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current RotationalAcceleration.
- public override int GetHashCode()
- {
- return new { type = typeof(RotationalAcceleration), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(RotationalAccelerationUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation .
- ///
- /// A RotationalAcceleration with the specified unit.
- public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new RotationalAcceleration(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case RotationalAccelerationUnit.DegreePerSecondSquared: return (Math.PI/180)*_value;
- case RotationalAccelerationUnit.RadianPerSecondSquared: return _value;
- case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return ((2*Math.PI)/60)*_value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(RotationalAccelerationUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case RotationalAccelerationUnit.DegreePerSecondSquared: return (180/Math.PI)*baseUnitValue;
- case RotationalAccelerationUnit.RadianPerSecondSquared: return baseUnitValue;
- case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return (60/(2*Math.PI))*baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 RotationalAcceleration Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 RotationalAcceleration result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static RotationalAccelerationUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is RadianPerSecondSquared
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static RotationalAccelerationUnit ToStringDefaultUnit { get; set; } = RotationalAccelerationUnit.RadianPerSecondSquared;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(RotationalAccelerationUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of RotationalAcceleration
- ///
- public static RotationalAcceleration MaxValue => new RotationalAcceleration(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of RotationalAcceleration
- ///
- public static RotationalAcceleration MinValue => new RotationalAcceleration(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => RotationalAcceleration.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => RotationalAcceleration.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/RotationalSpeed.Common.g.cs b/Common/GeneratedCode/Quantities/RotationalSpeed.Common.g.cs
deleted file mode 100644
index 9613a8574a..0000000000
--- a/Common/GeneratedCode/Quantities/RotationalSpeed.Common.g.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega").
- ///
- // 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 RotationalSpeed : IQuantity
-#else
- public partial struct RotationalSpeed : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly RotationalSpeedUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static RotationalSpeed()
- {
- BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit RadianPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public RotationalSpeed(double radianspersecond)
- {
- _value = Convert.ToDouble(radianspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- RotationalSpeed(double numericValue, RotationalSpeedUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit RadianPerSecond.
- ///
- /// Value assuming base unit RadianPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalSpeed(long radianspersecond) : this(Convert.ToDouble(radianspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit RadianPerSecond.
- ///
- /// Value assuming base unit RadianPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalSpeed(decimal radianspersecond) : this(Convert.ToDouble(radianspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.RotationalSpeed;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static RotationalSpeedUnit BaseUnit => RotationalSpeedUnit.RadianPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the RotationalSpeed quantity.
- ///
- public static RotationalSpeedUnit[] Units { get; } = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().Except(new RotationalSpeedUnit[]{ RotationalSpeedUnit.Undefined }).ToArray();
-
- ///
- /// Get RotationalSpeed in CentiradiansPerSecond.
- ///
- public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond);
-
- ///
- /// Get RotationalSpeed in DeciradiansPerSecond.
- ///
- public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond);
-
- ///
- /// Get RotationalSpeed in DegreesPerMinute.
- ///
- public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute);
-
- ///
- /// Get RotationalSpeed in DegreesPerSecond.
- ///
- public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond);
-
- ///
- /// Get RotationalSpeed in MicrodegreesPerSecond.
- ///
- public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond);
-
- ///
- /// Get RotationalSpeed in MicroradiansPerSecond.
- ///
- public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond);
-
- ///
- /// Get RotationalSpeed in MillidegreesPerSecond.
- ///
- public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond);
-
- ///
- /// Get RotationalSpeed in MilliradiansPerSecond.
- ///
- public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond);
-
- ///
- /// Get RotationalSpeed in NanodegreesPerSecond.
- ///
- public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond);
-
- ///
- /// Get RotationalSpeed in NanoradiansPerSecond.
- ///
- public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond);
-
- ///
- /// Get RotationalSpeed in RadiansPerSecond.
- ///
- public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond);
-
- ///
- /// Get RotationalSpeed in RevolutionsPerMinute.
- ///
- public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute);
-
- ///
- /// Get RotationalSpeed in RevolutionsPerSecond.
- ///
- public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecond.
- ///
- public static RotationalSpeed Zero => new RotationalSpeed(0, BaseUnit);
-
- ///
- /// Get RotationalSpeed from CentiradiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromCentiradiansPerSecond(double centiradianspersecond)
-#else
- public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradianspersecond)
-#endif
- {
- double value = (double) centiradianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from DeciradiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromDeciradiansPerSecond(double deciradianspersecond)
-#else
- public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradianspersecond)
-#endif
- {
- double value = (double) deciradianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from DegreesPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromDegreesPerMinute(double degreesperminute)
-#else
- public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminute)
-#endif
- {
- double value = (double) degreesperminute;
- return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute);
- }
-
- ///
- /// Get RotationalSpeed from DegreesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromDegreesPerSecond(double degreespersecond)
-#else
- public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecond)
-#endif
- {
- double value = (double) degreespersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond);
- }
-
- ///
- /// Get RotationalSpeed from MicrodegreesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromMicrodegreesPerSecond(double microdegreespersecond)
-#else
- public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegreespersecond)
-#endif
- {
- double value = (double) microdegreespersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond);
- }
-
- ///
- /// Get RotationalSpeed from MicroradiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromMicroradiansPerSecond(double microradianspersecond)
-#else
- public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradianspersecond)
-#endif
- {
- double value = (double) microradianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from MillidegreesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromMillidegreesPerSecond(double millidegreespersecond)
-#else
- public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegreespersecond)
-#endif
- {
- double value = (double) millidegreespersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond);
- }
-
- ///
- /// Get RotationalSpeed from MilliradiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromMilliradiansPerSecond(double milliradianspersecond)
-#else
- public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradianspersecond)
-#endif
- {
- double value = (double) milliradianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from NanodegreesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromNanodegreesPerSecond(double nanodegreespersecond)
-#else
- public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegreespersecond)
-#endif
- {
- double value = (double) nanodegreespersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond);
- }
-
- ///
- /// Get RotationalSpeed from NanoradiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromNanoradiansPerSecond(double nanoradianspersecond)
-#else
- public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradianspersecond)
-#endif
- {
- double value = (double) nanoradianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from RadiansPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromRadiansPerSecond(double radianspersecond)
-#else
- public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecond)
-#endif
- {
- double value = (double) radianspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond);
- }
-
- ///
- /// Get RotationalSpeed from RevolutionsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromRevolutionsPerMinute(double revolutionsperminute)
-#else
- public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutionsperminute)
-#endif
- {
- double value = (double) revolutionsperminute;
- return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute);
- }
-
- ///
- /// Get RotationalSpeed from RevolutionsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalSpeed FromRevolutionsPerSecond(double revolutionspersecond)
-#else
- public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutionspersecond)
-#endif
- {
- double value = (double) revolutionspersecond;
- return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// RotationalSpeed unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit)
-#else
- public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit)
-#endif
- {
- return new RotationalSpeed((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(RotationalSpeedUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is RotationalSpeed)) throw new ArgumentException("Expected type RotationalSpeed.", nameof(obj));
-
- return CompareTo((RotationalSpeed)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(RotationalSpeed other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(RotationalSpeed, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is RotationalSpeed))
- return false;
-
- var objQuantity = (RotationalSpeed)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another RotationalSpeed 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.
- [Obsolete("Please use the Equals(RotationalSpeed, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(RotationalSpeed other, RotationalSpeed maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current RotationalSpeed.
- public override int GetHashCode()
- {
- return new { type = typeof(RotationalSpeed), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(RotationalSpeedUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation .
- ///
- /// A RotationalSpeed with the specified unit.
- public RotationalSpeed ToUnit(RotationalSpeedUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new RotationalSpeed(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case RotationalSpeedUnit.CentiradianPerSecond: return (_value) * 1e-2d;
- case RotationalSpeedUnit.DeciradianPerSecond: return (_value) * 1e-1d;
- case RotationalSpeedUnit.DegreePerMinute: return (Math.PI/(180*60))*_value;
- case RotationalSpeedUnit.DegreePerSecond: return (Math.PI/180)*_value;
- case RotationalSpeedUnit.MicrodegreePerSecond: return ((Math.PI/180)*_value) * 1e-6d;
- case RotationalSpeedUnit.MicroradianPerSecond: return (_value) * 1e-6d;
- case RotationalSpeedUnit.MillidegreePerSecond: return ((Math.PI/180)*_value) * 1e-3d;
- case RotationalSpeedUnit.MilliradianPerSecond: return (_value) * 1e-3d;
- case RotationalSpeedUnit.NanodegreePerSecond: return ((Math.PI/180)*_value) * 1e-9d;
- case RotationalSpeedUnit.NanoradianPerSecond: return (_value) * 1e-9d;
- case RotationalSpeedUnit.RadianPerSecond: return _value;
- case RotationalSpeedUnit.RevolutionPerMinute: return (_value*6.2831853072)/60;
- case RotationalSpeedUnit.RevolutionPerSecond: return _value*6.2831853072;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(RotationalSpeedUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case RotationalSpeedUnit.CentiradianPerSecond: return (baseUnitValue) / 1e-2d;
- case RotationalSpeedUnit.DeciradianPerSecond: return (baseUnitValue) / 1e-1d;
- case RotationalSpeedUnit.DegreePerMinute: return (180*60/Math.PI)*baseUnitValue;
- case RotationalSpeedUnit.DegreePerSecond: return (180/Math.PI)*baseUnitValue;
- case RotationalSpeedUnit.MicrodegreePerSecond: return ((180/Math.PI)*baseUnitValue) / 1e-6d;
- case RotationalSpeedUnit.MicroradianPerSecond: return (baseUnitValue) / 1e-6d;
- case RotationalSpeedUnit.MillidegreePerSecond: return ((180/Math.PI)*baseUnitValue) / 1e-3d;
- case RotationalSpeedUnit.MilliradianPerSecond: return (baseUnitValue) / 1e-3d;
- case RotationalSpeedUnit.NanodegreePerSecond: return ((180/Math.PI)*baseUnitValue) / 1e-9d;
- case RotationalSpeedUnit.NanoradianPerSecond: return (baseUnitValue) / 1e-9d;
- case RotationalSpeedUnit.RadianPerSecond: return baseUnitValue;
- case RotationalSpeedUnit.RevolutionPerMinute: return (baseUnitValue/6.2831853072)*60;
- case RotationalSpeedUnit.RevolutionPerSecond: return baseUnitValue/6.2831853072;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 RotationalSpeed Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 RotationalSpeed result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static RotationalSpeedUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is RadianPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static RotationalSpeedUnit ToStringDefaultUnit { get; set; } = RotationalSpeedUnit.RadianPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(RotationalSpeedUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of RotationalSpeed
- ///
- public static RotationalSpeed MaxValue => new RotationalSpeed(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of RotationalSpeed
- ///
- public static RotationalSpeed MinValue => new RotationalSpeed(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => RotationalSpeed.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => RotationalSpeed.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/RotationalStiffness.Common.g.cs b/Common/GeneratedCode/Quantities/RotationalStiffness.Common.g.cs
deleted file mode 100644
index 1acea7cd26..0000000000
--- a/Common/GeneratedCode/Quantities/RotationalStiffness.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness
- ///
- // 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 RotationalStiffness : IQuantity
-#else
- public partial struct RotationalStiffness : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly RotationalStiffnessUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static RotationalStiffness()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonMeterPerRadian.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public RotationalStiffness(double newtonmetersperradian)
- {
- _value = Convert.ToDouble(newtonmetersperradian);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- RotationalStiffness(double numericValue, RotationalStiffnessUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeterPerRadian.
- ///
- /// Value assuming base unit NewtonMeterPerRadian.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalStiffness(long newtonmetersperradian) : this(Convert.ToDouble(newtonmetersperradian), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeterPerRadian.
- ///
- /// Value assuming base unit NewtonMeterPerRadian.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalStiffness(decimal newtonmetersperradian) : this(Convert.ToDouble(newtonmetersperradian), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.RotationalStiffness;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static RotationalStiffnessUnit BaseUnit => RotationalStiffnessUnit.NewtonMeterPerRadian;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the RotationalStiffness quantity.
- ///
- public static RotationalStiffnessUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().Except(new RotationalStiffnessUnit[]{ RotationalStiffnessUnit.Undefined }).ToArray();
-
- ///
- /// Get RotationalStiffness in KilonewtonMetersPerRadian.
- ///
- public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian);
-
- ///
- /// Get RotationalStiffness in MeganewtonMetersPerRadian.
- ///
- public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian);
-
- ///
- /// Get RotationalStiffness in NewtonMetersPerRadian.
- ///
- public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadian.
- ///
- public static RotationalStiffness Zero => new RotationalStiffness(0, BaseUnit);
-
- ///
- /// Get RotationalStiffness from KilonewtonMetersPerRadian.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffness FromKilonewtonMetersPerRadian(double kilonewtonmetersperradian)
-#else
- public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue kilonewtonmetersperradian)
-#endif
- {
- double value = (double) kilonewtonmetersperradian;
- return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian);
- }
-
- ///
- /// Get RotationalStiffness from MeganewtonMetersPerRadian.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffness FromMeganewtonMetersPerRadian(double meganewtonmetersperradian)
-#else
- public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue meganewtonmetersperradian)
-#endif
- {
- double value = (double) meganewtonmetersperradian;
- return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian);
- }
-
- ///
- /// Get RotationalStiffness from NewtonMetersPerRadian.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffness FromNewtonMetersPerRadian(double newtonmetersperradian)
-#else
- public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newtonmetersperradian)
-#endif
- {
- double value = (double) newtonmetersperradian;
- return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// RotationalStiffness unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static RotationalStiffness From(double value, RotationalStiffnessUnit fromUnit)
-#else
- public static RotationalStiffness From(QuantityValue value, RotationalStiffnessUnit fromUnit)
-#endif
- {
- return new RotationalStiffness((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(RotationalStiffnessUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is RotationalStiffness)) throw new ArgumentException("Expected type RotationalStiffness.", nameof(obj));
-
- return CompareTo((RotationalStiffness)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(RotationalStiffness other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(RotationalStiffness, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is RotationalStiffness))
- return false;
-
- var objQuantity = (RotationalStiffness)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another RotationalStiffness 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.
- [Obsolete("Please use the Equals(RotationalStiffness, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(RotationalStiffness other, RotationalStiffness maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current RotationalStiffness.
- public override int GetHashCode()
- {
- return new { type = typeof(RotationalStiffness), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(RotationalStiffnessUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation .
- ///
- /// A RotationalStiffness with the specified unit.
- public RotationalStiffness ToUnit(RotationalStiffnessUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new RotationalStiffness(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (_value) * 1e3d;
- case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (_value) * 1e6d;
- case RotationalStiffnessUnit.NewtonMeterPerRadian: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(RotationalStiffnessUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (baseUnitValue) / 1e3d;
- case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (baseUnitValue) / 1e6d;
- case RotationalStiffnessUnit.NewtonMeterPerRadian: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 RotationalStiffness Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 RotationalStiffness result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static RotationalStiffnessUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonMeterPerRadian
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static RotationalStiffnessUnit ToStringDefaultUnit { get; set; } = RotationalStiffnessUnit.NewtonMeterPerRadian;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(RotationalStiffnessUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of RotationalStiffness
- ///
- public static RotationalStiffness MaxValue => new RotationalStiffness(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of RotationalStiffness
- ///
- public static RotationalStiffness MinValue => new RotationalStiffness(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => RotationalStiffness.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => RotationalStiffness.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/RotationalStiffnessPerLength.Common.g.cs b/Common/GeneratedCode/Quantities/RotationalStiffnessPerLength.Common.g.cs
deleted file mode 100644
index 2ddb3ee574..0000000000
--- a/Common/GeneratedCode/Quantities/RotationalStiffnessPerLength.Common.g.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness
- ///
- // 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 RotationalStiffnessPerLength : IQuantity
-#else
- public partial struct RotationalStiffnessPerLength : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly RotationalStiffnessPerLengthUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static RotationalStiffnessPerLength()
- {
- BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonMeterPerRadianPerMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public RotationalStiffnessPerLength(double newtonmetersperradianpermeter)
- {
- _value = Convert.ToDouble(newtonmetersperradianpermeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- RotationalStiffnessPerLength(double numericValue, RotationalStiffnessPerLengthUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeterPerRadianPerMeter.
- ///
- /// Value assuming base unit NewtonMeterPerRadianPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalStiffnessPerLength(long newtonmetersperradianpermeter) : this(Convert.ToDouble(newtonmetersperradianpermeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeterPerRadianPerMeter.
- ///
- /// Value assuming base unit NewtonMeterPerRadianPerMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- RotationalStiffnessPerLength(decimal newtonmetersperradianpermeter) : this(Convert.ToDouble(newtonmetersperradianpermeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.RotationalStiffnessPerLength;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static RotationalStiffnessPerLengthUnit BaseUnit => RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the RotationalStiffnessPerLength quantity.
- ///
- public static RotationalStiffnessPerLengthUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().Except(new RotationalStiffnessPerLengthUnit[]{ RotationalStiffnessPerLengthUnit.Undefined }).ToArray();
-
- ///
- /// Get RotationalStiffnessPerLength in KilonewtonMetersPerRadianPerMeter.
- ///
- public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter);
-
- ///
- /// Get RotationalStiffnessPerLength in MeganewtonMetersPerRadianPerMeter.
- ///
- public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter);
-
- ///
- /// Get RotationalStiffnessPerLength in NewtonMetersPerRadianPerMeter.
- ///
- public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter.
- ///
- public static RotationalStiffnessPerLength Zero => new RotationalStiffnessPerLength(0, BaseUnit);
-
- ///
- /// Get RotationalStiffnessPerLength from KilonewtonMetersPerRadianPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(double kilonewtonmetersperradianpermeter)
-#else
- public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(QuantityValue kilonewtonmetersperradianpermeter)
-#endif
- {
- double value = (double) kilonewtonmetersperradianpermeter;
- return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter);
- }
-
- ///
- /// Get RotationalStiffnessPerLength from MeganewtonMetersPerRadianPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(double meganewtonmetersperradianpermeter)
-#else
- public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(QuantityValue meganewtonmetersperradianpermeter)
-#endif
- {
- double value = (double) meganewtonmetersperradianpermeter;
- return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter);
- }
-
- ///
- /// Get RotationalStiffnessPerLength from NewtonMetersPerRadianPerMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(double newtonmetersperradianpermeter)
-#else
- public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(QuantityValue newtonmetersperradianpermeter)
-#endif
- {
- double value = (double) newtonmetersperradianpermeter;
- return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// RotationalStiffnessPerLength unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static RotationalStiffnessPerLength From(double value, RotationalStiffnessPerLengthUnit fromUnit)
-#else
- public static RotationalStiffnessPerLength From(QuantityValue value, RotationalStiffnessPerLengthUnit fromUnit)
-#endif
- {
- return new RotationalStiffnessPerLength((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is RotationalStiffnessPerLength)) throw new ArgumentException("Expected type RotationalStiffnessPerLength.", nameof(obj));
-
- return CompareTo((RotationalStiffnessPerLength)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(RotationalStiffnessPerLength other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(RotationalStiffnessPerLength, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is RotationalStiffnessPerLength))
- return false;
-
- var objQuantity = (RotationalStiffnessPerLength)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another RotationalStiffnessPerLength 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.
- [Obsolete("Please use the Equals(RotationalStiffnessPerLength, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current RotationalStiffnessPerLength.
- public override int GetHashCode()
- {
- return new { type = typeof(RotationalStiffnessPerLength), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(RotationalStiffnessPerLengthUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation .
- ///
- /// A RotationalStiffnessPerLength with the specified unit.
- public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new RotationalStiffnessPerLength(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (_value) * 1e3d;
- case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (_value) * 1e6d;
- case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(RotationalStiffnessPerLengthUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (baseUnitValue) / 1e3d;
- case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (baseUnitValue) / 1e6d;
- case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 RotationalStiffnessPerLength Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 RotationalStiffnessPerLength result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static RotationalStiffnessPerLengthUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonMeterPerRadianPerMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static RotationalStiffnessPerLengthUnit ToStringDefaultUnit { get; set; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(RotationalStiffnessPerLengthUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of RotationalStiffnessPerLength
- ///
- public static RotationalStiffnessPerLength MaxValue => new RotationalStiffnessPerLength(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of RotationalStiffnessPerLength
- ///
- public static RotationalStiffnessPerLength MinValue => new RotationalStiffnessPerLength(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => RotationalStiffnessPerLength.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => RotationalStiffnessPerLength.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/SolidAngle.Common.g.cs b/Common/GeneratedCode/Quantities/SolidAngle.Common.g.cs
deleted file mode 100644
index cff028e8d9..0000000000
--- a/Common/GeneratedCode/Quantities/SolidAngle.Common.g.cs
+++ /dev/null
@@ -1,489 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point.
- ///
- // 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 SolidAngle : IQuantity
-#else
- public partial struct SolidAngle : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SolidAngleUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SolidAngleUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static SolidAngle()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Steradian.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public SolidAngle(double steradians)
- {
- _value = Convert.ToDouble(steradians);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- SolidAngle(double numericValue, SolidAngleUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Steradian.
- ///
- /// Value assuming base unit Steradian.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SolidAngle(long steradians) : this(Convert.ToDouble(steradians), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Steradian.
- ///
- /// Value assuming base unit Steradian.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SolidAngle(decimal steradians) : this(Convert.ToDouble(steradians), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.SolidAngle;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SolidAngleUnit BaseUnit => SolidAngleUnit.Steradian;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the SolidAngle quantity.
- ///
- public static SolidAngleUnit[] Units { get; } = Enum.GetValues(typeof(SolidAngleUnit)).Cast().Except(new SolidAngleUnit[]{ SolidAngleUnit.Undefined }).ToArray();
-
- ///
- /// Get SolidAngle in Steradians.
- ///
- public double Steradians => As(SolidAngleUnit.Steradian);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Steradian.
- ///
- public static SolidAngle Zero => new SolidAngle(0, BaseUnit);
-
- ///
- /// Get SolidAngle from Steradians.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SolidAngle FromSteradians(double steradians)
-#else
- public static SolidAngle FromSteradians(QuantityValue steradians)
-#endif
- {
- double value = (double) steradians;
- return new SolidAngle(value, SolidAngleUnit.Steradian);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// SolidAngle unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static SolidAngle From(double value, SolidAngleUnit fromUnit)
-#else
- public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit)
-#endif
- {
- return new SolidAngle((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SolidAngleUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is SolidAngle)) throw new ArgumentException("Expected type SolidAngle.", nameof(obj));
-
- return CompareTo((SolidAngle)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(SolidAngle other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(SolidAngle, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is SolidAngle))
- return false;
-
- var objQuantity = (SolidAngle)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another SolidAngle within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another SolidAngle 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.
- [Obsolete("Please use the Equals(SolidAngle, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(SolidAngle other, SolidAngle maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current SolidAngle.
- public override int GetHashCode()
- {
- return new { type = typeof(SolidAngle), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SolidAngleUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this SolidAngle to another SolidAngle with the unit representation .
- ///
- /// A SolidAngle with the specified unit.
- public SolidAngle ToUnit(SolidAngleUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new SolidAngle(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SolidAngleUnit.Steradian: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SolidAngleUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SolidAngleUnit.Steradian: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 SolidAngle Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 SolidAngle result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SolidAngleUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Steradian
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SolidAngleUnit ToStringDefaultUnit { get; set; } = SolidAngleUnit.Steradian;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SolidAngleUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of SolidAngle
- ///
- public static SolidAngle MaxValue => new SolidAngle(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of SolidAngle
- ///
- public static SolidAngle MinValue => new SolidAngle(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => SolidAngle.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => SolidAngle.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/SpecificEnergy.Common.g.cs b/Common/GeneratedCode/Quantities/SpecificEnergy.Common.g.cs
deleted file mode 100644
index 2bfd75da0c..0000000000
--- a/Common/GeneratedCode/Quantities/SpecificEnergy.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The SpecificEnergy
- ///
- // 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 SpecificEnergy : IQuantity
-#else
- public partial struct SpecificEnergy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SpecificEnergyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static SpecificEnergy()
- {
- BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerKilogram.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public SpecificEnergy(double joulesperkilogram)
- {
- _value = Convert.ToDouble(joulesperkilogram);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- SpecificEnergy(double numericValue, SpecificEnergyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKilogram.
- ///
- /// Value assuming base unit JoulePerKilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificEnergy(long joulesperkilogram) : this(Convert.ToDouble(joulesperkilogram), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKilogram.
- ///
- /// Value assuming base unit JoulePerKilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificEnergy(decimal joulesperkilogram) : this(Convert.ToDouble(joulesperkilogram), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.SpecificEnergy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SpecificEnergyUnit BaseUnit => SpecificEnergyUnit.JoulePerKilogram;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the SpecificEnergy quantity.
- ///
- public static SpecificEnergyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().Except(new SpecificEnergyUnit[]{ SpecificEnergyUnit.Undefined }).ToArray();
-
- ///
- /// Get SpecificEnergy in CaloriesPerGram.
- ///
- public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram);
-
- ///
- /// Get SpecificEnergy in JoulesPerKilogram.
- ///
- public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram);
-
- ///
- /// Get SpecificEnergy in KilocaloriesPerGram.
- ///
- public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram);
-
- ///
- /// Get SpecificEnergy in KilojoulesPerKilogram.
- ///
- public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram);
-
- ///
- /// Get SpecificEnergy in KilowattHoursPerKilogram.
- ///
- public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram);
-
- ///
- /// Get SpecificEnergy in MegajoulesPerKilogram.
- ///
- public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram);
-
- ///
- /// Get SpecificEnergy in MegawattHoursPerKilogram.
- ///
- public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram);
-
- ///
- /// Get SpecificEnergy in WattHoursPerKilogram.
- ///
- public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogram.
- ///
- public static SpecificEnergy Zero => new SpecificEnergy(0, BaseUnit);
-
- ///
- /// Get SpecificEnergy from CaloriesPerGram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromCaloriesPerGram(double caloriespergram)
-#else
- public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram)
-#endif
- {
- double value = (double) caloriespergram;
- return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram);
- }
-
- ///
- /// Get SpecificEnergy from JoulesPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromJoulesPerKilogram(double joulesperkilogram)
-#else
- public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogram)
-#endif
- {
- double value = (double) joulesperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram);
- }
-
- ///
- /// Get SpecificEnergy from KilocaloriesPerGram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromKilocaloriesPerGram(double kilocaloriespergram)
-#else
- public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriespergram)
-#endif
- {
- double value = (double) kilocaloriespergram;
- return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram);
- }
-
- ///
- /// Get SpecificEnergy from KilojoulesPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromKilojoulesPerKilogram(double kilojoulesperkilogram)
-#else
- public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesperkilogram)
-#endif
- {
- double value = (double) kilojoulesperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram);
- }
-
- ///
- /// Get SpecificEnergy from KilowattHoursPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromKilowattHoursPerKilogram(double kilowatthoursperkilogram)
-#else
- public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatthoursperkilogram)
-#endif
- {
- double value = (double) kilowatthoursperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram);
- }
-
- ///
- /// Get SpecificEnergy from MegajoulesPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromMegajoulesPerKilogram(double megajoulesperkilogram)
-#else
- public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesperkilogram)
-#endif
- {
- double value = (double) megajoulesperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram);
- }
-
- ///
- /// Get SpecificEnergy from MegawattHoursPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromMegawattHoursPerKilogram(double megawatthoursperkilogram)
-#else
- public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatthoursperkilogram)
-#endif
- {
- double value = (double) megawatthoursperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram);
- }
-
- ///
- /// Get SpecificEnergy from WattHoursPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEnergy FromWattHoursPerKilogram(double watthoursperkilogram)
-#else
- public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursperkilogram)
-#endif
- {
- double value = (double) watthoursperkilogram;
- return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// SpecificEnergy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static SpecificEnergy From(double value, SpecificEnergyUnit fromUnit)
-#else
- public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUnit)
-#endif
- {
- return new SpecificEnergy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SpecificEnergyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is SpecificEnergy)) throw new ArgumentException("Expected type SpecificEnergy.", nameof(obj));
-
- return CompareTo((SpecificEnergy)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(SpecificEnergy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(SpecificEnergy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is SpecificEnergy))
- return false;
-
- var objQuantity = (SpecificEnergy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another SpecificEnergy 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.
- [Obsolete("Please use the Equals(SpecificEnergy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(SpecificEnergy other, SpecificEnergy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current SpecificEnergy.
- public override int GetHashCode()
- {
- return new { type = typeof(SpecificEnergy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SpecificEnergyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation .
- ///
- /// A SpecificEnergy with the specified unit.
- public SpecificEnergy ToUnit(SpecificEnergyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new SpecificEnergy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SpecificEnergyUnit.CaloriePerGram: return _value*4.184e3;
- case SpecificEnergyUnit.JoulePerKilogram: return _value;
- case SpecificEnergyUnit.KilocaloriePerGram: return (_value*4.184e3) * 1e3d;
- case SpecificEnergyUnit.KilojoulePerKilogram: return (_value) * 1e3d;
- case SpecificEnergyUnit.KilowattHourPerKilogram: return (_value*3.6e3) * 1e3d;
- case SpecificEnergyUnit.MegajoulePerKilogram: return (_value) * 1e6d;
- case SpecificEnergyUnit.MegawattHourPerKilogram: return (_value*3.6e3) * 1e6d;
- case SpecificEnergyUnit.WattHourPerKilogram: return _value*3.6e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SpecificEnergyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SpecificEnergyUnit.CaloriePerGram: return baseUnitValue/4.184e3;
- case SpecificEnergyUnit.JoulePerKilogram: return baseUnitValue;
- case SpecificEnergyUnit.KilocaloriePerGram: return (baseUnitValue/4.184e3) / 1e3d;
- case SpecificEnergyUnit.KilojoulePerKilogram: return (baseUnitValue) / 1e3d;
- case SpecificEnergyUnit.KilowattHourPerKilogram: return (baseUnitValue/3.6e3) / 1e3d;
- case SpecificEnergyUnit.MegajoulePerKilogram: return (baseUnitValue) / 1e6d;
- case SpecificEnergyUnit.MegawattHourPerKilogram: return (baseUnitValue/3.6e3) / 1e6d;
- case SpecificEnergyUnit.WattHourPerKilogram: return baseUnitValue/3.6e3;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 SpecificEnergy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 SpecificEnergy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SpecificEnergyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerKilogram
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SpecificEnergyUnit ToStringDefaultUnit { get; set; } = SpecificEnergyUnit.JoulePerKilogram;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SpecificEnergyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of SpecificEnergy
- ///
- public static SpecificEnergy MaxValue => new SpecificEnergy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of SpecificEnergy
- ///
- public static SpecificEnergy MinValue => new SpecificEnergy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => SpecificEnergy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => SpecificEnergy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/SpecificEntropy.Common.g.cs b/Common/GeneratedCode/Quantities/SpecificEntropy.Common.g.cs
deleted file mode 100644
index 41e4e8afaa..0000000000
--- a/Common/GeneratedCode/Quantities/SpecificEntropy.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass.
- ///
- // 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 SpecificEntropy : IQuantity
-#else
- public partial struct SpecificEntropy : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SpecificEntropyUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static SpecificEntropy()
- {
- BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit JoulePerKilogramKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public SpecificEntropy(double joulesperkilogramkelvin)
- {
- _value = Convert.ToDouble(joulesperkilogramkelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- SpecificEntropy(double numericValue, SpecificEntropyUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKilogramKelvin.
- ///
- /// Value assuming base unit JoulePerKilogramKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificEntropy(long joulesperkilogramkelvin) : this(Convert.ToDouble(joulesperkilogramkelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit JoulePerKilogramKelvin.
- ///
- /// Value assuming base unit JoulePerKilogramKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificEntropy(decimal joulesperkilogramkelvin) : this(Convert.ToDouble(joulesperkilogramkelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.SpecificEntropy;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SpecificEntropyUnit BaseUnit => SpecificEntropyUnit.JoulePerKilogramKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the SpecificEntropy quantity.
- ///
- public static SpecificEntropyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().Except(new SpecificEntropyUnit[]{ SpecificEntropyUnit.Undefined }).ToArray();
-
- ///
- /// Get SpecificEntropy in CaloriesPerGramKelvin.
- ///
- public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin);
-
- ///
- /// Get SpecificEntropy in JoulesPerKilogramDegreeCelsius.
- ///
- public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius);
-
- ///
- /// Get SpecificEntropy in JoulesPerKilogramKelvin.
- ///
- public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin);
-
- ///
- /// Get SpecificEntropy in KilocaloriesPerGramKelvin.
- ///
- public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin);
-
- ///
- /// Get SpecificEntropy in KilojoulesPerKilogramDegreeCelsius.
- ///
- public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius);
-
- ///
- /// Get SpecificEntropy in KilojoulesPerKilogramKelvin.
- ///
- public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin);
-
- ///
- /// Get SpecificEntropy in MegajoulesPerKilogramDegreeCelsius.
- ///
- public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius);
-
- ///
- /// Get SpecificEntropy in MegajoulesPerKilogramKelvin.
- ///
- public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogramKelvin.
- ///
- public static SpecificEntropy Zero => new SpecificEntropy(0, BaseUnit);
-
- ///
- /// Get SpecificEntropy from CaloriesPerGramKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromCaloriesPerGramKelvin(double caloriespergramkelvin)
-#else
- public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespergramkelvin)
-#endif
- {
- double value = (double) caloriespergramkelvin;
- return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin);
- }
-
- ///
- /// Get SpecificEntropy from JoulesPerKilogramDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(double joulesperkilogramdegreecelsius)
-#else
- public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue joulesperkilogramdegreecelsius)
-#endif
- {
- double value = (double) joulesperkilogramdegreecelsius;
- return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius);
- }
-
- ///
- /// Get SpecificEntropy from JoulesPerKilogramKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromJoulesPerKilogramKelvin(double joulesperkilogramkelvin)
-#else
- public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulesperkilogramkelvin)
-#endif
- {
- double value = (double) joulesperkilogramkelvin;
- return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin);
- }
-
- ///
- /// Get SpecificEntropy from KilocaloriesPerGramKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromKilocaloriesPerGramKelvin(double kilocaloriespergramkelvin)
-#else
- public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kilocaloriespergramkelvin)
-#endif
- {
- double value = (double) kilocaloriespergramkelvin;
- return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin);
- }
-
- ///
- /// Get SpecificEntropy from KilojoulesPerKilogramDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(double kilojoulesperkilogramdegreecelsius)
-#else
- public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityValue kilojoulesperkilogramdegreecelsius)
-#endif
- {
- double value = (double) kilojoulesperkilogramdegreecelsius;
- return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius);
- }
-
- ///
- /// Get SpecificEntropy from KilojoulesPerKilogramKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromKilojoulesPerKilogramKelvin(double kilojoulesperkilogramkelvin)
-#else
- public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilojoulesperkilogramkelvin)
-#endif
- {
- double value = (double) kilojoulesperkilogramkelvin;
- return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin);
- }
-
- ///
- /// Get SpecificEntropy from MegajoulesPerKilogramDegreeCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(double megajoulesperkilogramdegreecelsius)
-#else
- public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityValue megajoulesperkilogramdegreecelsius)
-#endif
- {
- double value = (double) megajoulesperkilogramdegreecelsius;
- return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius);
- }
-
- ///
- /// Get SpecificEntropy from MegajoulesPerKilogramKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificEntropy FromMegajoulesPerKilogramKelvin(double megajoulesperkilogramkelvin)
-#else
- public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue megajoulesperkilogramkelvin)
-#endif
- {
- double value = (double) megajoulesperkilogramkelvin;
- return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// SpecificEntropy unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static SpecificEntropy From(double value, SpecificEntropyUnit fromUnit)
-#else
- public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit fromUnit)
-#endif
- {
- return new SpecificEntropy((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SpecificEntropyUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is SpecificEntropy)) throw new ArgumentException("Expected type SpecificEntropy.", nameof(obj));
-
- return CompareTo((SpecificEntropy)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(SpecificEntropy other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(SpecificEntropy, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is SpecificEntropy))
- return false;
-
- var objQuantity = (SpecificEntropy)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another SpecificEntropy 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.
- [Obsolete("Please use the Equals(SpecificEntropy, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(SpecificEntropy other, SpecificEntropy maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current SpecificEntropy.
- public override int GetHashCode()
- {
- return new { type = typeof(SpecificEntropy), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SpecificEntropyUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation .
- ///
- /// A SpecificEntropy with the specified unit.
- public SpecificEntropy ToUnit(SpecificEntropyUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new SpecificEntropy(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SpecificEntropyUnit.CaloriePerGramKelvin: return _value*4.184e3;
- case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return _value;
- case SpecificEntropyUnit.JoulePerKilogramKelvin: return _value;
- case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (_value*4.184e3) * 1e3d;
- case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (_value) * 1e3d;
- case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (_value) * 1e3d;
- case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (_value) * 1e6d;
- case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (_value) * 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SpecificEntropyUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SpecificEntropyUnit.CaloriePerGramKelvin: return baseUnitValue/4.184e3;
- case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return baseUnitValue;
- case SpecificEntropyUnit.JoulePerKilogramKelvin: return baseUnitValue;
- case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (baseUnitValue/4.184e3) / 1e3d;
- case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (baseUnitValue) / 1e3d;
- case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (baseUnitValue) / 1e3d;
- case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (baseUnitValue) / 1e6d;
- case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (baseUnitValue) / 1e6d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 SpecificEntropy Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 SpecificEntropy result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SpecificEntropyUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is JoulePerKilogramKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SpecificEntropyUnit ToStringDefaultUnit { get; set; } = SpecificEntropyUnit.JoulePerKilogramKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SpecificEntropyUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of SpecificEntropy
- ///
- public static SpecificEntropy MaxValue => new SpecificEntropy(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of SpecificEntropy
- ///
- public static SpecificEntropy MinValue => new SpecificEntropy(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => SpecificEntropy.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => SpecificEntropy.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/SpecificVolume.Common.g.cs b/Common/GeneratedCode/Quantities/SpecificVolume.Common.g.cs
deleted file mode 100644
index a7563f4c9e..0000000000
--- a/Common/GeneratedCode/Quantities/SpecificVolume.Common.g.cs
+++ /dev/null
@@ -1,511 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well.
- ///
- // 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 SpecificVolume : IQuantity
-#else
- public partial struct SpecificVolume : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SpecificVolumeUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static SpecificVolume()
- {
- BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit CubicMeterPerKilogram.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public SpecificVolume(double cubicmetersperkilogram)
- {
- _value = Convert.ToDouble(cubicmetersperkilogram);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- SpecificVolume(double numericValue, SpecificVolumeUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerKilogram.
- ///
- /// Value assuming base unit CubicMeterPerKilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificVolume(long cubicmetersperkilogram) : this(Convert.ToDouble(cubicmetersperkilogram), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerKilogram.
- ///
- /// Value assuming base unit CubicMeterPerKilogram.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificVolume(decimal cubicmetersperkilogram) : this(Convert.ToDouble(cubicmetersperkilogram), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.SpecificVolume;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SpecificVolumeUnit BaseUnit => SpecificVolumeUnit.CubicMeterPerKilogram;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the SpecificVolume quantity.
- ///
- public static SpecificVolumeUnit[] Units { get; } = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().Except(new SpecificVolumeUnit[]{ SpecificVolumeUnit.Undefined }).ToArray();
-
- ///
- /// Get SpecificVolume in CubicFeetPerPound.
- ///
- public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound);
-
- ///
- /// Get SpecificVolume in CubicMetersPerKilogram.
- ///
- public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerKilogram.
- ///
- public static SpecificVolume Zero => new SpecificVolume(0, BaseUnit);
-
- ///
- /// Get SpecificVolume from CubicFeetPerPound.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificVolume FromCubicFeetPerPound(double cubicfeetperpound)
-#else
- public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpound)
-#endif
- {
- double value = (double) cubicfeetperpound;
- return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound);
- }
-
- ///
- /// Get SpecificVolume from CubicMetersPerKilogram.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificVolume FromCubicMetersPerKilogram(double cubicmetersperkilogram)
-#else
- public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmetersperkilogram)
-#endif
- {
- double value = (double) cubicmetersperkilogram;
- return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// SpecificVolume unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static SpecificVolume From(double value, SpecificVolumeUnit fromUnit)
-#else
- public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUnit)
-#endif
- {
- return new SpecificVolume((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SpecificVolumeUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is SpecificVolume)) throw new ArgumentException("Expected type SpecificVolume.", nameof(obj));
-
- return CompareTo((SpecificVolume)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(SpecificVolume other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(SpecificVolume, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is SpecificVolume))
- return false;
-
- var objQuantity = (SpecificVolume)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another SpecificVolume within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another SpecificVolume 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.
- [Obsolete("Please use the Equals(SpecificVolume, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(SpecificVolume other, SpecificVolume maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current SpecificVolume.
- public override int GetHashCode()
- {
- return new { type = typeof(SpecificVolume), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SpecificVolumeUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this SpecificVolume to another SpecificVolume with the unit representation .
- ///
- /// A SpecificVolume with the specified unit.
- public SpecificVolume ToUnit(SpecificVolumeUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new SpecificVolume(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SpecificVolumeUnit.CubicFootPerPound: return _value/16.01846353;
- case SpecificVolumeUnit.CubicMeterPerKilogram: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SpecificVolumeUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SpecificVolumeUnit.CubicFootPerPound: return baseUnitValue*16.01846353;
- case SpecificVolumeUnit.CubicMeterPerKilogram: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 SpecificVolume Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 SpecificVolume result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SpecificVolumeUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is CubicMeterPerKilogram
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SpecificVolumeUnit ToStringDefaultUnit { get; set; } = SpecificVolumeUnit.CubicMeterPerKilogram;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SpecificVolumeUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of SpecificVolume
- ///
- public static SpecificVolume MaxValue => new SpecificVolume(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of SpecificVolume
- ///
- public static SpecificVolume MinValue => new SpecificVolume(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => SpecificVolume.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => SpecificVolume.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/SpecificWeight.Common.g.cs b/Common/GeneratedCode/Quantities/SpecificWeight.Common.g.cs
deleted file mode 100644
index 6333256431..0000000000
--- a/Common/GeneratedCode/Quantities/SpecificWeight.Common.g.cs
+++ /dev/null
@@ -1,826 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume.
- ///
- // 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 SpecificWeight : IQuantity
-#else
- public partial struct SpecificWeight : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SpecificWeightUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SpecificWeightUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static SpecificWeight()
- {
- BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonPerCubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public SpecificWeight(double newtonspercubicmeter)
- {
- _value = Convert.ToDouble(newtonspercubicmeter);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- SpecificWeight(double numericValue, SpecificWeightUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerCubicMeter.
- ///
- /// Value assuming base unit NewtonPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificWeight(long newtonspercubicmeter) : this(Convert.ToDouble(newtonspercubicmeter), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonPerCubicMeter.
- ///
- /// Value assuming base unit NewtonPerCubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- SpecificWeight(decimal newtonspercubicmeter) : this(Convert.ToDouble(newtonspercubicmeter), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.SpecificWeight;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SpecificWeightUnit BaseUnit => SpecificWeightUnit.NewtonPerCubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the SpecificWeight quantity.
- ///
- public static SpecificWeightUnit[] Units { get; } = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().Except(new SpecificWeightUnit[]{ SpecificWeightUnit.Undefined }).ToArray();
-
- ///
- /// Get SpecificWeight in KilogramsForcePerCubicCentimeter.
- ///
- public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter);
-
- ///
- /// Get SpecificWeight in KilogramsForcePerCubicMeter.
- ///
- public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter);
-
- ///
- /// Get SpecificWeight in KilogramsForcePerCubicMillimeter.
- ///
- public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter);
-
- ///
- /// Get SpecificWeight in KilonewtonsPerCubicCentimeter.
- ///
- public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter);
-
- ///
- /// Get SpecificWeight in KilonewtonsPerCubicMeter.
- ///
- public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter);
-
- ///
- /// Get SpecificWeight in KilonewtonsPerCubicMillimeter.
- ///
- public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter);
-
- ///
- /// Get SpecificWeight in KilopoundsForcePerCubicFoot.
- ///
- public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot);
-
- ///
- /// Get SpecificWeight in KilopoundsForcePerCubicInch.
- ///
- public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch);
-
- ///
- /// Get SpecificWeight in MeganewtonsPerCubicMeter.
- ///
- public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter);
-
- ///
- /// Get SpecificWeight in NewtonsPerCubicCentimeter.
- ///
- public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter);
-
- ///
- /// Get SpecificWeight in NewtonsPerCubicMeter.
- ///
- public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter);
-
- ///
- /// Get SpecificWeight in NewtonsPerCubicMillimeter.
- ///
- public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter);
-
- ///
- /// Get SpecificWeight in PoundsForcePerCubicFoot.
- ///
- public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot);
-
- ///
- /// Get SpecificWeight in PoundsForcePerCubicInch.
- ///
- public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch);
-
- ///
- /// Get SpecificWeight in TonnesForcePerCubicCentimeter.
- ///
- public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter);
-
- ///
- /// Get SpecificWeight in TonnesForcePerCubicMeter.
- ///
- public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter);
-
- ///
- /// Get SpecificWeight in TonnesForcePerCubicMillimeter.
- ///
- public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerCubicMeter.
- ///
- public static SpecificWeight Zero => new SpecificWeight(0, BaseUnit);
-
- ///
- /// Get SpecificWeight from KilogramsForcePerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilogramsForcePerCubicCentimeter(double kilogramsforcepercubiccentimeter)
-#else
- public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue kilogramsforcepercubiccentimeter)
-#endif
- {
- double value = (double) kilogramsforcepercubiccentimeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter);
- }
-
- ///
- /// Get SpecificWeight from KilogramsForcePerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilogramsForcePerCubicMeter(double kilogramsforcepercubicmeter)
-#else
- public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilogramsforcepercubicmeter)
-#endif
- {
- double value = (double) kilogramsforcepercubicmeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter);
- }
-
- ///
- /// Get SpecificWeight from KilogramsForcePerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilogramsForcePerCubicMillimeter(double kilogramsforcepercubicmillimeter)
-#else
- public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue kilogramsforcepercubicmillimeter)
-#endif
- {
- double value = (double) kilogramsforcepercubicmillimeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter);
- }
-
- ///
- /// Get SpecificWeight from KilonewtonsPerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilonewtonsPerCubicCentimeter(double kilonewtonspercubiccentimeter)
-#else
- public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kilonewtonspercubiccentimeter)
-#endif
- {
- double value = (double) kilonewtonspercubiccentimeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter);
- }
-
- ///
- /// Get SpecificWeight from KilonewtonsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilonewtonsPerCubicMeter(double kilonewtonspercubicmeter)
-#else
- public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewtonspercubicmeter)
-#endif
- {
- double value = (double) kilonewtonspercubicmeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter);
- }
-
- ///
- /// Get SpecificWeight from KilonewtonsPerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilonewtonsPerCubicMillimeter(double kilonewtonspercubicmillimeter)
-#else
- public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kilonewtonspercubicmillimeter)
-#endif
- {
- double value = (double) kilonewtonspercubicmillimeter;
- return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter);
- }
-
- ///
- /// Get SpecificWeight from KilopoundsForcePerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilopoundsForcePerCubicFoot(double kilopoundsforcepercubicfoot)
-#else
- public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilopoundsforcepercubicfoot)
-#endif
- {
- double value = (double) kilopoundsforcepercubicfoot;
- return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot);
- }
-
- ///
- /// Get SpecificWeight from KilopoundsForcePerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromKilopoundsForcePerCubicInch(double kilopoundsforcepercubicinch)
-#else
- public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilopoundsforcepercubicinch)
-#endif
- {
- double value = (double) kilopoundsforcepercubicinch;
- return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch);
- }
-
- ///
- /// Get SpecificWeight from MeganewtonsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromMeganewtonsPerCubicMeter(double meganewtonspercubicmeter)
-#else
- public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewtonspercubicmeter)
-#endif
- {
- double value = (double) meganewtonspercubicmeter;
- return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter);
- }
-
- ///
- /// Get SpecificWeight from NewtonsPerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromNewtonsPerCubicCentimeter(double newtonspercubiccentimeter)
-#else
- public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtonspercubiccentimeter)
-#endif
- {
- double value = (double) newtonspercubiccentimeter;
- return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter);
- }
-
- ///
- /// Get SpecificWeight from NewtonsPerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromNewtonsPerCubicMeter(double newtonspercubicmeter)
-#else
- public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercubicmeter)
-#endif
- {
- double value = (double) newtonspercubicmeter;
- return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter);
- }
-
- ///
- /// Get SpecificWeight from NewtonsPerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromNewtonsPerCubicMillimeter(double newtonspercubicmillimeter)
-#else
- public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtonspercubicmillimeter)
-#endif
- {
- double value = (double) newtonspercubicmillimeter;
- return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter);
- }
-
- ///
- /// Get SpecificWeight from PoundsForcePerCubicFoot.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromPoundsForcePerCubicFoot(double poundsforcepercubicfoot)
-#else
- public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsforcepercubicfoot)
-#endif
- {
- double value = (double) poundsforcepercubicfoot;
- return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot);
- }
-
- ///
- /// Get SpecificWeight from PoundsForcePerCubicInch.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromPoundsForcePerCubicInch(double poundsforcepercubicinch)
-#else
- public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsforcepercubicinch)
-#endif
- {
- double value = (double) poundsforcepercubicinch;
- return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch);
- }
-
- ///
- /// Get SpecificWeight from TonnesForcePerCubicCentimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromTonnesForcePerCubicCentimeter(double tonnesforcepercubiccentimeter)
-#else
- public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue tonnesforcepercubiccentimeter)
-#endif
- {
- double value = (double) tonnesforcepercubiccentimeter;
- return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter);
- }
-
- ///
- /// Get SpecificWeight from TonnesForcePerCubicMeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromTonnesForcePerCubicMeter(double tonnesforcepercubicmeter)
-#else
- public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesforcepercubicmeter)
-#endif
- {
- double value = (double) tonnesforcepercubicmeter;
- return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter);
- }
-
- ///
- /// Get SpecificWeight from TonnesForcePerCubicMillimeter.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static SpecificWeight FromTonnesForcePerCubicMillimeter(double tonnesforcepercubicmillimeter)
-#else
- public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue tonnesforcepercubicmillimeter)
-#endif
- {
- double value = (double) tonnesforcepercubicmillimeter;
- return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// SpecificWeight unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static SpecificWeight From(double value, SpecificWeightUnit fromUnit)
-#else
- public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUnit)
-#endif
- {
- return new SpecificWeight((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SpecificWeightUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is SpecificWeight)) throw new ArgumentException("Expected type SpecificWeight.", nameof(obj));
-
- return CompareTo((SpecificWeight)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(SpecificWeight other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(SpecificWeight, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is SpecificWeight))
- return false;
-
- var objQuantity = (SpecificWeight)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another SpecificWeight within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another SpecificWeight 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.
- [Obsolete("Please use the Equals(SpecificWeight, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(SpecificWeight other, SpecificWeight maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current SpecificWeight.
- public override int GetHashCode()
- {
- return new { type = typeof(SpecificWeight), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SpecificWeightUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this SpecificWeight to another SpecificWeight with the unit representation .
- ///
- /// A SpecificWeight with the specified unit.
- public SpecificWeight ToUnit(SpecificWeightUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new SpecificWeight(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return _value*9.80665e6;
- case SpecificWeightUnit.KilogramForcePerCubicMeter: return _value*9.80665;
- case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return _value*9.80665e9;
- case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (_value*1000000) * 1e3d;
- case SpecificWeightUnit.KilonewtonPerCubicMeter: return (_value) * 1e3d;
- case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (_value*1000000000) * 1e3d;
- case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (_value*1.570874638462462e2) * 1e3d;
- case SpecificWeightUnit.KilopoundForcePerCubicInch: return (_value*2.714471375263134e5) * 1e3d;
- case SpecificWeightUnit.MeganewtonPerCubicMeter: return (_value) * 1e6d;
- case SpecificWeightUnit.NewtonPerCubicCentimeter: return _value*1000000;
- case SpecificWeightUnit.NewtonPerCubicMeter: return _value;
- case SpecificWeightUnit.NewtonPerCubicMillimeter: return _value*1000000000;
- case SpecificWeightUnit.PoundForcePerCubicFoot: return _value*1.570874638462462e2;
- case SpecificWeightUnit.PoundForcePerCubicInch: return _value*2.714471375263134e5;
- case SpecificWeightUnit.TonneForcePerCubicCentimeter: return _value*9.80665e9;
- case SpecificWeightUnit.TonneForcePerCubicMeter: return _value*9.80665e3;
- case SpecificWeightUnit.TonneForcePerCubicMillimeter: return _value*9.80665e12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SpecificWeightUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return baseUnitValue/9.80665e6;
- case SpecificWeightUnit.KilogramForcePerCubicMeter: return baseUnitValue/9.80665;
- case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return baseUnitValue/9.80665e9;
- case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (baseUnitValue*0.000001) / 1e3d;
- case SpecificWeightUnit.KilonewtonPerCubicMeter: return (baseUnitValue) / 1e3d;
- case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (baseUnitValue*0.000000001) / 1e3d;
- case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (baseUnitValue/1.570874638462462e2) / 1e3d;
- case SpecificWeightUnit.KilopoundForcePerCubicInch: return (baseUnitValue/2.714471375263134e5) / 1e3d;
- case SpecificWeightUnit.MeganewtonPerCubicMeter: return (baseUnitValue) / 1e6d;
- case SpecificWeightUnit.NewtonPerCubicCentimeter: return baseUnitValue*0.000001;
- case SpecificWeightUnit.NewtonPerCubicMeter: return baseUnitValue;
- case SpecificWeightUnit.NewtonPerCubicMillimeter: return baseUnitValue*0.000000001;
- case SpecificWeightUnit.PoundForcePerCubicFoot: return baseUnitValue/1.570874638462462e2;
- case SpecificWeightUnit.PoundForcePerCubicInch: return baseUnitValue/2.714471375263134e5;
- case SpecificWeightUnit.TonneForcePerCubicCentimeter: return baseUnitValue/9.80665e9;
- case SpecificWeightUnit.TonneForcePerCubicMeter: return baseUnitValue/9.80665e3;
- case SpecificWeightUnit.TonneForcePerCubicMillimeter: return baseUnitValue/9.80665e12;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 SpecificWeight Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 SpecificWeight result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SpecificWeightUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonPerCubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SpecificWeightUnit ToStringDefaultUnit { get; set; } = SpecificWeightUnit.NewtonPerCubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SpecificWeightUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of SpecificWeight
- ///
- public static SpecificWeight MaxValue => new SpecificWeight(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of SpecificWeight
- ///
- public static SpecificWeight MinValue => new SpecificWeight(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => SpecificWeight.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => SpecificWeight.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Speed.Common.g.cs b/Common/GeneratedCode/Quantities/Speed.Common.g.cs
deleted file mode 100644
index 2b82cec471..0000000000
--- a/Common/GeneratedCode/Quantities/Speed.Common.g.cs
+++ /dev/null
@@ -1,1141 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero.
- ///
- // 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 Speed : IQuantity
-#else
- public partial struct Speed : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly SpeedUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public SpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Speed()
- {
- BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit MeterPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Speed(double meterspersecond)
- {
- _value = Convert.ToDouble(meterspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Speed(double numericValue, SpeedUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterPerSecond.
- ///
- /// Value assuming base unit MeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Speed(long meterspersecond) : this(Convert.ToDouble(meterspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit MeterPerSecond.
- ///
- /// Value assuming base unit MeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Speed(decimal meterspersecond) : this(Convert.ToDouble(meterspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Speed;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static SpeedUnit BaseUnit => SpeedUnit.MeterPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Speed quantity.
- ///
- public static SpeedUnit[] Units { get; } = Enum.GetValues(typeof(SpeedUnit)).Cast().Except(new SpeedUnit[]{ SpeedUnit.Undefined }).ToArray();
-
- ///
- /// Get Speed in CentimetersPerHour.
- ///
- public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour);
-
- ///
- /// Get Speed in CentimetersPerMinutes.
- ///
- public double CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute);
-
- ///
- /// Get Speed in CentimetersPerSecond.
- ///
- public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond);
-
- ///
- /// Get Speed in DecimetersPerMinutes.
- ///
- public double DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute);
-
- ///
- /// Get Speed in DecimetersPerSecond.
- ///
- public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond);
-
- ///
- /// Get Speed in FeetPerHour.
- ///
- public double FeetPerHour => As(SpeedUnit.FootPerHour);
-
- ///
- /// Get Speed in FeetPerMinute.
- ///
- public double FeetPerMinute => As(SpeedUnit.FootPerMinute);
-
- ///
- /// Get Speed in FeetPerSecond.
- ///
- public double FeetPerSecond => As(SpeedUnit.FootPerSecond);
-
- ///
- /// Get Speed in InchesPerHour.
- ///
- public double InchesPerHour => As(SpeedUnit.InchPerHour);
-
- ///
- /// Get Speed in InchesPerMinute.
- ///
- public double InchesPerMinute => As(SpeedUnit.InchPerMinute);
-
- ///
- /// Get Speed in InchesPerSecond.
- ///
- public double InchesPerSecond => As(SpeedUnit.InchPerSecond);
-
- ///
- /// Get Speed in KilometersPerHour.
- ///
- public double KilometersPerHour => As(SpeedUnit.KilometerPerHour);
-
- ///
- /// Get Speed in KilometersPerMinutes.
- ///
- public double KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute);
-
- ///
- /// Get Speed in KilometersPerSecond.
- ///
- public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond);
-
- ///
- /// Get Speed in Knots.
- ///
- public double Knots => As(SpeedUnit.Knot);
-
- ///
- /// Get Speed in MetersPerHour.
- ///
- public double MetersPerHour => As(SpeedUnit.MeterPerHour);
-
- ///
- /// Get Speed in MetersPerMinutes.
- ///
- public double MetersPerMinutes => As(SpeedUnit.MeterPerMinute);
-
- ///
- /// Get Speed in MetersPerSecond.
- ///
- public double MetersPerSecond => As(SpeedUnit.MeterPerSecond);
-
- ///
- /// Get Speed in MicrometersPerMinutes.
- ///
- public double MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute);
-
- ///
- /// Get Speed in MicrometersPerSecond.
- ///
- public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond);
-
- ///
- /// Get Speed in MilesPerHour.
- ///
- public double MilesPerHour => As(SpeedUnit.MilePerHour);
-
- ///
- /// Get Speed in MillimetersPerHour.
- ///
- public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour);
-
- ///
- /// Get Speed in MillimetersPerMinutes.
- ///
- public double MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute);
-
- ///
- /// Get Speed in MillimetersPerSecond.
- ///
- public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond);
-
- ///
- /// Get Speed in NanometersPerMinutes.
- ///
- public double NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute);
-
- ///
- /// Get Speed in NanometersPerSecond.
- ///
- public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond);
-
- ///
- /// Get Speed in UsSurveyFeetPerHour.
- ///
- public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour);
-
- ///
- /// Get Speed in UsSurveyFeetPerMinute.
- ///
- public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute);
-
- ///
- /// Get Speed in UsSurveyFeetPerSecond.
- ///
- public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond);
-
- ///
- /// Get Speed in YardsPerHour.
- ///
- public double YardsPerHour => As(SpeedUnit.YardPerHour);
-
- ///
- /// Get Speed in YardsPerMinute.
- ///
- public double YardsPerMinute => As(SpeedUnit.YardPerMinute);
-
- ///
- /// Get Speed in YardsPerSecond.
- ///
- public double YardsPerSecond => As(SpeedUnit.YardPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecond.
- ///
- public static Speed Zero => new Speed(0, BaseUnit);
-
- ///
- /// Get Speed from CentimetersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromCentimetersPerHour(double centimetersperhour)
-#else
- public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour)
-#endif
- {
- double value = (double) centimetersperhour;
- return new Speed(value, SpeedUnit.CentimeterPerHour);
- }
-
- ///
- /// Get Speed from CentimetersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromCentimetersPerMinutes(double centimetersperminutes)
-#else
- public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminutes)
-#endif
- {
- double value = (double) centimetersperminutes;
- return new Speed(value, SpeedUnit.CentimeterPerMinute);
- }
-
- ///
- /// Get Speed from CentimetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromCentimetersPerSecond(double centimeterspersecond)
-#else
- public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond)
-#endif
- {
- double value = (double) centimeterspersecond;
- return new Speed(value, SpeedUnit.CentimeterPerSecond);
- }
-
- ///
- /// Get Speed from DecimetersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromDecimetersPerMinutes(double decimetersperminutes)
-#else
- public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes)
-#endif
- {
- double value = (double) decimetersperminutes;
- return new Speed(value, SpeedUnit.DecimeterPerMinute);
- }
-
- ///
- /// Get Speed from DecimetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromDecimetersPerSecond(double decimeterspersecond)
-#else
- public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond)
-#endif
- {
- double value = (double) decimeterspersecond;
- return new Speed(value, SpeedUnit.DecimeterPerSecond);
- }
-
- ///
- /// Get Speed from FeetPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromFeetPerHour(double feetperhour)
-#else
- public static Speed FromFeetPerHour(QuantityValue feetperhour)
-#endif
- {
- double value = (double) feetperhour;
- return new Speed(value, SpeedUnit.FootPerHour);
- }
-
- ///
- /// Get Speed from FeetPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromFeetPerMinute(double feetperminute)
-#else
- public static Speed FromFeetPerMinute(QuantityValue feetperminute)
-#endif
- {
- double value = (double) feetperminute;
- return new Speed(value, SpeedUnit.FootPerMinute);
- }
-
- ///
- /// Get Speed from FeetPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromFeetPerSecond(double feetpersecond)
-#else
- public static Speed FromFeetPerSecond(QuantityValue feetpersecond)
-#endif
- {
- double value = (double) feetpersecond;
- return new Speed(value, SpeedUnit.FootPerSecond);
- }
-
- ///
- /// Get Speed from InchesPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromInchesPerHour(double inchesperhour)
-#else
- public static Speed FromInchesPerHour(QuantityValue inchesperhour)
-#endif
- {
- double value = (double) inchesperhour;
- return new Speed(value, SpeedUnit.InchPerHour);
- }
-
- ///
- /// Get Speed from InchesPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromInchesPerMinute(double inchesperminute)
-#else
- public static Speed FromInchesPerMinute(QuantityValue inchesperminute)
-#endif
- {
- double value = (double) inchesperminute;
- return new Speed(value, SpeedUnit.InchPerMinute);
- }
-
- ///
- /// Get Speed from InchesPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromInchesPerSecond(double inchespersecond)
-#else
- public static Speed FromInchesPerSecond(QuantityValue inchespersecond)
-#endif
- {
- double value = (double) inchespersecond;
- return new Speed(value, SpeedUnit.InchPerSecond);
- }
-
- ///
- /// Get Speed from KilometersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromKilometersPerHour(double kilometersperhour)
-#else
- public static Speed FromKilometersPerHour(QuantityValue kilometersperhour)
-#endif
- {
- double value = (double) kilometersperhour;
- return new Speed(value, SpeedUnit.KilometerPerHour);
- }
-
- ///
- /// Get Speed from KilometersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromKilometersPerMinutes(double kilometersperminutes)
-#else
- public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes)
-#endif
- {
- double value = (double) kilometersperminutes;
- return new Speed(value, SpeedUnit.KilometerPerMinute);
- }
-
- ///
- /// Get Speed from KilometersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromKilometersPerSecond(double kilometerspersecond)
-#else
- public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond)
-#endif
- {
- double value = (double) kilometerspersecond;
- return new Speed(value, SpeedUnit.KilometerPerSecond);
- }
-
- ///
- /// Get Speed from Knots.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromKnots(double knots)
-#else
- public static Speed FromKnots(QuantityValue knots)
-#endif
- {
- double value = (double) knots;
- return new Speed(value, SpeedUnit.Knot);
- }
-
- ///
- /// Get Speed from MetersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMetersPerHour(double metersperhour)
-#else
- public static Speed FromMetersPerHour(QuantityValue metersperhour)
-#endif
- {
- double value = (double) metersperhour;
- return new Speed(value, SpeedUnit.MeterPerHour);
- }
-
- ///
- /// Get Speed from MetersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMetersPerMinutes(double metersperminutes)
-#else
- public static Speed FromMetersPerMinutes(QuantityValue metersperminutes)
-#endif
- {
- double value = (double) metersperminutes;
- return new Speed(value, SpeedUnit.MeterPerMinute);
- }
-
- ///
- /// Get Speed from MetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMetersPerSecond(double meterspersecond)
-#else
- public static Speed FromMetersPerSecond(QuantityValue meterspersecond)
-#endif
- {
- double value = (double) meterspersecond;
- return new Speed(value, SpeedUnit.MeterPerSecond);
- }
-
- ///
- /// Get Speed from MicrometersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMicrometersPerMinutes(double micrometersperminutes)
-#else
- public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminutes)
-#endif
- {
- double value = (double) micrometersperminutes;
- return new Speed(value, SpeedUnit.MicrometerPerMinute);
- }
-
- ///
- /// Get Speed from MicrometersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMicrometersPerSecond(double micrometerspersecond)
-#else
- public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond)
-#endif
- {
- double value = (double) micrometerspersecond;
- return new Speed(value, SpeedUnit.MicrometerPerSecond);
- }
-
- ///
- /// Get Speed from MilesPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMilesPerHour(double milesperhour)
-#else
- public static Speed FromMilesPerHour(QuantityValue milesperhour)
-#endif
- {
- double value = (double) milesperhour;
- return new Speed(value, SpeedUnit.MilePerHour);
- }
-
- ///
- /// Get Speed from MillimetersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMillimetersPerHour(double millimetersperhour)
-#else
- public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour)
-#endif
- {
- double value = (double) millimetersperhour;
- return new Speed(value, SpeedUnit.MillimeterPerHour);
- }
-
- ///
- /// Get Speed from MillimetersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMillimetersPerMinutes(double millimetersperminutes)
-#else
- public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminutes)
-#endif
- {
- double value = (double) millimetersperminutes;
- return new Speed(value, SpeedUnit.MillimeterPerMinute);
- }
-
- ///
- /// Get Speed from MillimetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromMillimetersPerSecond(double millimeterspersecond)
-#else
- public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond)
-#endif
- {
- double value = (double) millimeterspersecond;
- return new Speed(value, SpeedUnit.MillimeterPerSecond);
- }
-
- ///
- /// Get Speed from NanometersPerMinutes.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromNanometersPerMinutes(double nanometersperminutes)
-#else
- public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes)
-#endif
- {
- double value = (double) nanometersperminutes;
- return new Speed(value, SpeedUnit.NanometerPerMinute);
- }
-
- ///
- /// Get Speed from NanometersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromNanometersPerSecond(double nanometerspersecond)
-#else
- public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond)
-#endif
- {
- double value = (double) nanometerspersecond;
- return new Speed(value, SpeedUnit.NanometerPerSecond);
- }
-
- ///
- /// Get Speed from UsSurveyFeetPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromUsSurveyFeetPerHour(double ussurveyfeetperhour)
-#else
- public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour)
-#endif
- {
- double value = (double) ussurveyfeetperhour;
- return new Speed(value, SpeedUnit.UsSurveyFootPerHour);
- }
-
- ///
- /// Get Speed from UsSurveyFeetPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromUsSurveyFeetPerMinute(double ussurveyfeetperminute)
-#else
- public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminute)
-#endif
- {
- double value = (double) ussurveyfeetperminute;
- return new Speed(value, SpeedUnit.UsSurveyFootPerMinute);
- }
-
- ///
- /// Get Speed from UsSurveyFeetPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromUsSurveyFeetPerSecond(double ussurveyfeetpersecond)
-#else
- public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecond)
-#endif
- {
- double value = (double) ussurveyfeetpersecond;
- return new Speed(value, SpeedUnit.UsSurveyFootPerSecond);
- }
-
- ///
- /// Get Speed from YardsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromYardsPerHour(double yardsperhour)
-#else
- public static Speed FromYardsPerHour(QuantityValue yardsperhour)
-#endif
- {
- double value = (double) yardsperhour;
- return new Speed(value, SpeedUnit.YardPerHour);
- }
-
- ///
- /// Get Speed from YardsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromYardsPerMinute(double yardsperminute)
-#else
- public static Speed FromYardsPerMinute(QuantityValue yardsperminute)
-#endif
- {
- double value = (double) yardsperminute;
- return new Speed(value, SpeedUnit.YardPerMinute);
- }
-
- ///
- /// Get Speed from YardsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Speed FromYardsPerSecond(double yardspersecond)
-#else
- public static Speed FromYardsPerSecond(QuantityValue yardspersecond)
-#endif
- {
- double value = (double) yardspersecond;
- return new Speed(value, SpeedUnit.YardPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Speed unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Speed From(double value, SpeedUnit fromUnit)
-#else
- public static Speed From(QuantityValue value, SpeedUnit fromUnit)
-#endif
- {
- return new Speed((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(SpeedUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Speed)) throw new ArgumentException("Expected type Speed.", nameof(obj));
-
- return CompareTo((Speed)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(Speed other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Speed, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Speed))
- return false;
-
- var objQuantity = (Speed)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Speed within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Speed other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Speed 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.
- [Obsolete("Please use the Equals(Speed, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Speed other, Speed maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Speed.
- public override int GetHashCode()
- {
- return new { type = typeof(Speed), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(SpeedUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Speed to another Speed with the unit representation .
- ///
- /// A Speed with the specified unit.
- public Speed ToUnit(SpeedUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Speed(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case SpeedUnit.CentimeterPerHour: return (_value/3600) * 1e-2d;
- case SpeedUnit.CentimeterPerMinute: return (_value/60) * 1e-2d;
- case SpeedUnit.CentimeterPerSecond: return (_value) * 1e-2d;
- case SpeedUnit.DecimeterPerMinute: return (_value/60) * 1e-1d;
- case SpeedUnit.DecimeterPerSecond: return (_value) * 1e-1d;
- case SpeedUnit.FootPerHour: return _value*0.3048/3600;
- case SpeedUnit.FootPerMinute: return _value*0.3048/60;
- case SpeedUnit.FootPerSecond: return _value*0.3048;
- case SpeedUnit.InchPerHour: return (_value/3600)*2.54e-2;
- case SpeedUnit.InchPerMinute: return (_value/60)*2.54e-2;
- case SpeedUnit.InchPerSecond: return _value*2.54e-2;
- case SpeedUnit.KilometerPerHour: return (_value/3600) * 1e3d;
- case SpeedUnit.KilometerPerMinute: return (_value/60) * 1e3d;
- case SpeedUnit.KilometerPerSecond: return (_value) * 1e3d;
- case SpeedUnit.Knot: return _value*0.514444;
- case SpeedUnit.MeterPerHour: return _value/3600;
- case SpeedUnit.MeterPerMinute: return _value/60;
- case SpeedUnit.MeterPerSecond: return _value;
- case SpeedUnit.MicrometerPerMinute: return (_value/60) * 1e-6d;
- case SpeedUnit.MicrometerPerSecond: return (_value) * 1e-6d;
- case SpeedUnit.MilePerHour: return _value*0.44704;
- case SpeedUnit.MillimeterPerHour: return (_value/3600) * 1e-3d;
- case SpeedUnit.MillimeterPerMinute: return (_value/60) * 1e-3d;
- case SpeedUnit.MillimeterPerSecond: return (_value) * 1e-3d;
- case SpeedUnit.NanometerPerMinute: return (_value/60) * 1e-9d;
- case SpeedUnit.NanometerPerSecond: return (_value) * 1e-9d;
- case SpeedUnit.UsSurveyFootPerHour: return (_value*1200/3937)/3600;
- case SpeedUnit.UsSurveyFootPerMinute: return (_value*1200/3937)/60;
- case SpeedUnit.UsSurveyFootPerSecond: return _value*1200/3937;
- case SpeedUnit.YardPerHour: return _value*0.9144/3600;
- case SpeedUnit.YardPerMinute: return _value*0.9144/60;
- case SpeedUnit.YardPerSecond: return _value*0.9144;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(SpeedUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case SpeedUnit.CentimeterPerHour: return (baseUnitValue*3600) / 1e-2d;
- case SpeedUnit.CentimeterPerMinute: return (baseUnitValue*60) / 1e-2d;
- case SpeedUnit.CentimeterPerSecond: return (baseUnitValue) / 1e-2d;
- case SpeedUnit.DecimeterPerMinute: return (baseUnitValue*60) / 1e-1d;
- case SpeedUnit.DecimeterPerSecond: return (baseUnitValue) / 1e-1d;
- case SpeedUnit.FootPerHour: return baseUnitValue/0.3048*3600;
- case SpeedUnit.FootPerMinute: return baseUnitValue/0.3048*60;
- case SpeedUnit.FootPerSecond: return baseUnitValue/0.3048;
- case SpeedUnit.InchPerHour: return (baseUnitValue/2.54e-2)*3600;
- case SpeedUnit.InchPerMinute: return (baseUnitValue/2.54e-2)*60;
- case SpeedUnit.InchPerSecond: return baseUnitValue/2.54e-2;
- case SpeedUnit.KilometerPerHour: return (baseUnitValue*3600) / 1e3d;
- case SpeedUnit.KilometerPerMinute: return (baseUnitValue*60) / 1e3d;
- case SpeedUnit.KilometerPerSecond: return (baseUnitValue) / 1e3d;
- case SpeedUnit.Knot: return baseUnitValue/0.514444;
- case SpeedUnit.MeterPerHour: return baseUnitValue*3600;
- case SpeedUnit.MeterPerMinute: return baseUnitValue*60;
- case SpeedUnit.MeterPerSecond: return baseUnitValue;
- case SpeedUnit.MicrometerPerMinute: return (baseUnitValue*60) / 1e-6d;
- case SpeedUnit.MicrometerPerSecond: return (baseUnitValue) / 1e-6d;
- case SpeedUnit.MilePerHour: return baseUnitValue/0.44704;
- case SpeedUnit.MillimeterPerHour: return (baseUnitValue*3600) / 1e-3d;
- case SpeedUnit.MillimeterPerMinute: return (baseUnitValue*60) / 1e-3d;
- case SpeedUnit.MillimeterPerSecond: return (baseUnitValue) / 1e-3d;
- case SpeedUnit.NanometerPerMinute: return (baseUnitValue*60) / 1e-9d;
- case SpeedUnit.NanometerPerSecond: return (baseUnitValue) / 1e-9d;
- case SpeedUnit.UsSurveyFootPerHour: return (baseUnitValue*3937/1200)*3600;
- case SpeedUnit.UsSurveyFootPerMinute: return (baseUnitValue*3937/1200)*60;
- case SpeedUnit.UsSurveyFootPerSecond: return baseUnitValue*3937/1200;
- case SpeedUnit.YardPerHour: return baseUnitValue/0.9144*3600;
- case SpeedUnit.YardPerMinute: return baseUnitValue/0.9144*60;
- case SpeedUnit.YardPerSecond: return baseUnitValue/0.9144;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Speed Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Speed result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static SpeedUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is MeterPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static SpeedUnit ToStringDefaultUnit { get; set; } = SpeedUnit.MeterPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(SpeedUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Speed
- ///
- public static Speed MaxValue => new Speed(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Speed
- ///
- public static Speed MinValue => new Speed(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Speed.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Speed.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Temperature.Common.g.cs b/Common/GeneratedCode/Quantities/Temperature.Common.g.cs
deleted file mode 100644
index 15133db34e..0000000000
--- a/Common/GeneratedCode/Quantities/Temperature.Common.g.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.
- ///
- // 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 Temperature : IQuantity
-#else
- public partial struct Temperature : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly TemperatureUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public TemperatureUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Temperature()
- {
- BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Kelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Temperature(double kelvins)
- {
- _value = Convert.ToDouble(kelvins);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Temperature(double numericValue, TemperatureUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kelvin.
- ///
- /// Value assuming base unit Kelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Temperature(long kelvins) : this(Convert.ToDouble(kelvins), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kelvin.
- ///
- /// Value assuming base unit Kelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Temperature(decimal kelvins) : this(Convert.ToDouble(kelvins), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Temperature;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static TemperatureUnit BaseUnit => TemperatureUnit.Kelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Temperature quantity.
- ///
- public static TemperatureUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureUnit)).Cast().Except(new TemperatureUnit[]{ TemperatureUnit.Undefined }).ToArray();
-
- ///
- /// Get Temperature in DegreesCelsius.
- ///
- public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius);
-
- ///
- /// Get Temperature in DegreesDelisle.
- ///
- public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle);
-
- ///
- /// Get Temperature in DegreesFahrenheit.
- ///
- public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit);
-
- ///
- /// Get Temperature in DegreesNewton.
- ///
- public double DegreesNewton => As(TemperatureUnit.DegreeNewton);
-
- ///
- /// Get Temperature in DegreesRankine.
- ///
- public double DegreesRankine => As(TemperatureUnit.DegreeRankine);
-
- ///
- /// Get Temperature in DegreesReaumur.
- ///
- public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur);
-
- ///
- /// Get Temperature in DegreesRoemer.
- ///
- public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer);
-
- ///
- /// Get Temperature in Kelvins.
- ///
- public double Kelvins => As(TemperatureUnit.Kelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin.
- ///
- public static Temperature Zero => new Temperature(0, BaseUnit);
-
- ///
- /// Get Temperature from DegreesCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesCelsius(double degreescelsius)
-#else
- public static Temperature FromDegreesCelsius(QuantityValue degreescelsius)
-#endif
- {
- double value = (double) degreescelsius;
- return new Temperature(value, TemperatureUnit.DegreeCelsius);
- }
-
- ///
- /// Get Temperature from DegreesDelisle.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesDelisle(double degreesdelisle)
-#else
- public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle)
-#endif
- {
- double value = (double) degreesdelisle;
- return new Temperature(value, TemperatureUnit.DegreeDelisle);
- }
-
- ///
- /// Get Temperature from DegreesFahrenheit.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesFahrenheit(double degreesfahrenheit)
-#else
- public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit)
-#endif
- {
- double value = (double) degreesfahrenheit;
- return new Temperature(value, TemperatureUnit.DegreeFahrenheit);
- }
-
- ///
- /// Get Temperature from DegreesNewton.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesNewton(double degreesnewton)
-#else
- public static Temperature FromDegreesNewton(QuantityValue degreesnewton)
-#endif
- {
- double value = (double) degreesnewton;
- return new Temperature(value, TemperatureUnit.DegreeNewton);
- }
-
- ///
- /// Get Temperature from DegreesRankine.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesRankine(double degreesrankine)
-#else
- public static Temperature FromDegreesRankine(QuantityValue degreesrankine)
-#endif
- {
- double value = (double) degreesrankine;
- return new Temperature(value, TemperatureUnit.DegreeRankine);
- }
-
- ///
- /// Get Temperature from DegreesReaumur.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesReaumur(double degreesreaumur)
-#else
- public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur)
-#endif
- {
- double value = (double) degreesreaumur;
- return new Temperature(value, TemperatureUnit.DegreeReaumur);
- }
-
- ///
- /// Get Temperature from DegreesRoemer.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromDegreesRoemer(double degreesroemer)
-#else
- public static Temperature FromDegreesRoemer(QuantityValue degreesroemer)
-#endif
- {
- double value = (double) degreesroemer;
- return new Temperature(value, TemperatureUnit.DegreeRoemer);
- }
-
- ///
- /// Get Temperature from Kelvins.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Temperature FromKelvins(double kelvins)
-#else
- public static Temperature FromKelvins(QuantityValue kelvins)
-#endif
- {
- double value = (double) kelvins;
- return new Temperature(value, TemperatureUnit.Kelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Temperature unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Temperature From(double value, TemperatureUnit fromUnit)
-#else
- public static Temperature From(QuantityValue value, TemperatureUnit fromUnit)
-#endif
- {
- return new Temperature((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(TemperatureUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Temperature)) throw new ArgumentException("Expected type Temperature.", nameof(obj));
-
- return CompareTo((Temperature)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(Temperature other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Temperature, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Temperature))
- return false;
-
- var objQuantity = (Temperature)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Temperature within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Temperature 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.
- [Obsolete("Please use the Equals(Temperature, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Temperature other, Temperature maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Temperature.
- public override int GetHashCode()
- {
- return new { type = typeof(Temperature), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(TemperatureUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Temperature to another Temperature with the unit representation .
- ///
- /// A Temperature with the specified unit.
- public Temperature ToUnit(TemperatureUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Temperature(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case TemperatureUnit.DegreeCelsius: return _value + 273.15;
- case TemperatureUnit.DegreeDelisle: return _value*-2/3 + 373.15;
- case TemperatureUnit.DegreeFahrenheit: return _value*5/9 + 459.67*5/9;
- case TemperatureUnit.DegreeNewton: return _value*100/33 + 273.15;
- case TemperatureUnit.DegreeRankine: return _value*5/9;
- case TemperatureUnit.DegreeReaumur: return _value*5/4 + 273.15;
- case TemperatureUnit.DegreeRoemer: return _value*40/21 + 273.15 - 7.5*40d/21;
- case TemperatureUnit.Kelvin: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(TemperatureUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case TemperatureUnit.DegreeCelsius: return baseUnitValue - 273.15;
- case TemperatureUnit.DegreeDelisle: return (baseUnitValue - 373.15)*-3/2;
- case TemperatureUnit.DegreeFahrenheit: return (baseUnitValue - 459.67*5/9)*9/5;
- case TemperatureUnit.DegreeNewton: return (baseUnitValue - 273.15)*33/100;
- case TemperatureUnit.DegreeRankine: return baseUnitValue*9/5;
- case TemperatureUnit.DegreeReaumur: return (baseUnitValue - 273.15)*4/5;
- case TemperatureUnit.DegreeRoemer: return (baseUnitValue - (273.15 - 7.5*40d/21))*21/40;
- case TemperatureUnit.Kelvin: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Temperature Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Temperature result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static TemperatureUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Kelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static TemperatureUnit ToStringDefaultUnit { get; set; } = TemperatureUnit.Kelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(TemperatureUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Temperature
- ///
- public static Temperature MaxValue => new Temperature(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Temperature
- ///
- public static Temperature MinValue => new Temperature(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Temperature.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Temperature.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/TemperatureChangeRate.Common.g.cs b/Common/GeneratedCode/Quantities/TemperatureChangeRate.Common.g.cs
deleted file mode 100644
index a4da3cde72..0000000000
--- a/Common/GeneratedCode/Quantities/TemperatureChangeRate.Common.g.cs
+++ /dev/null
@@ -1,679 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time).
- ///
- // 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 TemperatureChangeRate : IQuantity
-#else
- public partial struct TemperatureChangeRate : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly TemperatureChangeRateUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static TemperatureChangeRate()
- {
- BaseDimensions = new BaseDimensions(0, 0, -1, 0, 1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit DegreeCelsiusPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public TemperatureChangeRate(double degreescelsiuspersecond)
- {
- _value = Convert.ToDouble(degreescelsiuspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- TemperatureChangeRate(double numericValue, TemperatureChangeRateUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DegreeCelsiusPerSecond.
- ///
- /// Value assuming base unit DegreeCelsiusPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- TemperatureChangeRate(long degreescelsiuspersecond) : this(Convert.ToDouble(degreescelsiuspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit DegreeCelsiusPerSecond.
- ///
- /// Value assuming base unit DegreeCelsiusPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- TemperatureChangeRate(decimal degreescelsiuspersecond) : this(Convert.ToDouble(degreescelsiuspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.TemperatureChangeRate;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static TemperatureChangeRateUnit BaseUnit => TemperatureChangeRateUnit.DegreeCelsiusPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the TemperatureChangeRate quantity.
- ///
- public static TemperatureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().Except(new TemperatureChangeRateUnit[]{ TemperatureChangeRateUnit.Undefined }).ToArray();
-
- ///
- /// Get TemperatureChangeRate in CentidegreesCelsiusPerSecond.
- ///
- public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in DecadegreesCelsiusPerSecond.
- ///
- public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in DecidegreesCelsiusPerSecond.
- ///
- public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in DegreesCelsiusPerMinute.
- ///
- public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute);
-
- ///
- /// Get TemperatureChangeRate in DegreesCelsiusPerSecond.
- ///
- public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in HectodegreesCelsiusPerSecond.
- ///
- public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in KilodegreesCelsiusPerSecond.
- ///
- public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in MicrodegreesCelsiusPerSecond.
- ///
- public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in MillidegreesCelsiusPerSecond.
- ///
- public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond);
-
- ///
- /// Get TemperatureChangeRate in NanodegreesCelsiusPerSecond.
- ///
- public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerSecond.
- ///
- public static TemperatureChangeRate Zero => new TemperatureChangeRate(0, BaseUnit);
-
- ///
- /// Get TemperatureChangeRate from CentidegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(double centidegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityValue centidegreescelsiuspersecond)
-#endif
- {
- double value = (double) centidegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from DecadegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(double decadegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValue decadegreescelsiuspersecond)
-#endif
- {
- double value = (double) decadegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from DecidegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(double decidegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValue decidegreescelsiuspersecond)
-#endif
- {
- double value = (double) decidegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from DegreesCelsiusPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromDegreesCelsiusPerMinute(double degreescelsiusperminute)
-#else
- public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue degreescelsiusperminute)
-#endif
- {
- double value = (double) degreescelsiusperminute;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute);
- }
-
- ///
- /// Get TemperatureChangeRate from DegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromDegreesCelsiusPerSecond(double degreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue degreescelsiuspersecond)
-#endif
- {
- double value = (double) degreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from HectodegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(double hectodegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityValue hectodegreescelsiuspersecond)
-#endif
- {
- double value = (double) hectodegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from KilodegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(double kilodegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValue kilodegreescelsiuspersecond)
-#endif
- {
- double value = (double) kilodegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from MicrodegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(double microdegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityValue microdegreescelsiuspersecond)
-#endif
- {
- double value = (double) microdegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from MillidegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(double millidegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityValue millidegreescelsiuspersecond)
-#endif
- {
- double value = (double) millidegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond);
- }
-
- ///
- /// Get TemperatureChangeRate from NanodegreesCelsiusPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(double nanodegreescelsiuspersecond)
-#else
- public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValue nanodegreescelsiuspersecond)
-#endif
- {
- double value = (double) nanodegreescelsiuspersecond;
- return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// TemperatureChangeRate unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static TemperatureChangeRate From(double value, TemperatureChangeRateUnit fromUnit)
-#else
- public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeRateUnit fromUnit)
-#endif
- {
- return new TemperatureChangeRate((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(TemperatureChangeRateUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is TemperatureChangeRate)) throw new ArgumentException("Expected type TemperatureChangeRate.", nameof(obj));
-
- return CompareTo((TemperatureChangeRate)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(TemperatureChangeRate other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(TemperatureChangeRate, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is TemperatureChangeRate))
- return false;
-
- var objQuantity = (TemperatureChangeRate)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another TemperatureChangeRate 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.
- [Obsolete("Please use the Equals(TemperatureChangeRate, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(TemperatureChangeRate other, TemperatureChangeRate maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current TemperatureChangeRate.
- public override int GetHashCode()
- {
- return new { type = typeof(TemperatureChangeRate), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(TemperatureChangeRateUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation .
- ///
- /// A TemperatureChangeRate with the specified unit.
- public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new TemperatureChangeRate(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (_value) * 1e-2d;
- case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (_value) * 1e1d;
- case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (_value) * 1e-1d;
- case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return _value/60;
- case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return _value;
- case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (_value) * 1e2d;
- case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (_value) * 1e3d;
- case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (_value) * 1e-6d;
- case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (_value) * 1e-3d;
- case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (_value) * 1e-9d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(TemperatureChangeRateUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-2d;
- case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (baseUnitValue) / 1e1d;
- case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-1d;
- case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return baseUnitValue*60;
- case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return baseUnitValue;
- case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (baseUnitValue) / 1e2d;
- case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (baseUnitValue) / 1e3d;
- case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (baseUnitValue) / 1e-6d;
- case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-3d;
- case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (baseUnitValue) / 1e-9d;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 TemperatureChangeRate Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 TemperatureChangeRate result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static TemperatureChangeRateUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is DegreeCelsiusPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static TemperatureChangeRateUnit ToStringDefaultUnit { get; set; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(TemperatureChangeRateUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of TemperatureChangeRate
- ///
- public static TemperatureChangeRate MaxValue => new TemperatureChangeRate(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of TemperatureChangeRate
- ///
- public static TemperatureChangeRate MinValue => new TemperatureChangeRate(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => TemperatureChangeRate.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => TemperatureChangeRate.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/TemperatureDelta.Common.g.cs b/Common/GeneratedCode/Quantities/TemperatureDelta.Common.g.cs
deleted file mode 100644
index 2c5f5310eb..0000000000
--- a/Common/GeneratedCode/Quantities/TemperatureDelta.Common.g.cs
+++ /dev/null
@@ -1,820 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Difference between two temperatures. The conversions are different than for Temperature.
- ///
- // 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 TemperatureDelta : IQuantity
-#else
- public partial struct TemperatureDelta : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly TemperatureDeltaUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static TemperatureDelta()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit Kelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public TemperatureDelta(double kelvins)
- {
- _value = Convert.ToDouble(kelvins);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- TemperatureDelta(double numericValue, TemperatureDeltaUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kelvin.
- ///
- /// Value assuming base unit Kelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- TemperatureDelta(long kelvins) : this(Convert.ToDouble(kelvins), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit Kelvin.
- ///
- /// Value assuming base unit Kelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- TemperatureDelta(decimal kelvins) : this(Convert.ToDouble(kelvins), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.TemperatureDelta;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static TemperatureDeltaUnit BaseUnit => TemperatureDeltaUnit.Kelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the TemperatureDelta quantity.
- ///
- public static TemperatureDeltaUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().Except(new TemperatureDeltaUnit[]{ TemperatureDeltaUnit.Undefined }).ToArray();
-
- ///
- /// Get TemperatureDelta in DegreesCelsius.
- ///
- public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius);
-
- ///
- /// Get TemperatureDelta in DegreesCelsiusDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeCelsius instead")]
- public double DegreesCelsiusDelta => As(TemperatureDeltaUnit.DegreeCelsiusDelta);
-
- ///
- /// Get TemperatureDelta in DegreesDelisle.
- ///
- public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle);
-
- ///
- /// Get TemperatureDelta in DegreesDelisleDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeDelisle instead")]
- public double DegreesDelisleDelta => As(TemperatureDeltaUnit.DegreeDelisleDelta);
-
- ///
- /// Get TemperatureDelta in DegreesFahrenheit.
- ///
- public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit);
-
- ///
- /// Get TemperatureDelta in DegreesFahrenheitDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeFahrenheit instead")]
- public double DegreesFahrenheitDelta => As(TemperatureDeltaUnit.DegreeFahrenheitDelta);
-
- ///
- /// Get TemperatureDelta in DegreesNewton.
- ///
- public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton);
-
- ///
- /// Get TemperatureDelta in DegreesNewtonDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeNewton instead")]
- public double DegreesNewtonDelta => As(TemperatureDeltaUnit.DegreeNewtonDelta);
-
- ///
- /// Get TemperatureDelta in DegreesRankine.
- ///
- public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine);
-
- ///
- /// Get TemperatureDelta in DegreesRankineDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeRankine instead")]
- public double DegreesRankineDelta => As(TemperatureDeltaUnit.DegreeRankineDelta);
-
- ///
- /// Get TemperatureDelta in DegreesReaumur.
- ///
- public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur);
-
- ///
- /// Get TemperatureDelta in DegreesReaumurDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeReaumur instead")]
- public double DegreesReaumurDelta => As(TemperatureDeltaUnit.DegreeReaumurDelta);
-
- ///
- /// Get TemperatureDelta in DegreesRoemer.
- ///
- public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer);
-
- ///
- /// Get TemperatureDelta in DegreesRoemerDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeRoemer instead")]
- public double DegreesRoemerDelta => As(TemperatureDeltaUnit.DegreeRoemerDelta);
-
- ///
- /// Get TemperatureDelta in Kelvins.
- ///
- public double Kelvins => As(TemperatureDeltaUnit.Kelvin);
-
- ///
- /// Get TemperatureDelta in KelvinsDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use Kelvin instead")]
- public double KelvinsDelta => As(TemperatureDeltaUnit.KelvinDelta);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin.
- ///
- public static TemperatureDelta Zero => new TemperatureDelta(0, BaseUnit);
-
- ///
- /// Get TemperatureDelta from DegreesCelsius.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesCelsius(double degreescelsius)
-#else
- public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius)
-#endif
- {
- double value = (double) degreescelsius;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius);
- }
-
- ///
- /// Get TemperatureDelta from DegreesCelsiusDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeCelsius instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesCelsiusDelta(double degreescelsiusdelta)
-#else
- public static TemperatureDelta FromDegreesCelsiusDelta(QuantityValue degreescelsiusdelta)
-#endif
- {
- double value = (double) degreescelsiusdelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsiusDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesDelisle.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesDelisle(double degreesdelisle)
-#else
- public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle)
-#endif
- {
- double value = (double) degreesdelisle;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle);
- }
-
- ///
- /// Get TemperatureDelta from DegreesDelisleDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeDelisle instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesDelisleDelta(double degreesdelisledelta)
-#else
- public static TemperatureDelta FromDegreesDelisleDelta(QuantityValue degreesdelisledelta)
-#endif
- {
- double value = (double) degreesdelisledelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisleDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesFahrenheit.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesFahrenheit(double degreesfahrenheit)
-#else
- public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahrenheit)
-#endif
- {
- double value = (double) degreesfahrenheit;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit);
- }
-
- ///
- /// Get TemperatureDelta from DegreesFahrenheitDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeFahrenheit instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesFahrenheitDelta(double degreesfahrenheitdelta)
-#else
- public static TemperatureDelta FromDegreesFahrenheitDelta(QuantityValue degreesfahrenheitdelta)
-#endif
- {
- double value = (double) degreesfahrenheitdelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheitDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesNewton.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesNewton(double degreesnewton)
-#else
- public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton)
-#endif
- {
- double value = (double) degreesnewton;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton);
- }
-
- ///
- /// Get TemperatureDelta from DegreesNewtonDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeNewton instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesNewtonDelta(double degreesnewtondelta)
-#else
- public static TemperatureDelta FromDegreesNewtonDelta(QuantityValue degreesnewtondelta)
-#endif
- {
- double value = (double) degreesnewtondelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewtonDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesRankine.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesRankine(double degreesrankine)
-#else
- public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine)
-#endif
- {
- double value = (double) degreesrankine;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine);
- }
-
- ///
- /// Get TemperatureDelta from DegreesRankineDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeRankine instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesRankineDelta(double degreesrankinedelta)
-#else
- public static TemperatureDelta FromDegreesRankineDelta(QuantityValue degreesrankinedelta)
-#endif
- {
- double value = (double) degreesrankinedelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankineDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesReaumur.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesReaumur(double degreesreaumur)
-#else
- public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur)
-#endif
- {
- double value = (double) degreesreaumur;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur);
- }
-
- ///
- /// Get TemperatureDelta from DegreesReaumurDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeReaumur instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesReaumurDelta(double degreesreaumurdelta)
-#else
- public static TemperatureDelta FromDegreesReaumurDelta(QuantityValue degreesreaumurdelta)
-#endif
- {
- double value = (double) degreesreaumurdelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumurDelta);
- }
-
- ///
- /// Get TemperatureDelta from DegreesRoemer.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesRoemer(double degreesroemer)
-#else
- public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer)
-#endif
- {
- double value = (double) degreesroemer;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer);
- }
-
- ///
- /// Get TemperatureDelta from DegreesRoemerDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use DegreeRoemer instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromDegreesRoemerDelta(double degreesroemerdelta)
-#else
- public static TemperatureDelta FromDegreesRoemerDelta(QuantityValue degreesroemerdelta)
-#endif
- {
- double value = (double) degreesroemerdelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemerDelta);
- }
-
- ///
- /// Get TemperatureDelta from Kelvins.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromKelvins(double kelvins)
-#else
- public static TemperatureDelta FromKelvins(QuantityValue kelvins)
-#endif
- {
- double value = (double) kelvins;
- return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin);
- }
-
- ///
- /// Get TemperatureDelta from KelvinsDelta.
- ///
- [System.Obsolete("Deprecated due to github issue #180, please use Kelvin instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static TemperatureDelta FromKelvinsDelta(double kelvinsdelta)
-#else
- public static TemperatureDelta FromKelvinsDelta(QuantityValue kelvinsdelta)
-#endif
- {
- double value = (double) kelvinsdelta;
- return new TemperatureDelta(value, TemperatureDeltaUnit.KelvinDelta);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// TemperatureDelta unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static TemperatureDelta From(double value, TemperatureDeltaUnit fromUnit)
-#else
- public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fromUnit)
-#endif
- {
- return new TemperatureDelta((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(TemperatureDeltaUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is TemperatureDelta)) throw new ArgumentException("Expected type TemperatureDelta.", nameof(obj));
-
- return CompareTo((TemperatureDelta)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(TemperatureDelta other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(TemperatureDelta, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is TemperatureDelta))
- return false;
-
- var objQuantity = (TemperatureDelta)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another TemperatureDelta 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.
- [Obsolete("Please use the Equals(TemperatureDelta, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(TemperatureDelta other, TemperatureDelta maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current TemperatureDelta.
- public override int GetHashCode()
- {
- return new { type = typeof(TemperatureDelta), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(TemperatureDeltaUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation .
- ///
- /// A TemperatureDelta with the specified unit.
- public TemperatureDelta ToUnit(TemperatureDeltaUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new TemperatureDelta(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case TemperatureDeltaUnit.DegreeCelsius: return _value;
- case TemperatureDeltaUnit.DegreeCelsiusDelta: return _value;
- case TemperatureDeltaUnit.DegreeDelisle: return _value*-2/3;
- case TemperatureDeltaUnit.DegreeDelisleDelta: return _value*-2/3;
- case TemperatureDeltaUnit.DegreeFahrenheit: return _value*5/9;
- case TemperatureDeltaUnit.DegreeFahrenheitDelta: return _value*5/9;
- case TemperatureDeltaUnit.DegreeNewton: return _value*100/33;
- case TemperatureDeltaUnit.DegreeNewtonDelta: return _value*100/33;
- case TemperatureDeltaUnit.DegreeRankine: return _value*5/9;
- case TemperatureDeltaUnit.DegreeRankineDelta: return _value*5/9;
- case TemperatureDeltaUnit.DegreeReaumur: return _value*5/4;
- case TemperatureDeltaUnit.DegreeReaumurDelta: return _value*5/4;
- case TemperatureDeltaUnit.DegreeRoemer: return _value*40/21;
- case TemperatureDeltaUnit.DegreeRoemerDelta: return _value*40/21;
- case TemperatureDeltaUnit.Kelvin: return _value;
- case TemperatureDeltaUnit.KelvinDelta: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(TemperatureDeltaUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case TemperatureDeltaUnit.DegreeCelsius: return baseUnitValue;
- case TemperatureDeltaUnit.DegreeCelsiusDelta: return baseUnitValue;
- case TemperatureDeltaUnit.DegreeDelisle: return baseUnitValue*-3/2;
- case TemperatureDeltaUnit.DegreeDelisleDelta: return baseUnitValue*-3/2;
- case TemperatureDeltaUnit.DegreeFahrenheit: return baseUnitValue*9/5;
- case TemperatureDeltaUnit.DegreeFahrenheitDelta: return baseUnitValue*9/5;
- case TemperatureDeltaUnit.DegreeNewton: return baseUnitValue*33/100;
- case TemperatureDeltaUnit.DegreeNewtonDelta: return baseUnitValue*33/100;
- case TemperatureDeltaUnit.DegreeRankine: return baseUnitValue*9/5;
- case TemperatureDeltaUnit.DegreeRankineDelta: return baseUnitValue*9/5;
- case TemperatureDeltaUnit.DegreeReaumur: return baseUnitValue*4/5;
- case TemperatureDeltaUnit.DegreeReaumurDelta: return baseUnitValue*4/5;
- case TemperatureDeltaUnit.DegreeRoemer: return baseUnitValue*21/40;
- case TemperatureDeltaUnit.DegreeRoemerDelta: return baseUnitValue*21/40;
- case TemperatureDeltaUnit.Kelvin: return baseUnitValue;
- case TemperatureDeltaUnit.KelvinDelta: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 TemperatureDelta Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 TemperatureDelta result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static TemperatureDeltaUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is Kelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static TemperatureDeltaUnit ToStringDefaultUnit { get; set; } = TemperatureDeltaUnit.Kelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(TemperatureDeltaUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of TemperatureDelta
- ///
- public static TemperatureDelta MaxValue => new TemperatureDelta(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of TemperatureDelta
- ///
- public static TemperatureDelta MinValue => new TemperatureDelta(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => TemperatureDelta.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => TemperatureDelta.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ThermalConductivity.Common.g.cs b/Common/GeneratedCode/Quantities/ThermalConductivity.Common.g.cs
deleted file mode 100644
index 59ddee2a84..0000000000
--- a/Common/GeneratedCode/Quantities/ThermalConductivity.Common.g.cs
+++ /dev/null
@@ -1,511 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Thermal conductivity is the property of a material to conduct heat.
- ///
- // 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 ThermalConductivity : IQuantity
-#else
- public partial struct ThermalConductivity : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ThermalConductivityUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ThermalConductivity()
- {
- BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit WattPerMeterKelvin.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ThermalConductivity(double wattspermeterkelvin)
- {
- _value = Convert.ToDouble(wattspermeterkelvin);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ThermalConductivity(double numericValue, ThermalConductivityUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerMeterKelvin.
- ///
- /// Value assuming base unit WattPerMeterKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ThermalConductivity(long wattspermeterkelvin) : this(Convert.ToDouble(wattspermeterkelvin), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit WattPerMeterKelvin.
- ///
- /// Value assuming base unit WattPerMeterKelvin.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ThermalConductivity(decimal wattspermeterkelvin) : this(Convert.ToDouble(wattspermeterkelvin), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ThermalConductivity;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ThermalConductivityUnit BaseUnit => ThermalConductivityUnit.WattPerMeterKelvin;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ThermalConductivity quantity.
- ///
- public static ThermalConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().Except(new ThermalConductivityUnit[]{ ThermalConductivityUnit.Undefined }).ToArray();
-
- ///
- /// Get ThermalConductivity in BtusPerHourFootFahrenheit.
- ///
- public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit);
-
- ///
- /// Get ThermalConductivity in WattsPerMeterKelvin.
- ///
- public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeterKelvin.
- ///
- public static ThermalConductivity Zero => new ThermalConductivity(0, BaseUnit);
-
- ///
- /// Get ThermalConductivity from BtusPerHourFootFahrenheit.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalConductivity FromBtusPerHourFootFahrenheit(double btusperhourfootfahrenheit)
-#else
- public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue btusperhourfootfahrenheit)
-#endif
- {
- double value = (double) btusperhourfootfahrenheit;
- return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit);
- }
-
- ///
- /// Get ThermalConductivity from WattsPerMeterKelvin.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalConductivity FromWattsPerMeterKelvin(double wattspermeterkelvin)
-#else
- public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattspermeterkelvin)
-#endif
- {
- double value = (double) wattspermeterkelvin;
- return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ThermalConductivity unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ThermalConductivity From(double value, ThermalConductivityUnit fromUnit)
-#else
- public static ThermalConductivity From(QuantityValue value, ThermalConductivityUnit fromUnit)
-#endif
- {
- return new ThermalConductivity((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ThermalConductivityUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ThermalConductivity)) throw new ArgumentException("Expected type ThermalConductivity.", nameof(obj));
-
- return CompareTo((ThermalConductivity)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(ThermalConductivity other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ThermalConductivity, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ThermalConductivity))
- return false;
-
- var objQuantity = (ThermalConductivity)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ThermalConductivity 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.
- [Obsolete("Please use the Equals(ThermalConductivity, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ThermalConductivity other, ThermalConductivity maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ThermalConductivity.
- public override int GetHashCode()
- {
- return new { type = typeof(ThermalConductivity), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ThermalConductivityUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation .
- ///
- /// A ThermalConductivity with the specified unit.
- public ThermalConductivity ToUnit(ThermalConductivityUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ThermalConductivity(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return _value*1.73073467;
- case ThermalConductivityUnit.WattPerMeterKelvin: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ThermalConductivityUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return baseUnitValue/1.73073467;
- case ThermalConductivityUnit.WattPerMeterKelvin: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ThermalConductivity Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ThermalConductivity result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ThermalConductivityUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is WattPerMeterKelvin
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ThermalConductivityUnit ToStringDefaultUnit { get; set; } = ThermalConductivityUnit.WattPerMeterKelvin;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ThermalConductivityUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ThermalConductivity
- ///
- public static ThermalConductivity MaxValue => new ThermalConductivity(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ThermalConductivity
- ///
- public static ThermalConductivity MinValue => new ThermalConductivity(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ThermalConductivity.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ThermalConductivity.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/ThermalResistance.Common.g.cs b/Common/GeneratedCode/Quantities/ThermalResistance.Common.g.cs
deleted file mode 100644
index d0c4034f11..0000000000
--- a/Common/GeneratedCode/Quantities/ThermalResistance.Common.g.cs
+++ /dev/null
@@ -1,574 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.
- ///
- // 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 ThermalResistance : IQuantity
-#else
- public partial struct ThermalResistance : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly ThermalResistanceUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static ThermalResistance()
- {
- BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit SquareMeterKelvinPerKilowatt.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public ThermalResistance(double squaremeterkelvinsperkilowatt)
- {
- _value = Convert.ToDouble(squaremeterkelvinsperkilowatt);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- ThermalResistance(double numericValue, ThermalResistanceUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeterKelvinPerKilowatt.
- ///
- /// Value assuming base unit SquareMeterKelvinPerKilowatt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ThermalResistance(long squaremeterkelvinsperkilowatt) : this(Convert.ToDouble(squaremeterkelvinsperkilowatt), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit SquareMeterKelvinPerKilowatt.
- ///
- /// Value assuming base unit SquareMeterKelvinPerKilowatt.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- ThermalResistance(decimal squaremeterkelvinsperkilowatt) : this(Convert.ToDouble(squaremeterkelvinsperkilowatt), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.ThermalResistance;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static ThermalResistanceUnit BaseUnit => ThermalResistanceUnit.SquareMeterKelvinPerKilowatt;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the ThermalResistance quantity.
- ///
- public static ThermalResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().Except(new ThermalResistanceUnit[]{ ThermalResistanceUnit.Undefined }).ToArray();
-
- ///
- /// Get ThermalResistance in HourSquareFeetDegreesFahrenheitPerBtu.
- ///
- public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu);
-
- ///
- /// Get ThermalResistance in SquareCentimeterHourDegreesCelsiusPerKilocalorie.
- ///
- public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie);
-
- ///
- /// Get ThermalResistance in SquareCentimeterKelvinsPerWatt.
- ///
- public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt);
-
- ///
- /// Get ThermalResistance in SquareMeterDegreesCelsiusPerWatt.
- ///
- public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt);
-
- ///
- /// Get ThermalResistance in SquareMeterKelvinsPerKilowatt.
- ///
- public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt.
- ///
- public static ThermalResistance Zero => new ThermalResistance(0, BaseUnit);
-
- ///
- /// Get ThermalResistance from HourSquareFeetDegreesFahrenheitPerBtu.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(double hoursquarefeetdegreesfahrenheitperbtu)
-#else
- public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(QuantityValue hoursquarefeetdegreesfahrenheitperbtu)
-#endif
- {
- double value = (double) hoursquarefeetdegreesfahrenheitperbtu;
- return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu);
- }
-
- ///
- /// Get ThermalResistance from SquareCentimeterHourDegreesCelsiusPerKilocalorie.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(double squarecentimeterhourdegreescelsiusperkilocalorie)
-#else
- public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(QuantityValue squarecentimeterhourdegreescelsiusperkilocalorie)
-#endif
- {
- double value = (double) squarecentimeterhourdegreescelsiusperkilocalorie;
- return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie);
- }
-
- ///
- /// Get ThermalResistance from SquareCentimeterKelvinsPerWatt.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(double squarecentimeterkelvinsperwatt)
-#else
- public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue squarecentimeterkelvinsperwatt)
-#endif
- {
- double value = (double) squarecentimeterkelvinsperwatt;
- return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt);
- }
-
- ///
- /// Get ThermalResistance from SquareMeterDegreesCelsiusPerWatt.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(double squaremeterdegreescelsiusperwatt)
-#else
- public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityValue squaremeterdegreescelsiusperwatt)
-#endif
- {
- double value = (double) squaremeterdegreescelsiusperwatt;
- return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt);
- }
-
- ///
- /// Get ThermalResistance from SquareMeterKelvinsPerKilowatt.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(double squaremeterkelvinsperkilowatt)
-#else
- public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue squaremeterkelvinsperkilowatt)
-#endif
- {
- double value = (double) squaremeterkelvinsperkilowatt;
- return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// ThermalResistance unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static ThermalResistance From(double value, ThermalResistanceUnit fromUnit)
-#else
- public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit fromUnit)
-#endif
- {
- return new ThermalResistance((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(ThermalResistanceUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is ThermalResistance)) throw new ArgumentException("Expected type ThermalResistance.", nameof(obj));
-
- return CompareTo((ThermalResistance)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(ThermalResistance other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(ThermalResistance, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is ThermalResistance))
- return false;
-
- var objQuantity = (ThermalResistance)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another ThermalResistance within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another ThermalResistance 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.
- [Obsolete("Please use the Equals(ThermalResistance, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(ThermalResistance other, ThermalResistance maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current ThermalResistance.
- public override int GetHashCode()
- {
- return new { type = typeof(ThermalResistance), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(ThermalResistanceUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this ThermalResistance to another ThermalResistance with the unit representation .
- ///
- /// A ThermalResistance with the specified unit.
- public ThermalResistance ToUnit(ThermalResistanceUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new ThermalResistance(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return _value*176.1121482159839;
- case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return _value*0.0859779507590433;
- case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return _value*0.0999964777570357;
- case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return _value*1000.088056074108;
- case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(ThermalResistanceUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return baseUnitValue/176.1121482159839;
- case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return baseUnitValue/0.0859779507590433;
- case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return baseUnitValue/0.0999964777570357;
- case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return baseUnitValue/1000.088056074108;
- case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 ThermalResistance Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 ThermalResistance result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static ThermalResistanceUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is SquareMeterKelvinPerKilowatt
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static ThermalResistanceUnit ToStringDefaultUnit { get; set; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(ThermalResistanceUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of ThermalResistance
- ///
- public static ThermalResistance MaxValue => new ThermalResistance(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of ThermalResistance
- ///
- public static ThermalResistance MinValue => new ThermalResistance(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => ThermalResistance.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => ThermalResistance.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Torque.Common.g.cs b/Common/GeneratedCode/Quantities/Torque.Common.g.cs
deleted file mode 100644
index 6f9df627ee..0000000000
--- a/Common/GeneratedCode/Quantities/Torque.Common.g.cs
+++ /dev/null
@@ -1,910 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.
- ///
- // 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 Torque : IQuantity
-#else
- public partial struct Torque : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly TorqueUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public TorqueUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Torque()
- {
- BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit NewtonMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Torque(double newtonmeters)
- {
- _value = Convert.ToDouble(newtonmeters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Torque(double numericValue, TorqueUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeter.
- ///
- /// Value assuming base unit NewtonMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Torque(long newtonmeters) : this(Convert.ToDouble(newtonmeters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit NewtonMeter.
- ///
- /// Value assuming base unit NewtonMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Torque(decimal newtonmeters) : this(Convert.ToDouble(newtonmeters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Torque;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static TorqueUnit BaseUnit => TorqueUnit.NewtonMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Torque quantity.
- ///
- public static TorqueUnit[] Units { get; } = Enum.GetValues(typeof(TorqueUnit)).Cast().Except(new TorqueUnit[]{ TorqueUnit.Undefined }).ToArray();
-
- ///
- /// Get Torque in KilogramForceCentimeters.
- ///
- public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter);
-
- ///
- /// Get Torque in KilogramForceMeters.
- ///
- public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter);
-
- ///
- /// Get Torque in KilogramForceMillimeters.
- ///
- public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter);
-
- ///
- /// Get Torque in KilonewtonCentimeters.
- ///
- public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter);
-
- ///
- /// Get Torque in KilonewtonMeters.
- ///
- public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter);
-
- ///
- /// Get Torque in KilonewtonMillimeters.
- ///
- public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter);
-
- ///
- /// Get Torque in KilopoundForceFeet.
- ///
- public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot);
-
- ///
- /// Get Torque in KilopoundForceInches.
- ///
- public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch);
-
- ///
- /// Get Torque in MeganewtonCentimeters.
- ///
- public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter);
-
- ///
- /// Get Torque in MeganewtonMeters.
- ///
- public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter);
-
- ///
- /// Get Torque in MeganewtonMillimeters.
- ///
- public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter);
-
- ///
- /// Get Torque in MegapoundForceFeet.
- ///
- public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot);
-
- ///
- /// Get Torque in MegapoundForceInches.
- ///
- public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch);
-
- ///
- /// Get Torque in NewtonCentimeters.
- ///
- public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter);
-
- ///
- /// Get Torque in NewtonMeters.
- ///
- public double NewtonMeters => As(TorqueUnit.NewtonMeter);
-
- ///
- /// Get Torque in NewtonMillimeters.
- ///
- public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter);
-
- ///
- /// Get Torque in PoundForceFeet.
- ///
- public double PoundForceFeet => As(TorqueUnit.PoundForceFoot);
-
- ///
- /// Get Torque in PoundForceInches.
- ///
- public double PoundForceInches => As(TorqueUnit.PoundForceInch);
-
- ///
- /// Get Torque in TonneForceCentimeters.
- ///
- public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter);
-
- ///
- /// Get Torque in TonneForceMeters.
- ///
- public double TonneForceMeters => As(TorqueUnit.TonneForceMeter);
-
- ///
- /// Get Torque in TonneForceMillimeters.
- ///
- public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeter.
- ///
- public static Torque Zero => new Torque(0, BaseUnit);
-
- ///
- /// Get Torque from KilogramForceCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilogramForceCentimeters(double kilogramforcecentimeters)
-#else
- public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecentimeters)
-#endif
- {
- double value = (double) kilogramforcecentimeters;
- return new Torque(value, TorqueUnit.KilogramForceCentimeter);
- }
-
- ///
- /// Get Torque from KilogramForceMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilogramForceMeters(double kilogramforcemeters)
-#else
- public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters)
-#endif
- {
- double value = (double) kilogramforcemeters;
- return new Torque(value, TorqueUnit.KilogramForceMeter);
- }
-
- ///
- /// Get Torque from KilogramForceMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilogramForceMillimeters(double kilogramforcemillimeters)
-#else
- public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemillimeters)
-#endif
- {
- double value = (double) kilogramforcemillimeters;
- return new Torque(value, TorqueUnit.KilogramForceMillimeter);
- }
-
- ///
- /// Get Torque from KilonewtonCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilonewtonCentimeters(double kilonewtoncentimeters)
-#else
- public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimeters)
-#endif
- {
- double value = (double) kilonewtoncentimeters;
- return new Torque(value, TorqueUnit.KilonewtonCentimeter);
- }
-
- ///
- /// Get Torque from KilonewtonMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilonewtonMeters(double kilonewtonmeters)
-#else
- public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters)
-#endif
- {
- double value = (double) kilonewtonmeters;
- return new Torque(value, TorqueUnit.KilonewtonMeter);
- }
-
- ///
- /// Get Torque from KilonewtonMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilonewtonMillimeters(double kilonewtonmillimeters)
-#else
- public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimeters)
-#endif
- {
- double value = (double) kilonewtonmillimeters;
- return new Torque(value, TorqueUnit.KilonewtonMillimeter);
- }
-
- ///
- /// Get Torque from KilopoundForceFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilopoundForceFeet(double kilopoundforcefeet)
-#else
- public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet)
-#endif
- {
- double value = (double) kilopoundforcefeet;
- return new Torque(value, TorqueUnit.KilopoundForceFoot);
- }
-
- ///
- /// Get Torque from KilopoundForceInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromKilopoundForceInches(double kilopoundforceinches)
-#else
- public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches)
-#endif
- {
- double value = (double) kilopoundforceinches;
- return new Torque(value, TorqueUnit.KilopoundForceInch);
- }
-
- ///
- /// Get Torque from MeganewtonCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromMeganewtonCentimeters(double meganewtoncentimeters)
-#else
- public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimeters)
-#endif
- {
- double value = (double) meganewtoncentimeters;
- return new Torque(value, TorqueUnit.MeganewtonCentimeter);
- }
-
- ///
- /// Get Torque from MeganewtonMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromMeganewtonMeters(double meganewtonmeters)
-#else
- public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters)
-#endif
- {
- double value = (double) meganewtonmeters;
- return new Torque(value, TorqueUnit.MeganewtonMeter);
- }
-
- ///
- /// Get Torque from MeganewtonMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromMeganewtonMillimeters(double meganewtonmillimeters)
-#else
- public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimeters)
-#endif
- {
- double value = (double) meganewtonmillimeters;
- return new Torque(value, TorqueUnit.MeganewtonMillimeter);
- }
-
- ///
- /// Get Torque from MegapoundForceFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromMegapoundForceFeet(double megapoundforcefeet)
-#else
- public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet)
-#endif
- {
- double value = (double) megapoundforcefeet;
- return new Torque(value, TorqueUnit.MegapoundForceFoot);
- }
-
- ///
- /// Get Torque from MegapoundForceInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromMegapoundForceInches(double megapoundforceinches)
-#else
- public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches)
-#endif
- {
- double value = (double) megapoundforceinches;
- return new Torque(value, TorqueUnit.MegapoundForceInch);
- }
-
- ///
- /// Get Torque from NewtonCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromNewtonCentimeters(double newtoncentimeters)
-#else
- public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters)
-#endif
- {
- double value = (double) newtoncentimeters;
- return new Torque(value, TorqueUnit.NewtonCentimeter);
- }
-
- ///
- /// Get Torque from NewtonMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromNewtonMeters(double newtonmeters)
-#else
- public static Torque FromNewtonMeters(QuantityValue newtonmeters)
-#endif
- {
- double value = (double) newtonmeters;
- return new Torque(value, TorqueUnit.NewtonMeter);
- }
-
- ///
- /// Get Torque from NewtonMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromNewtonMillimeters(double newtonmillimeters)
-#else
- public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters)
-#endif
- {
- double value = (double) newtonmillimeters;
- return new Torque(value, TorqueUnit.NewtonMillimeter);
- }
-
- ///
- /// Get Torque from PoundForceFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromPoundForceFeet(double poundforcefeet)
-#else
- public static Torque FromPoundForceFeet(QuantityValue poundforcefeet)
-#endif
- {
- double value = (double) poundforcefeet;
- return new Torque(value, TorqueUnit.PoundForceFoot);
- }
-
- ///
- /// Get Torque from PoundForceInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromPoundForceInches(double poundforceinches)
-#else
- public static Torque FromPoundForceInches(QuantityValue poundforceinches)
-#endif
- {
- double value = (double) poundforceinches;
- return new Torque(value, TorqueUnit.PoundForceInch);
- }
-
- ///
- /// Get Torque from TonneForceCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromTonneForceCentimeters(double tonneforcecentimeters)
-#else
- public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimeters)
-#endif
- {
- double value = (double) tonneforcecentimeters;
- return new Torque(value, TorqueUnit.TonneForceCentimeter);
- }
-
- ///
- /// Get Torque from TonneForceMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromTonneForceMeters(double tonneforcemeters)
-#else
- public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters)
-#endif
- {
- double value = (double) tonneforcemeters;
- return new Torque(value, TorqueUnit.TonneForceMeter);
- }
-
- ///
- /// Get Torque from TonneForceMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Torque FromTonneForceMillimeters(double tonneforcemillimeters)
-#else
- public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimeters)
-#endif
- {
- double value = (double) tonneforcemillimeters;
- return new Torque(value, TorqueUnit.TonneForceMillimeter);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Torque unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Torque From(double value, TorqueUnit fromUnit)
-#else
- public static Torque From(QuantityValue value, TorqueUnit fromUnit)
-#endif
- {
- return new Torque((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(TorqueUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Torque)) throw new ArgumentException("Expected type Torque.", nameof(obj));
-
- return CompareTo((Torque)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(Torque other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Torque, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Torque))
- return false;
-
- var objQuantity = (Torque)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Torque within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Torque other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Torque 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.
- [Obsolete("Please use the Equals(Torque, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Torque other, Torque maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Torque.
- public override int GetHashCode()
- {
- return new { type = typeof(Torque), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(TorqueUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Torque to another Torque with the unit representation .
- ///
- /// A Torque with the specified unit.
- public Torque ToUnit(TorqueUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Torque(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case TorqueUnit.KilogramForceCentimeter: return _value*0.0980665019960652;
- case TorqueUnit.KilogramForceMeter: return _value*9.80665019960652;
- case TorqueUnit.KilogramForceMillimeter: return _value*0.00980665019960652;
- case TorqueUnit.KilonewtonCentimeter: return (_value*0.01) * 1e3d;
- case TorqueUnit.KilonewtonMeter: return (_value) * 1e3d;
- case TorqueUnit.KilonewtonMillimeter: return (_value*0.001) * 1e3d;
- case TorqueUnit.KilopoundForceFoot: return (_value*1.3558179483314) * 1e3d;
- case TorqueUnit.KilopoundForceInch: return (_value*1.129848290276167e-1) * 1e3d;
- case TorqueUnit.MeganewtonCentimeter: return (_value*0.01) * 1e6d;
- case TorqueUnit.MeganewtonMeter: return (_value) * 1e6d;
- case TorqueUnit.MeganewtonMillimeter: return (_value*0.001) * 1e6d;
- case TorqueUnit.MegapoundForceFoot: return (_value*1.3558179483314) * 1e6d;
- case TorqueUnit.MegapoundForceInch: return (_value*1.129848290276167e-1) * 1e6d;
- case TorqueUnit.NewtonCentimeter: return _value*0.01;
- case TorqueUnit.NewtonMeter: return _value;
- case TorqueUnit.NewtonMillimeter: return _value*0.001;
- case TorqueUnit.PoundForceFoot: return _value*1.3558179483314;
- case TorqueUnit.PoundForceInch: return _value*1.129848290276167e-1;
- case TorqueUnit.TonneForceCentimeter: return _value*98.0665019960652;
- case TorqueUnit.TonneForceMeter: return _value*9806.65019960653;
- case TorqueUnit.TonneForceMillimeter: return _value*9.80665019960652;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(TorqueUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case TorqueUnit.KilogramForceCentimeter: return baseUnitValue*10.1971619222242;
- case TorqueUnit.KilogramForceMeter: return baseUnitValue*0.101971619222242;
- case TorqueUnit.KilogramForceMillimeter: return baseUnitValue*101.971619222242;
- case TorqueUnit.KilonewtonCentimeter: return (baseUnitValue*100) / 1e3d;
- case TorqueUnit.KilonewtonMeter: return (baseUnitValue) / 1e3d;
- case TorqueUnit.KilonewtonMillimeter: return (baseUnitValue*1000) / 1e3d;
- case TorqueUnit.KilopoundForceFoot: return (baseUnitValue/1.3558179483314) / 1e3d;
- case TorqueUnit.KilopoundForceInch: return (baseUnitValue/1.129848290276167e-1) / 1e3d;
- case TorqueUnit.MeganewtonCentimeter: return (baseUnitValue*100) / 1e6d;
- case TorqueUnit.MeganewtonMeter: return (baseUnitValue) / 1e6d;
- case TorqueUnit.MeganewtonMillimeter: return (baseUnitValue*1000) / 1e6d;
- case TorqueUnit.MegapoundForceFoot: return (baseUnitValue/1.3558179483314) / 1e6d;
- case TorqueUnit.MegapoundForceInch: return (baseUnitValue/1.129848290276167e-1) / 1e6d;
- case TorqueUnit.NewtonCentimeter: return baseUnitValue*100;
- case TorqueUnit.NewtonMeter: return baseUnitValue;
- case TorqueUnit.NewtonMillimeter: return baseUnitValue*1000;
- case TorqueUnit.PoundForceFoot: return baseUnitValue/1.3558179483314;
- case TorqueUnit.PoundForceInch: return baseUnitValue/1.129848290276167e-1;
- case TorqueUnit.TonneForceCentimeter: return baseUnitValue*0.0101971619222242;
- case TorqueUnit.TonneForceMeter: return baseUnitValue*0.000101971619222242;
- case TorqueUnit.TonneForceMillimeter: return baseUnitValue*0.101971619222242;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Torque Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Torque result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static TorqueUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is NewtonMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static TorqueUnit ToStringDefaultUnit { get; set; } = TorqueUnit.NewtonMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(TorqueUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Torque
- ///
- public static Torque MaxValue => new Torque(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Torque
- ///
- public static Torque MinValue => new Torque(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Torque.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Torque.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/VitaminA.Common.g.cs b/Common/GeneratedCode/Quantities/VitaminA.Common.g.cs
deleted file mode 100644
index eaed4be5ac..0000000000
--- a/Common/GeneratedCode/Quantities/VitaminA.Common.g.cs
+++ /dev/null
@@ -1,489 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.
- ///
- // 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 VitaminA : IQuantity
-#else
- public partial struct VitaminA : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly VitaminAUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public VitaminAUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static VitaminA()
- {
- }
-
- ///
- /// Creates the quantity with the given value in the base unit InternationalUnit.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public VitaminA(double internationalunits)
- {
- _value = Convert.ToDouble(internationalunits);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- VitaminA(double numericValue, VitaminAUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit InternationalUnit.
- ///
- /// Value assuming base unit InternationalUnit.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- VitaminA(long internationalunits) : this(Convert.ToDouble(internationalunits), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit InternationalUnit.
- ///
- /// Value assuming base unit InternationalUnit.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- VitaminA(decimal internationalunits) : this(Convert.ToDouble(internationalunits), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.VitaminA;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static VitaminAUnit BaseUnit => VitaminAUnit.InternationalUnit;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the VitaminA quantity.
- ///
- public static VitaminAUnit[] Units { get; } = Enum.GetValues(typeof(VitaminAUnit)).Cast().Except(new VitaminAUnit[]{ VitaminAUnit.Undefined }).ToArray();
-
- ///
- /// Get VitaminA in InternationalUnits.
- ///
- public double InternationalUnits => As(VitaminAUnit.InternationalUnit);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit InternationalUnit.
- ///
- public static VitaminA Zero => new VitaminA(0, BaseUnit);
-
- ///
- /// Get VitaminA from InternationalUnits.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VitaminA FromInternationalUnits(double internationalunits)
-#else
- public static VitaminA FromInternationalUnits(QuantityValue internationalunits)
-#endif
- {
- double value = (double) internationalunits;
- return new VitaminA(value, VitaminAUnit.InternationalUnit);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// VitaminA unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static VitaminA From(double value, VitaminAUnit fromUnit)
-#else
- public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit)
-#endif
- {
- return new VitaminA((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(VitaminAUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is VitaminA)) throw new ArgumentException("Expected type VitaminA.", nameof(obj));
-
- return CompareTo((VitaminA)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(VitaminA other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(VitaminA, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is VitaminA))
- return false;
-
- var objQuantity = (VitaminA)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another VitaminA within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another VitaminA 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.
- [Obsolete("Please use the Equals(VitaminA, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(VitaminA other, VitaminA maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current VitaminA.
- public override int GetHashCode()
- {
- return new { type = typeof(VitaminA), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(VitaminAUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this VitaminA to another VitaminA with the unit representation .
- ///
- /// A VitaminA with the specified unit.
- public VitaminA ToUnit(VitaminAUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new VitaminA(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case VitaminAUnit.InternationalUnit: return _value;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(VitaminAUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case VitaminAUnit.InternationalUnit: return baseUnitValue;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 VitaminA Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 VitaminA result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static VitaminAUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is InternationalUnit
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static VitaminAUnit ToStringDefaultUnit { get; set; } = VitaminAUnit.InternationalUnit;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(VitaminAUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of VitaminA
- ///
- public static VitaminA MaxValue => new VitaminA(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of VitaminA
- ///
- public static VitaminA MinValue => new VitaminA(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => VitaminA.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => VitaminA.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/Volume.Common.g.cs b/Common/GeneratedCode/Quantities/Volume.Common.g.cs
deleted file mode 100644
index 65a8d010b2..0000000000
--- a/Common/GeneratedCode/Quantities/Volume.Common.g.cs
+++ /dev/null
@@ -1,1418 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.
- ///
- // 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 Volume : IQuantity
-#else
- public partial struct Volume : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly VolumeUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public VolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static Volume()
- {
- BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit CubicMeter.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public Volume(double cubicmeters)
- {
- _value = Convert.ToDouble(cubicmeters);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- Volume(double numericValue, VolumeUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeter.
- ///
- /// Value assuming base unit CubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Volume(long cubicmeters) : this(Convert.ToDouble(cubicmeters), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeter.
- ///
- /// Value assuming base unit CubicMeter.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- Volume(decimal cubicmeters) : this(Convert.ToDouble(cubicmeters), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.Volume;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static VolumeUnit BaseUnit => VolumeUnit.CubicMeter;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the Volume quantity.
- ///
- public static VolumeUnit[] Units { get; } = Enum.GetValues(typeof(VolumeUnit)).Cast().Except(new VolumeUnit[]{ VolumeUnit.Undefined }).ToArray();
-
- ///
- /// Get Volume in AuTablespoons.
- ///
- public double AuTablespoons => As(VolumeUnit.AuTablespoon);
-
- ///
- /// Get Volume in Centiliters.
- ///
- public double Centiliters => As(VolumeUnit.Centiliter);
-
- ///
- /// Get Volume in CubicCentimeters.
- ///
- public double CubicCentimeters => As(VolumeUnit.CubicCentimeter);
-
- ///
- /// Get Volume in CubicDecimeters.
- ///
- public double CubicDecimeters => As(VolumeUnit.CubicDecimeter);
-
- ///
- /// Get Volume in CubicFeet.
- ///
- public double CubicFeet => As(VolumeUnit.CubicFoot);
-
- ///
- /// Get Volume in CubicInches.
- ///
- public double CubicInches => As(VolumeUnit.CubicInch);
-
- ///
- /// Get Volume in CubicKilometers.
- ///
- public double CubicKilometers => As(VolumeUnit.CubicKilometer);
-
- ///
- /// Get Volume in CubicMeters.
- ///
- public double CubicMeters => As(VolumeUnit.CubicMeter);
-
- ///
- /// Get Volume in CubicMicrometers.
- ///
- public double CubicMicrometers => As(VolumeUnit.CubicMicrometer);
-
- ///
- /// Get Volume in CubicMiles.
- ///
- public double CubicMiles => As(VolumeUnit.CubicMile);
-
- ///
- /// Get Volume in CubicMillimeters.
- ///
- public double CubicMillimeters => As(VolumeUnit.CubicMillimeter);
-
- ///
- /// Get Volume in CubicYards.
- ///
- public double CubicYards => As(VolumeUnit.CubicYard);
-
- ///
- /// Get Volume in Deciliters.
- ///
- public double Deciliters => As(VolumeUnit.Deciliter);
-
- ///
- /// Get Volume in HectocubicFeet.
- ///
- public double HectocubicFeet => As(VolumeUnit.HectocubicFoot);
-
- ///
- /// Get Volume in HectocubicMeters.
- ///
- public double HectocubicMeters => As(VolumeUnit.HectocubicMeter);
-
- ///
- /// Get Volume in Hectoliters.
- ///
- public double Hectoliters => As(VolumeUnit.Hectoliter);
-
- ///
- /// Get Volume in ImperialBeerBarrels.
- ///
- public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel);
-
- ///
- /// Get Volume in ImperialGallons.
- ///
- public double ImperialGallons => As(VolumeUnit.ImperialGallon);
-
- ///
- /// Get Volume in ImperialOunces.
- ///
- public double ImperialOunces => As(VolumeUnit.ImperialOunce);
-
- ///
- /// Get Volume in KilocubicFeet.
- ///
- public double KilocubicFeet => As(VolumeUnit.KilocubicFoot);
-
- ///
- /// Get Volume in KilocubicMeters.
- ///
- public double KilocubicMeters => As(VolumeUnit.KilocubicMeter);
-
- ///
- /// Get Volume in KiloimperialGallons.
- ///
- public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon);
-
- ///
- /// Get Volume in Kiloliters.
- ///
- public double Kiloliters => As(VolumeUnit.Kiloliter);
-
- ///
- /// Get Volume in KilousGallons.
- ///
- public double KilousGallons => As(VolumeUnit.KilousGallon);
-
- ///
- /// Get Volume in Liters.
- ///
- public double Liters => As(VolumeUnit.Liter);
-
- ///
- /// Get Volume in MegacubicFeet.
- ///
- public double MegacubicFeet => As(VolumeUnit.MegacubicFoot);
-
- ///
- /// Get Volume in MegaimperialGallons.
- ///
- public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon);
-
- ///
- /// Get Volume in MegausGallons.
- ///
- public double MegausGallons => As(VolumeUnit.MegausGallon);
-
- ///
- /// Get Volume in MetricCups.
- ///
- public double MetricCups => As(VolumeUnit.MetricCup);
-
- ///
- /// Get Volume in MetricTeaspoons.
- ///
- public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon);
-
- ///
- /// Get Volume in Microliters.
- ///
- public double Microliters => As(VolumeUnit.Microliter);
-
- ///
- /// Get Volume in Milliliters.
- ///
- public double Milliliters => As(VolumeUnit.Milliliter);
-
- ///
- /// Get Volume in OilBarrels.
- ///
- public double OilBarrels => As(VolumeUnit.OilBarrel);
-
- ///
- /// Get Volume in Tablespoons.
- ///
- [System.Obsolete("Deprecated due to github issue #134, please use UsTablespoon instead")]
- public double Tablespoons => As(VolumeUnit.Tablespoon);
-
- ///
- /// Get Volume in Teaspoons.
- ///
- [System.Obsolete("Deprecated due to github issue #134, please use UsTeaspoon instead")]
- public double Teaspoons => As(VolumeUnit.Teaspoon);
-
- ///
- /// Get Volume in UkTablespoons.
- ///
- public double UkTablespoons => As(VolumeUnit.UkTablespoon);
-
- ///
- /// Get Volume in UsBeerBarrels.
- ///
- public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel);
-
- ///
- /// Get Volume in UsCustomaryCups.
- ///
- public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup);
-
- ///
- /// Get Volume in UsGallons.
- ///
- public double UsGallons => As(VolumeUnit.UsGallon);
-
- ///
- /// Get Volume in UsLegalCups.
- ///
- public double UsLegalCups => As(VolumeUnit.UsLegalCup);
-
- ///
- /// Get Volume in UsOunces.
- ///
- public double UsOunces => As(VolumeUnit.UsOunce);
-
- ///
- /// Get Volume in UsPints.
- ///
- public double UsPints => As(VolumeUnit.UsPint);
-
- ///
- /// Get Volume in UsQuarts.
- ///
- public double UsQuarts => As(VolumeUnit.UsQuart);
-
- ///
- /// Get Volume in UsTablespoons.
- ///
- public double UsTablespoons => As(VolumeUnit.UsTablespoon);
-
- ///
- /// Get Volume in UsTeaspoons.
- ///
- public double UsTeaspoons => As(VolumeUnit.UsTeaspoon);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeter.
- ///
- public static Volume Zero => new Volume(0, BaseUnit);
-
- ///
- /// Get Volume from AuTablespoons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromAuTablespoons(double autablespoons)
-#else
- public static Volume FromAuTablespoons(QuantityValue autablespoons)
-#endif
- {
- double value = (double) autablespoons;
- return new Volume(value, VolumeUnit.AuTablespoon);
- }
-
- ///
- /// Get Volume from Centiliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCentiliters(double centiliters)
-#else
- public static Volume FromCentiliters(QuantityValue centiliters)
-#endif
- {
- double value = (double) centiliters;
- return new Volume(value, VolumeUnit.Centiliter);
- }
-
- ///
- /// Get Volume from CubicCentimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicCentimeters(double cubiccentimeters)
-#else
- public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters)
-#endif
- {
- double value = (double) cubiccentimeters;
- return new Volume(value, VolumeUnit.CubicCentimeter);
- }
-
- ///
- /// Get Volume from CubicDecimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicDecimeters(double cubicdecimeters)
-#else
- public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters)
-#endif
- {
- double value = (double) cubicdecimeters;
- return new Volume(value, VolumeUnit.CubicDecimeter);
- }
-
- ///
- /// Get Volume from CubicFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicFeet(double cubicfeet)
-#else
- public static Volume FromCubicFeet(QuantityValue cubicfeet)
-#endif
- {
- double value = (double) cubicfeet;
- return new Volume(value, VolumeUnit.CubicFoot);
- }
-
- ///
- /// Get Volume from CubicInches.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicInches(double cubicinches)
-#else
- public static Volume FromCubicInches(QuantityValue cubicinches)
-#endif
- {
- double value = (double) cubicinches;
- return new Volume(value, VolumeUnit.CubicInch);
- }
-
- ///
- /// Get Volume from CubicKilometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicKilometers(double cubickilometers)
-#else
- public static Volume FromCubicKilometers(QuantityValue cubickilometers)
-#endif
- {
- double value = (double) cubickilometers;
- return new Volume(value, VolumeUnit.CubicKilometer);
- }
-
- ///
- /// Get Volume from CubicMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicMeters(double cubicmeters)
-#else
- public static Volume FromCubicMeters(QuantityValue cubicmeters)
-#endif
- {
- double value = (double) cubicmeters;
- return new Volume(value, VolumeUnit.CubicMeter);
- }
-
- ///
- /// Get Volume from CubicMicrometers.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicMicrometers(double cubicmicrometers)
-#else
- public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers)
-#endif
- {
- double value = (double) cubicmicrometers;
- return new Volume(value, VolumeUnit.CubicMicrometer);
- }
-
- ///
- /// Get Volume from CubicMiles.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicMiles(double cubicmiles)
-#else
- public static Volume FromCubicMiles(QuantityValue cubicmiles)
-#endif
- {
- double value = (double) cubicmiles;
- return new Volume(value, VolumeUnit.CubicMile);
- }
-
- ///
- /// Get Volume from CubicMillimeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicMillimeters(double cubicmillimeters)
-#else
- public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters)
-#endif
- {
- double value = (double) cubicmillimeters;
- return new Volume(value, VolumeUnit.CubicMillimeter);
- }
-
- ///
- /// Get Volume from CubicYards.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromCubicYards(double cubicyards)
-#else
- public static Volume FromCubicYards(QuantityValue cubicyards)
-#endif
- {
- double value = (double) cubicyards;
- return new Volume(value, VolumeUnit.CubicYard);
- }
-
- ///
- /// Get Volume from Deciliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromDeciliters(double deciliters)
-#else
- public static Volume FromDeciliters(QuantityValue deciliters)
-#endif
- {
- double value = (double) deciliters;
- return new Volume(value, VolumeUnit.Deciliter);
- }
-
- ///
- /// Get Volume from HectocubicFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromHectocubicFeet(double hectocubicfeet)
-#else
- public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet)
-#endif
- {
- double value = (double) hectocubicfeet;
- return new Volume(value, VolumeUnit.HectocubicFoot);
- }
-
- ///
- /// Get Volume from HectocubicMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromHectocubicMeters(double hectocubicmeters)
-#else
- public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters)
-#endif
- {
- double value = (double) hectocubicmeters;
- return new Volume(value, VolumeUnit.HectocubicMeter);
- }
-
- ///
- /// Get Volume from Hectoliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromHectoliters(double hectoliters)
-#else
- public static Volume FromHectoliters(QuantityValue hectoliters)
-#endif
- {
- double value = (double) hectoliters;
- return new Volume(value, VolumeUnit.Hectoliter);
- }
-
- ///
- /// Get Volume from ImperialBeerBarrels.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromImperialBeerBarrels(double imperialbeerbarrels)
-#else
- public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels)
-#endif
- {
- double value = (double) imperialbeerbarrels;
- return new Volume(value, VolumeUnit.ImperialBeerBarrel);
- }
-
- ///
- /// Get Volume from ImperialGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromImperialGallons(double imperialgallons)
-#else
- public static Volume FromImperialGallons(QuantityValue imperialgallons)
-#endif
- {
- double value = (double) imperialgallons;
- return new Volume(value, VolumeUnit.ImperialGallon);
- }
-
- ///
- /// Get Volume from ImperialOunces.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromImperialOunces(double imperialounces)
-#else
- public static Volume FromImperialOunces(QuantityValue imperialounces)
-#endif
- {
- double value = (double) imperialounces;
- return new Volume(value, VolumeUnit.ImperialOunce);
- }
-
- ///
- /// Get Volume from KilocubicFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromKilocubicFeet(double kilocubicfeet)
-#else
- public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet)
-#endif
- {
- double value = (double) kilocubicfeet;
- return new Volume(value, VolumeUnit.KilocubicFoot);
- }
-
- ///
- /// Get Volume from KilocubicMeters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromKilocubicMeters(double kilocubicmeters)
-#else
- public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters)
-#endif
- {
- double value = (double) kilocubicmeters;
- return new Volume(value, VolumeUnit.KilocubicMeter);
- }
-
- ///
- /// Get Volume from KiloimperialGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromKiloimperialGallons(double kiloimperialgallons)
-#else
- public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons)
-#endif
- {
- double value = (double) kiloimperialgallons;
- return new Volume(value, VolumeUnit.KiloimperialGallon);
- }
-
- ///
- /// Get Volume from Kiloliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromKiloliters(double kiloliters)
-#else
- public static Volume FromKiloliters(QuantityValue kiloliters)
-#endif
- {
- double value = (double) kiloliters;
- return new Volume(value, VolumeUnit.Kiloliter);
- }
-
- ///
- /// Get Volume from KilousGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromKilousGallons(double kilousgallons)
-#else
- public static Volume FromKilousGallons(QuantityValue kilousgallons)
-#endif
- {
- double value = (double) kilousgallons;
- return new Volume(value, VolumeUnit.KilousGallon);
- }
-
- ///
- /// Get Volume from Liters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromLiters(double liters)
-#else
- public static Volume FromLiters(QuantityValue liters)
-#endif
- {
- double value = (double) liters;
- return new Volume(value, VolumeUnit.Liter);
- }
-
- ///
- /// Get Volume from MegacubicFeet.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMegacubicFeet(double megacubicfeet)
-#else
- public static Volume FromMegacubicFeet(QuantityValue megacubicfeet)
-#endif
- {
- double value = (double) megacubicfeet;
- return new Volume(value, VolumeUnit.MegacubicFoot);
- }
-
- ///
- /// Get Volume from MegaimperialGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMegaimperialGallons(double megaimperialgallons)
-#else
- public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons)
-#endif
- {
- double value = (double) megaimperialgallons;
- return new Volume(value, VolumeUnit.MegaimperialGallon);
- }
-
- ///
- /// Get Volume from MegausGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMegausGallons(double megausgallons)
-#else
- public static Volume FromMegausGallons(QuantityValue megausgallons)
-#endif
- {
- double value = (double) megausgallons;
- return new Volume(value, VolumeUnit.MegausGallon);
- }
-
- ///
- /// Get Volume from MetricCups.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMetricCups(double metriccups)
-#else
- public static Volume FromMetricCups(QuantityValue metriccups)
-#endif
- {
- double value = (double) metriccups;
- return new Volume(value, VolumeUnit.MetricCup);
- }
-
- ///
- /// Get Volume from MetricTeaspoons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMetricTeaspoons(double metricteaspoons)
-#else
- public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons)
-#endif
- {
- double value = (double) metricteaspoons;
- return new Volume(value, VolumeUnit.MetricTeaspoon);
- }
-
- ///
- /// Get Volume from Microliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMicroliters(double microliters)
-#else
- public static Volume FromMicroliters(QuantityValue microliters)
-#endif
- {
- double value = (double) microliters;
- return new Volume(value, VolumeUnit.Microliter);
- }
-
- ///
- /// Get Volume from Milliliters.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromMilliliters(double milliliters)
-#else
- public static Volume FromMilliliters(QuantityValue milliliters)
-#endif
- {
- double value = (double) milliliters;
- return new Volume(value, VolumeUnit.Milliliter);
- }
-
- ///
- /// Get Volume from OilBarrels.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromOilBarrels(double oilbarrels)
-#else
- public static Volume FromOilBarrels(QuantityValue oilbarrels)
-#endif
- {
- double value = (double) oilbarrels;
- return new Volume(value, VolumeUnit.OilBarrel);
- }
-
- ///
- /// Get Volume from Tablespoons.
- ///
- [System.Obsolete("Deprecated due to github issue #134, please use UsTablespoon instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromTablespoons(double tablespoons)
-#else
- public static Volume FromTablespoons(QuantityValue tablespoons)
-#endif
- {
- double value = (double) tablespoons;
- return new Volume(value, VolumeUnit.Tablespoon);
- }
-
- ///
- /// Get Volume from Teaspoons.
- ///
- [System.Obsolete("Deprecated due to github issue #134, please use UsTeaspoon instead")]
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromTeaspoons(double teaspoons)
-#else
- public static Volume FromTeaspoons(QuantityValue teaspoons)
-#endif
- {
- double value = (double) teaspoons;
- return new Volume(value, VolumeUnit.Teaspoon);
- }
-
- ///
- /// Get Volume from UkTablespoons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUkTablespoons(double uktablespoons)
-#else
- public static Volume FromUkTablespoons(QuantityValue uktablespoons)
-#endif
- {
- double value = (double) uktablespoons;
- return new Volume(value, VolumeUnit.UkTablespoon);
- }
-
- ///
- /// Get Volume from UsBeerBarrels.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsBeerBarrels(double usbeerbarrels)
-#else
- public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels)
-#endif
- {
- double value = (double) usbeerbarrels;
- return new Volume(value, VolumeUnit.UsBeerBarrel);
- }
-
- ///
- /// Get Volume from UsCustomaryCups.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsCustomaryCups(double uscustomarycups)
-#else
- public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups)
-#endif
- {
- double value = (double) uscustomarycups;
- return new Volume(value, VolumeUnit.UsCustomaryCup);
- }
-
- ///
- /// Get Volume from UsGallons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsGallons(double usgallons)
-#else
- public static Volume FromUsGallons(QuantityValue usgallons)
-#endif
- {
- double value = (double) usgallons;
- return new Volume(value, VolumeUnit.UsGallon);
- }
-
- ///
- /// Get Volume from UsLegalCups.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsLegalCups(double uslegalcups)
-#else
- public static Volume FromUsLegalCups(QuantityValue uslegalcups)
-#endif
- {
- double value = (double) uslegalcups;
- return new Volume(value, VolumeUnit.UsLegalCup);
- }
-
- ///
- /// Get Volume from UsOunces.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsOunces(double usounces)
-#else
- public static Volume FromUsOunces(QuantityValue usounces)
-#endif
- {
- double value = (double) usounces;
- return new Volume(value, VolumeUnit.UsOunce);
- }
-
- ///
- /// Get Volume from UsPints.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsPints(double uspints)
-#else
- public static Volume FromUsPints(QuantityValue uspints)
-#endif
- {
- double value = (double) uspints;
- return new Volume(value, VolumeUnit.UsPint);
- }
-
- ///
- /// Get Volume from UsQuarts.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsQuarts(double usquarts)
-#else
- public static Volume FromUsQuarts(QuantityValue usquarts)
-#endif
- {
- double value = (double) usquarts;
- return new Volume(value, VolumeUnit.UsQuart);
- }
-
- ///
- /// Get Volume from UsTablespoons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsTablespoons(double ustablespoons)
-#else
- public static Volume FromUsTablespoons(QuantityValue ustablespoons)
-#endif
- {
- double value = (double) ustablespoons;
- return new Volume(value, VolumeUnit.UsTablespoon);
- }
-
- ///
- /// Get Volume from UsTeaspoons.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static Volume FromUsTeaspoons(double usteaspoons)
-#else
- public static Volume FromUsTeaspoons(QuantityValue usteaspoons)
-#endif
- {
- double value = (double) usteaspoons;
- return new Volume(value, VolumeUnit.UsTeaspoon);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// Volume unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static Volume From(double value, VolumeUnit fromUnit)
-#else
- public static Volume From(QuantityValue value, VolumeUnit fromUnit)
-#endif
- {
- return new Volume((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(VolumeUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is Volume)) throw new ArgumentException("Expected type Volume.", nameof(obj));
-
- return CompareTo((Volume)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(Volume other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(Volume, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is Volume))
- return false;
-
- var objQuantity = (Volume)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another Volume within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(Volume other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another Volume 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.
- [Obsolete("Please use the Equals(Volume, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(Volume other, Volume maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current Volume.
- public override int GetHashCode()
- {
- return new { type = typeof(Volume), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(VolumeUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this Volume to another Volume with the unit representation .
- ///
- /// A Volume with the specified unit.
- public Volume ToUnit(VolumeUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new Volume(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case VolumeUnit.AuTablespoon: return _value*2e-5;
- case VolumeUnit.Centiliter: return (_value/1e3) * 1e-2d;
- case VolumeUnit.CubicCentimeter: return _value/1e6;
- case VolumeUnit.CubicDecimeter: return _value/1e3;
- case VolumeUnit.CubicFoot: return _value*0.0283168;
- case VolumeUnit.CubicInch: return _value*1.6387*1e-5;
- case VolumeUnit.CubicKilometer: return _value*1e9;
- case VolumeUnit.CubicMeter: return _value;
- case VolumeUnit.CubicMicrometer: return _value/1e18;
- case VolumeUnit.CubicMile: return _value*4.16818182544058e9;
- case VolumeUnit.CubicMillimeter: return _value/1e9;
- case VolumeUnit.CubicYard: return _value*0.764554858;
- case VolumeUnit.Deciliter: return (_value/1e3) * 1e-1d;
- case VolumeUnit.HectocubicFoot: return (_value*0.0283168) * 1e2d;
- case VolumeUnit.HectocubicMeter: return (_value) * 1e2d;
- case VolumeUnit.Hectoliter: return (_value/1e3) * 1e2d;
- case VolumeUnit.ImperialBeerBarrel: return _value*0.16365924;
- case VolumeUnit.ImperialGallon: return _value*0.00454609000000181429905810072407;
- case VolumeUnit.ImperialOunce: return _value*2.8413062499962901241875439064617e-5;
- case VolumeUnit.KilocubicFoot: return (_value*0.0283168) * 1e3d;
- case VolumeUnit.KilocubicMeter: return (_value) * 1e3d;
- case VolumeUnit.KiloimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e3d;
- case VolumeUnit.Kiloliter: return (_value/1e3) * 1e3d;
- case VolumeUnit.KilousGallon: return (_value*0.00378541) * 1e3d;
- case VolumeUnit.Liter: return _value/1e3;
- case VolumeUnit.MegacubicFoot: return (_value*0.0283168) * 1e6d;
- case VolumeUnit.MegaimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e6d;
- case VolumeUnit.MegausGallon: return (_value*0.00378541) * 1e6d;
- case VolumeUnit.MetricCup: return _value*0.00025;
- case VolumeUnit.MetricTeaspoon: return _value*0.5e-5;
- case VolumeUnit.Microliter: return (_value/1e3) * 1e-6d;
- case VolumeUnit.Milliliter: return (_value/1e3) * 1e-3d;
- case VolumeUnit.OilBarrel: return _value*0.158987294928;
- case VolumeUnit.Tablespoon: return _value*1.478676478125e-5;
- case VolumeUnit.Teaspoon: return _value*4.92892159375e-6;
- case VolumeUnit.UkTablespoon: return _value*1.5e-5;
- case VolumeUnit.UsBeerBarrel: return _value*0.1173477658;
- case VolumeUnit.UsCustomaryCup: return _value*0.0002365882365;
- case VolumeUnit.UsGallon: return _value*0.00378541;
- case VolumeUnit.UsLegalCup: return _value*0.00024;
- case VolumeUnit.UsOunce: return _value*2.957352956253760505068307980135e-5;
- case VolumeUnit.UsPint: return _value*4.73176473e-4;
- case VolumeUnit.UsQuart: return _value*9.46352946e-4;
- case VolumeUnit.UsTablespoon: return _value*1.478676478125e-5;
- case VolumeUnit.UsTeaspoon: return _value*4.92892159375e-6;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(VolumeUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case VolumeUnit.AuTablespoon: return baseUnitValue/2e-5;
- case VolumeUnit.Centiliter: return (baseUnitValue*1e3) / 1e-2d;
- case VolumeUnit.CubicCentimeter: return baseUnitValue*1e6;
- case VolumeUnit.CubicDecimeter: return baseUnitValue*1e3;
- case VolumeUnit.CubicFoot: return baseUnitValue/0.0283168;
- case VolumeUnit.CubicInch: return baseUnitValue/(1.6387*1e-5);
- case VolumeUnit.CubicKilometer: return baseUnitValue/1e9;
- case VolumeUnit.CubicMeter: return baseUnitValue;
- case VolumeUnit.CubicMicrometer: return baseUnitValue*1e18;
- case VolumeUnit.CubicMile: return baseUnitValue/4.16818182544058e9;
- case VolumeUnit.CubicMillimeter: return baseUnitValue*1e9;
- case VolumeUnit.CubicYard: return baseUnitValue/0.764554858;
- case VolumeUnit.Deciliter: return (baseUnitValue*1e3) / 1e-1d;
- case VolumeUnit.HectocubicFoot: return (baseUnitValue/0.0283168) / 1e2d;
- case VolumeUnit.HectocubicMeter: return (baseUnitValue) / 1e2d;
- case VolumeUnit.Hectoliter: return (baseUnitValue*1e3) / 1e2d;
- case VolumeUnit.ImperialBeerBarrel: return baseUnitValue/0.16365924;
- case VolumeUnit.ImperialGallon: return baseUnitValue/0.00454609000000181429905810072407;
- case VolumeUnit.ImperialOunce: return baseUnitValue/2.8413062499962901241875439064617e-5;
- case VolumeUnit.KilocubicFoot: return (baseUnitValue/0.0283168) / 1e3d;
- case VolumeUnit.KilocubicMeter: return (baseUnitValue) / 1e3d;
- case VolumeUnit.KiloimperialGallon: return (baseUnitValue/0.00454609000000181429905810072407) / 1e3d;
- case VolumeUnit.Kiloliter: return (baseUnitValue*1e3) / 1e3d;
- case VolumeUnit.KilousGallon: return (baseUnitValue/0.00378541) / 1e3d;
- case VolumeUnit.Liter: return baseUnitValue*1e3;
- case VolumeUnit.MegacubicFoot: return (baseUnitValue/0.0283168) / 1e6d;
- case VolumeUnit.MegaimperialGallon: return (baseUnitValue/0.00454609000000181429905810072407) / 1e6d;
- case VolumeUnit.MegausGallon: return (baseUnitValue/0.00378541) / 1e6d;
- case VolumeUnit.MetricCup: return baseUnitValue/0.00025;
- case VolumeUnit.MetricTeaspoon: return baseUnitValue/0.5e-5;
- case VolumeUnit.Microliter: return (baseUnitValue*1e3) / 1e-6d;
- case VolumeUnit.Milliliter: return (baseUnitValue*1e3) / 1e-3d;
- case VolumeUnit.OilBarrel: return baseUnitValue/0.158987294928;
- case VolumeUnit.Tablespoon: return baseUnitValue/1.478676478125e-5;
- case VolumeUnit.Teaspoon: return baseUnitValue/4.92892159375e-6;
- case VolumeUnit.UkTablespoon: return baseUnitValue/1.5e-5;
- case VolumeUnit.UsBeerBarrel: return baseUnitValue/0.1173477658;
- case VolumeUnit.UsCustomaryCup: return baseUnitValue/0.0002365882365;
- case VolumeUnit.UsGallon: return baseUnitValue/0.00378541;
- case VolumeUnit.UsLegalCup: return baseUnitValue/0.00024;
- case VolumeUnit.UsOunce: return baseUnitValue/2.957352956253760505068307980135e-5;
- case VolumeUnit.UsPint: return baseUnitValue/4.73176473e-4;
- case VolumeUnit.UsQuart: return baseUnitValue/9.46352946e-4;
- case VolumeUnit.UsTablespoon: return baseUnitValue/1.478676478125e-5;
- case VolumeUnit.UsTeaspoon: return baseUnitValue/4.92892159375e-6;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 Volume Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 Volume result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static VolumeUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is CubicMeter
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static VolumeUnit ToStringDefaultUnit { get; set; } = VolumeUnit.CubicMeter;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(VolumeUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of Volume
- ///
- public static Volume MaxValue => new Volume(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of Volume
- ///
- public static Volume MinValue => new Volume(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => Volume.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => Volume.BaseDimensions;
- }
-}
diff --git a/Common/GeneratedCode/Quantities/VolumeFlow.Common.g.cs b/Common/GeneratedCode/Quantities/VolumeFlow.Common.g.cs
deleted file mode 100644
index d585adc5ac..0000000000
--- a/Common/GeneratedCode/Quantities/VolumeFlow.Common.g.cs
+++ /dev/null
@@ -1,1057 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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;
-
-// ReSharper disable once CheckNamespace
-
-namespace UnitsNet
-{
- ///
- /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.
- ///
- // 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 VolumeFlow : IQuantity
-#else
- public partial struct VolumeFlow : IQuantity, IComparable, IComparable
-#endif
- {
- ///
- /// The numeric value this quantity was constructed with.
- ///
- private readonly double _value;
-
- ///
- /// The unit this quantity was constructed with.
- ///
- private readonly VolumeFlowUnit? _unit;
-
- ///
- /// The unit this quantity was constructed with -or- if default ctor was used.
- ///
- public VolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit);
-
- static VolumeFlow()
- {
- BaseDimensions = new BaseDimensions(3, 0, -1, 0, 0, 0, 0);
- }
-
- ///
- /// Creates the quantity with the given value in the base unit CubicMeterPerSecond.
- ///
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public VolumeFlow(double cubicmeterspersecond)
- {
- _value = Convert.ToDouble(cubicmeterspersecond);
- _unit = BaseUnit;
- }
-
- ///
- /// Creates the quantity with the given numeric value and unit.
- ///
- /// Numeric value.
- /// Unit representation.
- /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component.
-#if WINDOWS_UWP
- private
-#else
- public
-#endif
- VolumeFlow(double numericValue, VolumeFlowUnit unit)
- {
- _value = numericValue;
- _unit = unit;
- }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerSecond.
- ///
- /// Value assuming base unit CubicMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- VolumeFlow(long cubicmeterspersecond) : this(Convert.ToDouble(cubicmeterspersecond), BaseUnit) { }
-
- // 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
- ///
- /// Creates the quantity with the given value assuming the base unit CubicMeterPerSecond.
- ///
- /// Value assuming base unit CubicMeterPerSecond.
-#if WINDOWS_UWP
- private
-#else
- [Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
- public
-#endif
- VolumeFlow(decimal cubicmeterspersecond) : this(Convert.ToDouble(cubicmeterspersecond), BaseUnit) { }
-
- #region Properties
-
- ///
- /// The of this quantity.
- ///
- public static QuantityType QuantityType => QuantityType.VolumeFlow;
-
- ///
- /// The base unit representation of this quantity for the numeric value stored internally. All conversions go via this value.
- ///
- public static VolumeFlowUnit BaseUnit => VolumeFlowUnit.CubicMeterPerSecond;
-
- ///
- /// The of this quantity.
- ///
- public static BaseDimensions BaseDimensions
- {
- get;
- }
-
- ///
- /// All units of measurement for the VolumeFlow quantity.
- ///
- public static VolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().Except(new VolumeFlowUnit[]{ VolumeFlowUnit.Undefined }).ToArray();
-
- ///
- /// Get VolumeFlow in CentilitersPerMinute.
- ///
- public double CentilitersPerMinute => As(VolumeFlowUnit.CentilitersPerMinute);
-
- ///
- /// Get VolumeFlow in CubicDecimetersPerMinute.
- ///
- public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute);
-
- ///
- /// Get VolumeFlow in CubicFeetPerHour.
- ///
- public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour);
-
- ///
- /// Get VolumeFlow in CubicFeetPerMinute.
- ///
- public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute);
-
- ///
- /// Get VolumeFlow in CubicFeetPerSecond.
- ///
- public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond);
-
- ///
- /// Get VolumeFlow in CubicMetersPerHour.
- ///
- public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour);
-
- ///
- /// Get VolumeFlow in CubicMetersPerMinute.
- ///
- public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute);
-
- ///
- /// Get VolumeFlow in CubicMetersPerSecond.
- ///
- public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond);
-
- ///
- /// Get VolumeFlow in CubicMillimetersPerSecond.
- ///
- public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond);
-
- ///
- /// Get VolumeFlow in CubicYardsPerHour.
- ///
- public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour);
-
- ///
- /// Get VolumeFlow in CubicYardsPerMinute.
- ///
- public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute);
-
- ///
- /// Get VolumeFlow in CubicYardsPerSecond.
- ///
- public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond);
-
- ///
- /// Get VolumeFlow in DecilitersPerMinute.
- ///
- public double DecilitersPerMinute => As(VolumeFlowUnit.DecilitersPerMinute);
-
- ///
- /// Get VolumeFlow in KilolitersPerMinute.
- ///
- public double KilolitersPerMinute => As(VolumeFlowUnit.KilolitersPerMinute);
-
- ///
- /// Get VolumeFlow in KilousGallonsPerMinute.
- ///
- public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonsPerMinute);
-
- ///
- /// Get VolumeFlow in LitersPerHour.
- ///
- public double LitersPerHour => As(VolumeFlowUnit.LitersPerHour);
-
- ///
- /// Get VolumeFlow in LitersPerMinute.
- ///
- public double LitersPerMinute => As(VolumeFlowUnit.LitersPerMinute);
-
- ///
- /// Get VolumeFlow in LitersPerSecond.
- ///
- public double LitersPerSecond => As(VolumeFlowUnit.LitersPerSecond);
-
- ///
- /// Get VolumeFlow in MicrolitersPerMinute.
- ///
- public double MicrolitersPerMinute => As(VolumeFlowUnit.MicrolitersPerMinute);
-
- ///
- /// Get VolumeFlow in MillilitersPerMinute.
- ///
- public double MillilitersPerMinute => As(VolumeFlowUnit.MillilitersPerMinute);
-
- ///
- /// Get VolumeFlow in MillionUsGallonsPerDay.
- ///
- public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay);
-
- ///
- /// Get VolumeFlow in NanolitersPerMinute.
- ///
- public double NanolitersPerMinute => As(VolumeFlowUnit.NanolitersPerMinute);
-
- ///
- /// Get VolumeFlow in OilBarrelsPerDay.
- ///
- public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelsPerDay);
-
- ///
- /// Get VolumeFlow in OilBarrelsPerHour.
- ///
- public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelsPerHour);
-
- ///
- /// Get VolumeFlow in OilBarrelsPerMinute.
- ///
- public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelsPerMinute);
-
- ///
- /// Get VolumeFlow in UsGallonsPerHour.
- ///
- public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonsPerHour);
-
- ///
- /// Get VolumeFlow in UsGallonsPerMinute.
- ///
- public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonsPerMinute);
-
- ///
- /// Get VolumeFlow in UsGallonsPerSecond.
- ///
- public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonsPerSecond);
-
- #endregion
-
- #region Static
-
- ///
- /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond.
- ///
- public static VolumeFlow Zero => new VolumeFlow(0, BaseUnit);
-
- ///
- /// Get VolumeFlow from CentilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCentilitersPerMinute(double centilitersperminute)
-#else
- public static VolumeFlow FromCentilitersPerMinute(QuantityValue centilitersperminute)
-#endif
- {
- double value = (double) centilitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.CentilitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from CubicDecimetersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicDecimetersPerMinute(double cubicdecimetersperminute)
-#else
- public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimetersperminute)
-#endif
- {
- double value = (double) cubicdecimetersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute);
- }
-
- ///
- /// Get VolumeFlow from CubicFeetPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicFeetPerHour(double cubicfeetperhour)
-#else
- public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour)
-#endif
- {
- double value = (double) cubicfeetperhour;
- return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour);
- }
-
- ///
- /// Get VolumeFlow from CubicFeetPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicFeetPerMinute(double cubicfeetperminute)
-#else
- public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute)
-#endif
- {
- double value = (double) cubicfeetperminute;
- return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute);
- }
-
- ///
- /// Get VolumeFlow from CubicFeetPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicFeetPerSecond(double cubicfeetpersecond)
-#else
- public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond)
-#endif
- {
- double value = (double) cubicfeetpersecond;
- return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond);
- }
-
- ///
- /// Get VolumeFlow from CubicMetersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicMetersPerHour(double cubicmetersperhour)
-#else
- public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour)
-#endif
- {
- double value = (double) cubicmetersperhour;
- return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour);
- }
-
- ///
- /// Get VolumeFlow from CubicMetersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicMetersPerMinute(double cubicmetersperminute)
-#else
- public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmetersperminute)
-#endif
- {
- double value = (double) cubicmetersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute);
- }
-
- ///
- /// Get VolumeFlow from CubicMetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicMetersPerSecond(double cubicmeterspersecond)
-#else
- public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmeterspersecond)
-#endif
- {
- double value = (double) cubicmeterspersecond;
- return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond);
- }
-
- ///
- /// Get VolumeFlow from CubicMillimetersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicMillimetersPerSecond(double cubicmillimeterspersecond)
-#else
- public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillimeterspersecond)
-#endif
- {
- double value = (double) cubicmillimeterspersecond;
- return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond);
- }
-
- ///
- /// Get VolumeFlow from CubicYardsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicYardsPerHour(double cubicyardsperhour)
-#else
- public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour)
-#endif
- {
- double value = (double) cubicyardsperhour;
- return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour);
- }
-
- ///
- /// Get VolumeFlow from CubicYardsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicYardsPerMinute(double cubicyardsperminute)
-#else
- public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminute)
-#endif
- {
- double value = (double) cubicyardsperminute;
- return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute);
- }
-
- ///
- /// Get VolumeFlow from CubicYardsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromCubicYardsPerSecond(double cubicyardspersecond)
-#else
- public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardspersecond)
-#endif
- {
- double value = (double) cubicyardspersecond;
- return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond);
- }
-
- ///
- /// Get VolumeFlow from DecilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromDecilitersPerMinute(double decilitersperminute)
-#else
- public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminute)
-#endif
- {
- double value = (double) decilitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.DecilitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from KilolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromKilolitersPerMinute(double kilolitersperminute)
-#else
- public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminute)
-#endif
- {
- double value = (double) kilolitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.KilolitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from KilousGallonsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromKilousGallonsPerMinute(double kilousgallonsperminute)
-#else
- public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsperminute)
-#endif
- {
- double value = (double) kilousgallonsperminute;
- return new VolumeFlow(value, VolumeFlowUnit.KilousGallonsPerMinute);
- }
-
- ///
- /// Get VolumeFlow from LitersPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromLitersPerHour(double litersperhour)
-#else
- public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour)
-#endif
- {
- double value = (double) litersperhour;
- return new VolumeFlow(value, VolumeFlowUnit.LitersPerHour);
- }
-
- ///
- /// Get VolumeFlow from LitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromLitersPerMinute(double litersperminute)
-#else
- public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute)
-#endif
- {
- double value = (double) litersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.LitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from LitersPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromLitersPerSecond(double literspersecond)
-#else
- public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond)
-#endif
- {
- double value = (double) literspersecond;
- return new VolumeFlow(value, VolumeFlowUnit.LitersPerSecond);
- }
-
- ///
- /// Get VolumeFlow from MicrolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromMicrolitersPerMinute(double microlitersperminute)
-#else
- public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microlitersperminute)
-#endif
- {
- double value = (double) microlitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.MicrolitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from MillilitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromMillilitersPerMinute(double millilitersperminute)
-#else
- public static VolumeFlow FromMillilitersPerMinute(QuantityValue millilitersperminute)
-#endif
- {
- double value = (double) millilitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.MillilitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from MillionUsGallonsPerDay.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromMillionUsGallonsPerDay(double millionusgallonsperday)
-#else
- public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday)
-#endif
- {
- double value = (double) millionusgallonsperday;
- return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonsPerDay);
- }
-
- ///
- /// Get VolumeFlow from NanolitersPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromNanolitersPerMinute(double nanolitersperminute)
-#else
- public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminute)
-#endif
- {
- double value = (double) nanolitersperminute;
- return new VolumeFlow(value, VolumeFlowUnit.NanolitersPerMinute);
- }
-
- ///
- /// Get VolumeFlow from OilBarrelsPerDay.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromOilBarrelsPerDay(double oilbarrelsperday)
-#else
- public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday)
-#endif
- {
- double value = (double) oilbarrelsperday;
- return new VolumeFlow(value, VolumeFlowUnit.OilBarrelsPerDay);
- }
-
- ///
- /// Get VolumeFlow from OilBarrelsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromOilBarrelsPerHour(double oilbarrelsperhour)
-#else
- public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour)
-#endif
- {
- double value = (double) oilbarrelsperhour;
- return new VolumeFlow(value, VolumeFlowUnit.OilBarrelsPerHour);
- }
-
- ///
- /// Get VolumeFlow from OilBarrelsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromOilBarrelsPerMinute(double oilbarrelsperminute)
-#else
- public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminute)
-#endif
- {
- double value = (double) oilbarrelsperminute;
- return new VolumeFlow(value, VolumeFlowUnit.OilBarrelsPerMinute);
- }
-
- ///
- /// Get VolumeFlow from UsGallonsPerHour.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromUsGallonsPerHour(double usgallonsperhour)
-#else
- public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour)
-#endif
- {
- double value = (double) usgallonsperhour;
- return new VolumeFlow(value, VolumeFlowUnit.UsGallonsPerHour);
- }
-
- ///
- /// Get VolumeFlow from UsGallonsPerMinute.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromUsGallonsPerMinute(double usgallonsperminute)
-#else
- public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute)
-#endif
- {
- double value = (double) usgallonsperminute;
- return new VolumeFlow(value, VolumeFlowUnit.UsGallonsPerMinute);
- }
-
- ///
- /// Get VolumeFlow from UsGallonsPerSecond.
- ///
-#if WINDOWS_UWP
- [Windows.Foundation.Metadata.DefaultOverload]
- public static VolumeFlow FromUsGallonsPerSecond(double usgallonspersecond)
-#else
- public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond)
-#endif
- {
- double value = (double) usgallonspersecond;
- return new VolumeFlow(value, VolumeFlowUnit.UsGallonsPerSecond);
- }
-
-
- ///
- /// Dynamically convert from value and unit enum to .
- ///
- /// Value to convert from.
- /// Unit to convert from.
- /// VolumeFlow unit value.
-#if WINDOWS_UWP
- // Fix name conflict with parameter "value"
- [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")]
- public static VolumeFlow From(double value, VolumeFlowUnit fromUnit)
-#else
- public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit)
-#endif
- {
- return new VolumeFlow((double)value, fromUnit);
- }
-
- ///
- /// Get unit abbreviation string.
- ///
- /// Unit to get abbreviation for.
- /// Unit abbreviation string.
- [UsedImplicitly]
- public static string GetAbbreviation(VolumeFlowUnit unit)
- {
- return GetAbbreviation(unit, null);
- }
-
- #endregion
-
- #region Equality / IComparable
-
- public int CompareTo(object obj)
- {
- if(obj is null) throw new ArgumentNullException(nameof(obj));
- if(!(obj is VolumeFlow)) throw new ArgumentException("Expected type VolumeFlow.", nameof(obj));
-
- return CompareTo((VolumeFlow)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(VolumeFlow other)
- {
- return _value.CompareTo(other.AsBaseNumericType(this.Unit));
- }
-
- [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(VolumeFlow, double, ComparisonType) to provide the max allowed absolute or relative error.")]
- public override bool Equals(object obj)
- {
- if(obj is null || !(obj is VolumeFlow))
- return false;
-
- var objQuantity = (VolumeFlow)obj;
- return _value.Equals(objQuantity.AsBaseNumericType(this.Unit));
- }
-
- ///
- ///
- /// Compare equality to another VolumeFlow within the given absolute or relative tolerance.
- ///
- ///
- /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a percentage of this quantity's value. will be converted into
- /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
- /// this quantity's value to be considered equal.
- ///
- /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Relative);
- ///
- ///
- ///
- ///
- /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
- /// as a fixed number in this quantity's unit. will be converted into
- /// this quantity's unit for comparison.
- ///
- /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
- ///
- /// var a = Length.FromMeters(2.0);
- /// var b = Length.FromInches(50.0);
- /// a.Equals(b, 0.01, ComparisonType.Absolute);
- ///
- ///
- ///
- ///
- /// Note that it is advised against specifying zero difference, due to the nature
- /// of floating point operations and using System.Double internally.
- ///
- ///
- /// The other quantity to compare to.
- /// The absolute or relative tolerance value. Must be greater than or equal to 0.
- /// The comparison type: either relative or absolute.
- /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
- public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType)
- {
- if(tolerance < 0)
- throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
-
- double thisValue = (double)this.Value;
- double otherValueInThisUnits = other.As(this.Unit);
-
- return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType);
- }
-
- ///
- /// Compare equality to another VolumeFlow 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.
- [Obsolete("Please use the Equals(VolumeFlow, double, ComparisonType) overload. This method will be removed in a future version.")]
- public bool Equals(VolumeFlow other, VolumeFlow maxError)
- {
- return Math.Abs(_value - other.AsBaseNumericType(this.Unit)) <= maxError.AsBaseNumericType(this.Unit);
- }
-
- ///
- /// Returns the hash code for this instance.
- ///
- /// A hash code for the current VolumeFlow.
- public override int GetHashCode()
- {
- return new { type = typeof(VolumeFlow), Value, Unit }.GetHashCode();
- }
-
- #endregion
-
- #region Conversion
-
- ///
- /// Convert to the unit representation .
- ///
- /// Value converted to the specified unit.
- public double As(VolumeFlowUnit unit)
- {
- if(Unit == unit)
- return Convert.ToDouble(Value);
-
- var converted = AsBaseNumericType(unit);
- return Convert.ToDouble(converted);
- }
-
- ///
- /// Converts this VolumeFlow to another VolumeFlow with the unit representation .
- ///
- /// A VolumeFlow with the specified unit.
- public VolumeFlow ToUnit(VolumeFlowUnit unit)
- {
- var convertedValue = AsBaseNumericType(unit);
- return new VolumeFlow(convertedValue, unit);
- }
-
- ///
- /// Converts the current value + unit to the base unit.
- /// This is typically the first step in converting from one unit to another.
- ///
- /// The value in the base unit representation.
- private double AsBaseUnit()
- {
- switch(Unit)
- {
- case VolumeFlowUnit.CentilitersPerMinute: return (_value/60000.00000) * 1e-2d;
- case VolumeFlowUnit.CubicDecimeterPerMinute: return _value/60000.00000;
- case VolumeFlowUnit.CubicFootPerHour: return _value*7.8657907199999087346816086183876e-6;
- case VolumeFlowUnit.CubicFootPerMinute: return _value/2118.88000326;
- case VolumeFlowUnit.CubicFootPerSecond: return _value/35.314666721;
- case VolumeFlowUnit.CubicMeterPerHour: return _value/3600;
- case VolumeFlowUnit.CubicMeterPerMinute: return _value/60;
- case VolumeFlowUnit.CubicMeterPerSecond: return _value;
- case VolumeFlowUnit.CubicMillimeterPerSecond: return _value*1e-9;
- case VolumeFlowUnit.CubicYardPerHour: return _value*2.1237634944E-4;
- case VolumeFlowUnit.CubicYardPerMinute: return _value*0.0127425809664;
- case VolumeFlowUnit.CubicYardPerSecond: return _value*0.764554857984;
- case VolumeFlowUnit.DecilitersPerMinute: return (_value/60000.00000) * 1e-1d;
- case VolumeFlowUnit.KilolitersPerMinute: return (_value/60000.00000) * 1e3d;
- case VolumeFlowUnit.KilousGallonsPerMinute: return _value/15.850323141489;
- case VolumeFlowUnit.LitersPerHour: return _value/3600000.000;
- case VolumeFlowUnit.LitersPerMinute: return _value/60000.00000;
- case VolumeFlowUnit.LitersPerSecond: return _value/1000;
- case VolumeFlowUnit.MicrolitersPerMinute: return (_value/60000.00000) * 1e-6d;
- case VolumeFlowUnit.MillilitersPerMinute: return (_value/60000.00000) * 1e-3d;
- case VolumeFlowUnit.MillionUsGallonsPerDay: return _value/22.824465227;
- case VolumeFlowUnit.NanolitersPerMinute: return (_value/60000.00000) * 1e-9d;
- case VolumeFlowUnit.OilBarrelsPerDay: return _value*1.8401307283333333333333333333333e-6;
- case VolumeFlowUnit.OilBarrelsPerHour: return _value*4.41631375e-5;
- case VolumeFlowUnit.OilBarrelsPerMinute: return _value*2.64978825e-3;
- case VolumeFlowUnit.UsGallonsPerHour: return _value/951019.38848933424;
- case VolumeFlowUnit.UsGallonsPerMinute: return _value/15850.323141489;
- case VolumeFlowUnit.UsGallonsPerSecond: return _value/264.1720523581484;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to base units.");
- }
- }
-
- private double AsBaseNumericType(VolumeFlowUnit unit)
- {
- if(Unit == unit)
- return _value;
-
- var baseUnitValue = AsBaseUnit();
-
- switch(unit)
- {
- case VolumeFlowUnit.CentilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-2d;
- case VolumeFlowUnit.CubicDecimeterPerMinute: return baseUnitValue*60000.00000;
- case VolumeFlowUnit.CubicFootPerHour: return baseUnitValue/7.8657907199999087346816086183876e-6;
- case VolumeFlowUnit.CubicFootPerMinute: return baseUnitValue*2118.88000326;
- case VolumeFlowUnit.CubicFootPerSecond: return baseUnitValue*35.314666721;
- case VolumeFlowUnit.CubicMeterPerHour: return baseUnitValue*3600;
- case VolumeFlowUnit.CubicMeterPerMinute: return baseUnitValue*60;
- case VolumeFlowUnit.CubicMeterPerSecond: return baseUnitValue;
- case VolumeFlowUnit.CubicMillimeterPerSecond: return baseUnitValue/1e-9;
- case VolumeFlowUnit.CubicYardPerHour: return baseUnitValue/2.1237634944E-4;
- case VolumeFlowUnit.CubicYardPerMinute: return baseUnitValue/0.0127425809664;
- case VolumeFlowUnit.CubicYardPerSecond: return baseUnitValue/0.764554857984;
- case VolumeFlowUnit.DecilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-1d;
- case VolumeFlowUnit.KilolitersPerMinute: return (baseUnitValue*60000.00000) / 1e3d;
- case VolumeFlowUnit.KilousGallonsPerMinute: return baseUnitValue*15.850323141489;
- case VolumeFlowUnit.LitersPerHour: return baseUnitValue*3600000.000;
- case VolumeFlowUnit.LitersPerMinute: return baseUnitValue*60000.00000;
- case VolumeFlowUnit.LitersPerSecond: return baseUnitValue*1000;
- case VolumeFlowUnit.MicrolitersPerMinute: return (baseUnitValue*60000.00000) / 1e-6d;
- case VolumeFlowUnit.MillilitersPerMinute: return (baseUnitValue*60000.00000) / 1e-3d;
- case VolumeFlowUnit.MillionUsGallonsPerDay: return baseUnitValue*22.824465227;
- case VolumeFlowUnit.NanolitersPerMinute: return (baseUnitValue*60000.00000) / 1e-9d;
- case VolumeFlowUnit.OilBarrelsPerDay: return baseUnitValue/1.8401307283333333333333333333333e-6;
- case VolumeFlowUnit.OilBarrelsPerHour: return baseUnitValue/4.41631375e-5;
- case VolumeFlowUnit.OilBarrelsPerMinute: return baseUnitValue/2.64978825e-3;
- case VolumeFlowUnit.UsGallonsPerHour: return baseUnitValue*951019.38848933424;
- case VolumeFlowUnit.UsGallonsPerMinute: return baseUnitValue*15850.323141489;
- case VolumeFlowUnit.UsGallonsPerSecond: return baseUnitValue*264.1720523581484;
- default:
- throw new NotImplementedException($"Can not convert {Unit} to {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 VolumeFlow Parse(string str)
- {
- return Parse(str, null);
- }
-
- ///
- /// 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 VolumeFlow result)
- {
- return TryParse(str, null, out result);
- }
-
- ///
- /// Parse a unit string.
- ///
- /// String to parse. Typically in the form: {number} {unit}
- ///
- /// Length.ParseUnit("m", new CultureInfo("en-US"));
- ///
- /// The value of 'str' cannot be null.
- /// Error parsing string.
- public static VolumeFlowUnit ParseUnit(string str)
- {
- return ParseUnit(str, (IFormatProvider)null);
- }
-
- #endregion
-
- ///
- /// Set the default unit used by ToString(). Default is CubicMeterPerSecond
- ///
- [Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
- public static VolumeFlowUnit ToStringDefaultUnit { get; set; } = VolumeFlowUnit.CubicMeterPerSecond;
-
- ///
- /// Get default string representation of value and unit.
- ///
- /// String representation.
- public override string ToString()
- {
- return ToString(Unit);
- }
-
- ///
- /// 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(VolumeFlowUnit unit)
- {
- return ToString(unit, null, 2);
- }
-
- ///
- /// Represents the largest possible value of VolumeFlow
- ///
- public static VolumeFlow MaxValue => new VolumeFlow(double.MaxValue, BaseUnit);
-
- ///
- /// Represents the smallest possible value of VolumeFlow
- ///
- public static VolumeFlow MinValue => new VolumeFlow(double.MinValue, BaseUnit);
-
- ///
- /// The of this quantity.
- ///
- public QuantityType Type => VolumeFlow.QuantityType;
-
- ///
- /// The of this quantity.
- ///
- public BaseDimensions Dimensions => VolumeFlow.BaseDimensions;
- }
-}
diff --git a/Common/UnitDefinitions/Duration.json b/Common/UnitDefinitions/Duration.json
index ad19f0f063..7343405e0e 100644
--- a/Common/UnitDefinitions/Duration.json
+++ b/Common/UnitDefinitions/Duration.json
@@ -6,23 +6,6 @@
"T": 1
},
"Units": [
- {
- "ObsoleteText": "Use Year365 instead, which makes it clear that this is an approximate unit based on 365 days per year. The duration of a year varies due to corrections such as leap years, since a Gregorian solar calendar has 365.2425 days.",
- "SingularName": "Year",
- "PluralName": "Years",
- "FromUnitToBaseFunc": "x*365*24*3600",
- "FromBaseToUnitFunc": "x/(365*24*3600)",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "yr", "year", "years" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "год" ]
- }
- ]
- },
{
"SingularName": "Year365",
"PluralName": "Years365",
@@ -39,23 +22,6 @@
}
]
},
- {
- "ObsoleteText": "Use Month30 instead, which makes it clear that this is an approximate unit based on 30 days per month. The duration of a month varies, but the Gregorian solar calendar has 365.2425/12 = 30.44 days on average.",
- "SingularName": "Month",
- "PluralName": "Months",
- "FromUnitToBaseFunc": "x*30*24*3600",
- "FromBaseToUnitFunc": "x/(30*24*3600)",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "mo", "month", "months" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "месяц" ]
- }
- ]
- },
{
"SingularName": "Month30",
"PluralName": "Months30",
diff --git a/Common/UnitDefinitions/Flow.json b/Common/UnitDefinitions/Flow.json
deleted file mode 100644
index 2b4918d122..0000000000
--- a/Common/UnitDefinitions/Flow.json
+++ /dev/null
@@ -1,263 +0,0 @@
-{
- "Name": "Flow",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "BaseUnit": "CubicMeterPerSecond",
- "XmlDoc": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.",
- "BaseDimensions": {
- "L": 3,
- "T": -1
- },
- "Units": [
- {
- "SingularName": "CubicMeterPerSecond",
- "PluralName": "CubicMetersPerSecond",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x",
- "FromBaseToUnitFunc": "x",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "m³/s" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "м³/с" ]
- }
- ]
- },
- {
- "SingularName": "CubicMeterPerMinute",
- "PluralName": "CubicMetersPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/60",
- "FromBaseToUnitFunc": "x*60",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "m³/min" ]
- }
- ]
- },
- {
- "SingularName": "CubicMeterPerHour",
- "PluralName": "CubicMetersPerHour",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/3600",
- "FromBaseToUnitFunc": "x*3600",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "m³/h" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "м³/ч" ]
- }
- ]
- },
- {
- "SingularName": "CubicFootPerSecond",
- "PluralName": "CubicFeetPerSecond",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/35.314666721",
- "FromBaseToUnitFunc": "x*35.314666721",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "ft³/s" ]
- }
- ]
- },
- {
- "SingularName": "CubicFootPerMinute",
- "PluralName": "CubicFeetPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/2118.88000326",
- "FromBaseToUnitFunc": "x*2118.88000326",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "ft³/min" ]
- }
- ]
- },
- {
- "SingularName": "CubicFootPerHour",
- "PluralName": "CubicFeetPerHour",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x*7.8657907199999087346816086183876e-6",
- "FromBaseToUnitFunc": "x/7.8657907199999087346816086183876e-6",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "ft³/h", "cf/hr" ]
- }
- ]
- },
- {
- "SingularName": "CubicYardPerSecond",
- "PluralName": "CubicYardsPerSecond",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x*0.764554857984",
- "FromBaseToUnitFunc": "x/0.764554857984",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "yd³/s" ]
- }
- ]
- },
- {
- "SingularName": "CubicYardPerMinute",
- "PluralName": "CubicYardsPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x*0.0127425809664",
- "FromBaseToUnitFunc": "x/0.0127425809664",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "yd³/min" ]
- }
- ]
- },
- {
- "SingularName": "CubicYardPerHour",
- "PluralName": "CubicYardsPerHour",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x*2.1237634944E-4",
- "FromBaseToUnitFunc": "x/2.1237634944E-4",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "yd³/h" ]
- }
- ]
- },
- {
- "SingularName": "MillionUsGallonsPerDay",
- "PluralName": "MillionUsGallonsPerDay",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/22.824465227",
- "FromBaseToUnitFunc": "x*22.824465227",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "MGD" ]
- }
- ]
- },
- {
- "SingularName": "LitersPerSecond",
- "PluralName": "LitersPerSecond",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/1000",
- "FromBaseToUnitFunc": "x*1000",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "LPS" ]
- }
- ]
- },
- {
- "SingularName": "LitersPerMinute",
- "PluralName": "LitersPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/60000.00000",
- "FromBaseToUnitFunc": "x*60000.00000",
- "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "LPM" ]
- }
- ]
- },
- {
- "SingularName": "LitersPerHour",
- "PluralName": "LitersPerHour",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/3600000.000",
- "FromBaseToUnitFunc": "x*3600000.000",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "LPH" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "л/ч" ]
- }
- ]
- },
- {
- "SingularName": "UsGallonsPerSecond",
- "PluralName": "UsGallonsPerSecond",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/264.1720523581484",
- "FromBaseToUnitFunc": "x*264.1720523581484",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "gal (U.S.)/s" ]
- }
- ]
- },
- {
- "SingularName": "UsGallonsPerMinute",
- "PluralName": "UsGallonsPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/15850.323141489",
- "FromBaseToUnitFunc": "x*15850.323141489",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "gal (U.S.)/min", "GPM" ]
- }
- ]
- },
- {
- "SingularName": "UsGallonsPerHour",
- "PluralName": "UsGallonsPerHour",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/951019.38848933424",
- "FromBaseToUnitFunc": "x*951019.38848933424",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "gal (U.S.)/h" ]
- }
- ]
- },
- {
- "SingularName": "CubicDecimeterPerMinute",
- "PluralName": "CubicDecimetersPerMinute",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x/60000.00000",
- "FromBaseToUnitFunc": "x*60000.00000",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "dm³/min" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "дм³/мин" ]
- }
- ]
- },
- {
- "SingularName": "OilBarrelsPerDay",
- "PluralName": "OilBarrelsPerDay",
- "ObsoleteText": "Deprecated due to github issue #363, please use VolumeFlow instead",
- "FromUnitToBaseFunc": "x*1.8401307283333333333333333333333e-6",
- "FromBaseToUnitFunc": "x/1.8401307283333333333333333333333e-6",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "bbl/d", "BOPD" ]
- }
- ]
- }
- ]
-}
diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json
index 2ee0fd3767..ea24e97c88 100644
--- a/Common/UnitDefinitions/Length.json
+++ b/Common/UnitDefinitions/Length.json
@@ -64,7 +64,7 @@
"Localization": [
{
"Culture": "en-US",
- "Abbreviations": [ "ft", "'" ]
+ "Abbreviations": [ "ft", "'", "′" ]
},
{
"Culture": "ru-RU",
@@ -92,7 +92,7 @@
"Localization": [
{
"Culture": "en-US",
- "Abbreviations": [ "in", "\\\"" ]
+ "Abbreviations": [ "in", "\\\"", "″" ]
},
{
"Culture": "ru-RU",
@@ -233,4 +233,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json
index 21d85ae4b6..f1daa4f6f3 100644
--- a/Common/UnitDefinitions/Pressure.json
+++ b/Common/UnitDefinitions/Pressure.json
@@ -161,23 +161,6 @@
}
]
},
- {
- "SingularName": "Psi",
- "PluralName": "Psi",
- "ObsoleteText": "Deprecated due to github issue #215, please use PoundForcePerSquareInch instead",
- "FromUnitToBaseFunc": "x*6.894757293168361e3",
- "FromBaseToUnitFunc": "x/6.894757293168361e3",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "psi" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "psi" ]
- }
- ]
- },
{
"SingularName": "TechnicalAtmosphere",
"PluralName": "TechnicalAtmospheres",
diff --git a/Common/UnitDefinitions/TemperatureDelta.json b/Common/UnitDefinitions/TemperatureDelta.json
index 771f916667..34b37da1ea 100644
--- a/Common/UnitDefinitions/TemperatureDelta.json
+++ b/Common/UnitDefinitions/TemperatureDelta.json
@@ -98,110 +98,6 @@
"Abbreviations": [ "∆°Rø" ]
}
]
- },
- {
- "SingularName": "KelvinDelta",
- "PluralName": "KelvinsDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use Kelvin instead",
- "FromUnitToBaseFunc": "x",
- "FromBaseToUnitFunc": "x",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆K" ]
- }
- ]
- },
- {
- "SingularName": "DegreeCelsiusDelta",
- "PluralName": "DegreesCelsiusDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeCelsius instead",
- "FromUnitToBaseFunc": "x",
- "FromBaseToUnitFunc": "x",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°C" ]
- }
- ]
- },
- {
- "SingularName": "DegreeDelisleDelta",
- "PluralName": "DegreesDelisleDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeDelisle instead",
- "FromUnitToBaseFunc": "x*-2/3",
- "FromBaseToUnitFunc": "x*-3/2",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°De" ]
- }
- ]
- },
- {
- "SingularName": "DegreeFahrenheitDelta",
- "PluralName": "DegreesFahrenheitDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeFahrenheit instead",
- "FromUnitToBaseFunc": "x*5/9",
- "FromBaseToUnitFunc": "x*9/5",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°F" ]
- }
- ]
- },
- {
- "SingularName": "DegreeNewtonDelta",
- "PluralName": "DegreesNewtonDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeNewton instead",
- "FromUnitToBaseFunc": "x*100/33",
- "FromBaseToUnitFunc": "x*33/100",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°N" ]
- }
- ]
- },
- {
- "SingularName": "DegreeRankineDelta",
- "PluralName": "DegreesRankineDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeRankine instead",
- "FromUnitToBaseFunc": "x*5/9",
- "FromBaseToUnitFunc": "x*9/5",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°R" ]
- }
- ]
- },
- {
- "SingularName": "DegreeReaumurDelta",
- "PluralName": "DegreesReaumurDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeReaumur instead",
- "FromUnitToBaseFunc": "x*5/4",
- "FromBaseToUnitFunc": "x*4/5",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°Ré" ]
- }
- ]
- },
- {
- "SingularName": "DegreeRoemerDelta",
- "PluralName": "DegreesRoemerDelta",
- "ObsoleteText": "Deprecated due to github issue #180, please use DegreeRoemer instead",
- "FromUnitToBaseFunc": "x*40/21",
- "FromBaseToUnitFunc": "x*21/40",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "∆°Rø" ]
- }
- ]
}
]
}
\ No newline at end of file
diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json
index abb64bc7ce..4eef10b912 100644
--- a/Common/UnitDefinitions/Volume.json
+++ b/Common/UnitDefinitions/Volume.json
@@ -252,48 +252,6 @@
}
]
},
- {
- "SingularName": "Tablespoon",
- "PluralName": "Tablespoons",
- "ObsoleteText": "Deprecated due to github issue #134, please use UsTablespoon instead",
- "FromUnitToBaseFunc": "x*1.478676478125e-5",
- "FromBaseToUnitFunc": "x/1.478676478125e-5",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "Tbsp", "Tbs", "T", "tb", "tbs", "tbsp", "tblsp", "tblspn", "Tbsp.", "Tbs.", "T.", "tb.", "tbs.", "tbsp.", "tblsp.", "tblspn.", "tablespoon", "Tablespoon" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "столовая ложка" ]
- },
- {
- "Culture": "nb-NO",
- "Abbreviations": [ "ss", "ss.", "SS", "SS." ]
- }
- ]
- },
- {
- "SingularName": "Teaspoon",
- "PluralName": "Teaspoons",
- "ObsoleteText": "Deprecated due to github issue #134, please use UsTeaspoon instead",
- "FromUnitToBaseFunc": "x*4.92892159375e-6",
- "FromBaseToUnitFunc": "x/4.92892159375e-6",
- "Localization": [
- {
- "Culture": "en-US",
- "Abbreviations": [ "tsp", "t", "ts", "tspn", "t.", "ts.", "tsp.", "tspn.", "teaspoon" ]
- },
- {
- "Culture": "ru-RU",
- "Abbreviations": [ "чайная ложка" ]
- },
- {
- "Culture": "nb-NO",
- "Abbreviations": [ "ts", "ts." ]
- }
- ]
- },
{
"SingularName": "UsTablespoon",
"PluralName": "UsTablespoons",
diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json
index d0440363e1..cec7dec73a 100644
--- a/Common/UnitDefinitions/VolumeFlow.json
+++ b/Common/UnitDefinitions/VolumeFlow.json
@@ -1,4 +1,4 @@
-{
+{
"Name": "VolumeFlow",
"BaseUnit": "CubicMeterPerSecond",
"XmlDoc": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.",
@@ -136,7 +136,7 @@
]
},
{
- "SingularName": "LitersPerSecond",
+ "SingularName": "LiterPerSecond",
"PluralName": "LitersPerSecond",
"FromUnitToBaseFunc": "x/1000",
"FromBaseToUnitFunc": "x*1000",
@@ -148,7 +148,7 @@
]
},
{
- "SingularName": "LitersPerMinute",
+ "SingularName": "LiterPerMinute",
"PluralName": "LitersPerMinute",
"FromUnitToBaseFunc": "x/60000.00000",
"FromBaseToUnitFunc": "x*60000.00000",
@@ -161,7 +161,7 @@
]
},
{
- "SingularName": "LitersPerHour",
+ "SingularName": "LiterPerHour",
"PluralName": "LitersPerHour",
"FromUnitToBaseFunc": "x/3600000.000",
"FromBaseToUnitFunc": "x*3600000.000",
@@ -177,7 +177,7 @@
]
},
{
- "SingularName": "UsGallonsPerSecond",
+ "SingularName": "UsGallonPerSecond",
"PluralName": "UsGallonsPerSecond",
"FromUnitToBaseFunc": "x/264.1720523581484",
"FromBaseToUnitFunc": "x*264.1720523581484",
@@ -189,7 +189,7 @@
]
},
{
- "SingularName": "UsGallonsPerMinute",
+ "SingularName": "UsGallonPerMinute",
"PluralName": "UsGallonsPerMinute",
"FromUnitToBaseFunc": "x/15850.323141489",
"FromBaseToUnitFunc": "x*15850.323141489",
@@ -213,7 +213,7 @@
]
},
{
- "SingularName": "UsGallonsPerHour",
+ "SingularName": "UsGallonPerHour",
"PluralName": "UsGallonsPerHour",
"FromUnitToBaseFunc": "x/951019.38848933424",
"FromBaseToUnitFunc": "x*951019.38848933424",
@@ -241,7 +241,7 @@
]
},
{
- "SingularName": "OilBarrelsPerDay",
+ "SingularName": "OilBarrelPerDay",
"PluralName": "OilBarrelsPerDay",
"FromUnitToBaseFunc": "x*1.8401307283333333333333333333333e-6",
"FromBaseToUnitFunc": "x/1.8401307283333333333333333333333e-6",
@@ -253,7 +253,7 @@
]
},
{
- "SingularName": "OilBarrelsPerMinute",
+ "SingularName": "OilBarrelPerMinute",
"PluralName": "OilBarrelsPerMinute",
"FromUnitToBaseFunc": "x*2.64978825e-3",
"FromBaseToUnitFunc": "x/2.64978825e-3",
@@ -265,7 +265,7 @@
]
},
{
- "SingularName": "OilBarrelsPerHour",
+ "SingularName": "OilBarrelPerHour",
"PluralName": "OilBarrelsPerHour",
"FromUnitToBaseFunc": "x*4.41631375e-5",
"FromBaseToUnitFunc": "x/4.41631375e-5",
diff --git a/README.md b/README.md
index 0fdc875ee0..ce30d82c7e 100644
--- a/README.md
+++ b/README.md
@@ -11,20 +11,18 @@ Stop littering your code with unnecessary calculations, Units.NET gives you all
### Build Targets
-* .NET Standard 1.0
+* .NET Standard 2.0
* .NET 4.0
-* .NET 3.5 Client
* [Windows Runtime Component](https://docs.microsoft.com/en-us/windows/uwp/winrt-components/) for UWP apps (JavaScript, C++ or C#)
### Overview
-* [50+ quantities with a total of 600+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [Powershell scripts](UnitsNet/Scripts)
-* [1000+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations
+* [89 quantities with over 750 units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [Powershell scripts](UnitsNet/Scripts)
+* [1900+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations
* Immutable structs that implement `Equatable`, `IComparable`
* [Static typing](#static-typing) to avoid ambiguous values or units
* [Operator overloads](#operator-overloads) for arithmetic on quantities
-* [Extension methods](#extension-methods) for short-hand creation and conversions
* [Parse and ToString()](#culture) supports cultures and localization
* [Example: Creating a unit converter app](#example-app)
* [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input)
@@ -76,21 +74,6 @@ Acceleration a2 = Force.FromNewtons(100) / Mass.FromKilograms(20);
RotationalSpeed r = Angle.FromDegrees(90) / TimeSpan.FromSeconds(2);
```
-### Extension Methods
-
-All units have associated extension methods for a really compact, expressive way to construct values or do arithmetic.
-```C#
-using UnitsNet.Extensions.NumberToDuration;
-using UnitsNet.Extensions.NumberToLength;
-using UnitsNet.Extensions.NumberToTimeSpan;
-
-Speed speed = 30.Kilometers() / 1.Hours(); // 30 km/h (using Duration type)
-Length distance = speed * 2.h(); // 60 km (using TimeSpan type)
-
-Acceleration stdGravity = 9.80665.MetersPerSecondSquared();
-Force weight = 80.Kilograms() * stdGravity; // 80 kilograms-force or 784.532 newtons
-```
-
### Culture and Localization
The culture for abbreviations defaults to Thread.CurrentUICulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are:
@@ -133,7 +116,7 @@ Example:
### Example: Creating a dynamic unit converter app
[Source code](https://github.com/angularsen/UnitsNet/tree/master/Samples/UnitConverter.Wpf) for `Samples/UnitConverter.Wpf`
-[Download](https://github.com/angularsen/UnitsNet/releases/tag/UnitConverterWpf%2F2018-02-04) (release 2018-02-04 for Windows)
+[Download](https://github.com/angularsen/UnitsNet/releases/tag/UnitConverterWpf%2F2018-11-09) (release 2018-11-09 for Windows)

diff --git a/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj b/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj
index 64da47640d..593b33c624 100644
--- a/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj
+++ b/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj
@@ -1,19 +1,17 @@
-
+
- netcoreapp1.0
- ConsoleApp-NetCore
+ netcoreapp2.1
Exe
- ConsoleApp-NetCore
- 1.0.4
- $(PackageTargetFallback);dnxcore50
- false
- false
- false
+ ConsoleApp1.Program
-
+
+
+
+
+
diff --git a/Samples/ConsoleApp-NetCore/Program.cs b/Samples/ConsoleApp-NetCore/Program.cs
index 60b6e928b5..4d4141d683 100644
--- a/Samples/ConsoleApp-NetCore/Program.cs
+++ b/Samples/ConsoleApp-NetCore/Program.cs
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using UnitsNet;
namespace ConsoleApp1
diff --git a/Samples/ConsoleApp-NetCore/Properties/AssemblyInfo.cs b/Samples/ConsoleApp-NetCore/Properties/AssemblyInfo.cs
deleted file mode 100644
index 535ecf599f..0000000000
--- a/Samples/ConsoleApp-NetCore/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("ConsoleApp1")]
-[assembly: AssemblyTrademark("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("955a6cbf-c4e3-4c55-85c8-613e2ca4ccd7")]
diff --git a/Samples/Samples.sln b/Samples/Samples.sln
index 0d8fc0f162..e125d7998a 100644
--- a/Samples/Samples.sln
+++ b/Samples/Samples.sln
@@ -9,24 +9,104 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitConverter.Wpf", "UnitCo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfMVVMSample", "WpfMVVMSample\WpfMVVMSample\WpfMVVMSample.csproj", "{B72F9215-70FF-4155-89BC-9A02CC550447}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleConversionDemo.UWP.CSharp", "SimpleConversionDemo.UWP.CSharp\SimpleConversionDemo.UWP.CSharp.csproj", "{76255CC9-A854-441F-AF5C-2606509D3C5E}"
+EndProject
+Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "SimpleConversionDemo.UWP.WinJS", "SimpleConversionDemo.UWP.WinJS\SimpleConversionDemo.UWP.WinJS.jsproj", "{F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x64.Build.0 = Debug|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x86.Build.0 = Debug|Any CPU
{955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|ARM.ActiveCfg = Release|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x64.ActiveCfg = Release|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x64.Build.0 = Release|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x86.ActiveCfg = Release|Any CPU
+ {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x86.Build.0 = Release|Any CPU
{D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|x64.Build.0 = Debug|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|x86.Build.0 = Debug|Any CPU
{D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|ARM.ActiveCfg = Release|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|x64.ActiveCfg = Release|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|x64.Build.0 = Release|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|x86.ActiveCfg = Release|Any CPU
+ {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Release|x86.Build.0 = Release|Any CPU
{B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|x64.Build.0 = Debug|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Debug|x86.Build.0 = Debug|Any CPU
{B72F9215-70FF-4155-89BC-9A02CC550447}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B72F9215-70FF-4155-89BC-9A02CC550447}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|ARM.ActiveCfg = Release|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x64.ActiveCfg = Release|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x64.Build.0 = Release|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x86.ActiveCfg = Release|Any CPU
+ {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x86.Build.0 = Release|Any CPU
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.Build.0 = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.Deploy.0 = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.ActiveCfg = Debug|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Build.0 = Debug|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Deploy.0 = Debug|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x64.ActiveCfg = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.ActiveCfg = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Build.0 = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Deploy.0 = Debug|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.ActiveCfg = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.Build.0 = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.Deploy.0 = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.ActiveCfg = Release|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Build.0 = Release|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Deploy.0 = Release|ARM
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x64.ActiveCfg = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.ActiveCfg = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Build.0 = Release|x86
+ {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Deploy.0 = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.Build.0 = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.Deploy.0 = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.ActiveCfg = Debug|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Build.0 = Debug|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Deploy.0 = Debug|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x64.ActiveCfg = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.ActiveCfg = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Build.0 = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Deploy.0 = Debug|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.ActiveCfg = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.Build.0 = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.Deploy.0 = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.ActiveCfg = Release|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Build.0 = Release|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Deploy.0 = Release|ARM
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x64.ActiveCfg = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.ActiveCfg = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Build.0 = Release|x86
+ {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/UnitsNet.TestApps.Uwp.Csharp/.gitignore b/Samples/SimpleConversionDemo.UWP.CSharp/.gitignore
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/.gitignore
rename to Samples/SimpleConversionDemo.UWP.CSharp/.gitignore
diff --git a/UnitsNet.TestApps.Uwp.Csharp/App.xaml b/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/App.xaml
rename to Samples/SimpleConversionDemo.UWP.CSharp/App.xaml
diff --git a/UnitsNet.TestApps.Uwp.Csharp/App.xaml.cs b/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/App.xaml.cs
rename to Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/LockScreenLogo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/LockScreenLogo.scale-200.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/LockScreenLogo.scale-200.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/LockScreenLogo.scale-200.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/SplashScreen.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/SplashScreen.scale-200.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/SplashScreen.scale-200.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/SplashScreen.scale-200.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/Square150x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square150x150Logo.scale-200.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/Square150x150Logo.scale-200.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square150x150Logo.scale-200.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/Square44x44Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.scale-200.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/Square44x44Logo.scale-200.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.scale-200.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/StoreLogo.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/StoreLogo.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/StoreLogo.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/StoreLogo.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Assets/Wide310x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Wide310x150Logo.scale-200.png
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Assets/Wide310x150Logo.scale-200.png
rename to Samples/SimpleConversionDemo.UWP.CSharp/Assets/Wide310x150Logo.scale-200.png
diff --git a/UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml b/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml
rename to Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml
diff --git a/UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml.cs b/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs
similarity index 78%
rename from UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml.cs
rename to Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs
index 7905f7df5f..d2e8c25c54 100644
--- a/UnitsNet.TestApps.Uwp.Csharp/MainPage.xaml.cs
+++ b/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs
@@ -19,9 +19,9 @@ public MainPage()
InitializeComponent();
// Test some variations, From() constructors, Parse(), As()
- string celsius = Temperature.FromDegreesCelsius(100).ToString(TemperatureUnit.DegreeCelsius);
- string fahrenheit = Temperature.Parse("100 °C").ToString(TemperatureUnit.DegreeFahrenheit);
- string kelvin = Temperature.FromDegreesCelsius(Temperature.Parse(fahrenheit).As(TemperatureUnit.DegreeCelsius)).ToString(TemperatureUnit.Kelvin);
+ string celsius = Temperature.FromDegreesCelsius(100).ToUnit(TemperatureUnit.DegreeCelsius).ToString();
+ string fahrenheit = Temperature.Parse("100 °C").ToUnit(TemperatureUnit.DegreeFahrenheit).ToString();
+ string kelvin = Temperature.FromDegreesCelsius(Temperature.Parse(fahrenheit).As(TemperatureUnit.DegreeCelsius)).ToUnit(TemperatureUnit.Kelvin).ToString();
// Arithmetic operators not allowed in WinRT Components, but SHOULD be allowed in UWP C# apps
// new Temperature(5) + new Temperature(6)
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Package.appxmanifest b/Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest
similarity index 95%
rename from UnitsNet.TestApps.Uwp.Csharp/Package.appxmanifest
rename to Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest
index 23c4bac2b3..4aa128459b 100644
--- a/UnitsNet.TestApps.Uwp.Csharp/Package.appxmanifest
+++ b/Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest
@@ -1,6 +1,6 @@
-
+
UWP
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Properties/AssemblyInfo.cs b/Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Properties/AssemblyInfo.cs
rename to Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs
diff --git a/UnitsNet.TestApps.Uwp.Csharp/Properties/Default.rd.xml b/Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/Properties/Default.rd.xml
rename to Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml
diff --git a/UnitsNet.TestApps.Uwp.Csharp/README.md b/Samples/SimpleConversionDemo.UWP.CSharp/README.md
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/README.md
rename to Samples/SimpleConversionDemo.UWP.CSharp/README.md
diff --git a/UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp.csproj b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj
similarity index 94%
rename from UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp.csproj
rename to Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj
index d89fc5a964..19f9c3b450 100644
--- a/UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp.csproj
+++ b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj
@@ -12,12 +12,12 @@
en-US
UAP
10.0.16299.0
- 10.0.10240.0
+ 10.0.16299.0
14
512
{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- UnitsNet.TestApps.Uwp.Csharp_TemporaryKey.pfx
- A1E3AD6087EF223EE6E43EE09818599CAE918FEE
+ SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx
+ E98156EA0B8126C89A2653E1CBF645701A704E52
true
@@ -91,7 +91,7 @@
-
+
diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx
new file mode 100644
index 0000000000..61cfb8eca2
Binary files /dev/null and b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx differ
diff --git a/UnitsNet.TestApps.Uwp.Csharp/build.bat b/Samples/SimpleConversionDemo.UWP.CSharp/build.bat
similarity index 100%
rename from UnitsNet.TestApps.Uwp.Csharp/build.bat
rename to Samples/SimpleConversionDemo.UWP.CSharp/build.bat
diff --git a/UnitsNet.TestApps.Uwp.WinJS/project.json b/Samples/SimpleConversionDemo.UWP.CSharp/project.json
similarity index 60%
rename from UnitsNet.TestApps.Uwp.WinJS/project.json
rename to Samples/SimpleConversionDemo.UWP.CSharp/project.json
index a216036b9c..c0ecdfc923 100644
--- a/UnitsNet.TestApps.Uwp.WinJS/project.json
+++ b/Samples/SimpleConversionDemo.UWP.CSharp/project.json
@@ -1,10 +1,10 @@
{
"dependencies": {
- "Microsoft.NETCore.UniversalWindowsPlatform": "6.0.6",
- "UnitsNet.WindowsRuntimeComponent": "3.64.0"
+ "Microsoft.NETCore.UniversalWindowsPlatform": "6.1.9",
+ "UnitsNet.WindowsRuntimeComponent": "4.0.0-beta1"
},
"frameworks": {
- "uap10.0": {}
+ "uap10.0.16299": {}
},
"runtimes": {
"win10-arm": {},
diff --git a/UnitsNet.TestApps.Uwp.WinJS/README.md b/Samples/SimpleConversionDemo.UWP.WinJS/README.md
similarity index 100%
rename from UnitsNet.TestApps.Uwp.WinJS/README.md
rename to Samples/SimpleConversionDemo.UWP.WinJS/README.md
diff --git a/UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS.jsproj b/Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS.jsproj
similarity index 90%
rename from UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS.jsproj
rename to Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS.jsproj
index 866b991d93..4b820238c5 100644
--- a/UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS.jsproj
+++ b/Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS.jsproj
@@ -52,7 +52,8 @@
10.0.16299.0
$(VersionNumberMajor).$(VersionNumberMinor)
en-US
- UnitsNet.TestApps.Uwp.WinJS_TemporaryKey.pfx
+ SimpleConversionDemo.UWP.WinJS_TemporaryKey.pfx
+ 233FD264CDB1D145E2BAA90728A41382699F2046
@@ -74,15 +75,7 @@
-
-
-
-
- ..\packages\UnitsNet.WindowsRuntimeComponent.3.64.0\lib\uap10.0\UnitsNet.winmd
- true
- True
- False
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Tools/NUnit/nunit-agent.exe b/Tools/NUnit/nunit-agent.exe
deleted file mode 100644
index 637b2562be..0000000000
Binary files a/Tools/NUnit/nunit-agent.exe and /dev/null differ
diff --git a/Tools/NUnit/nunit-agent.exe.config b/Tools/NUnit/nunit-agent.exe.config
deleted file mode 100644
index de2caf60fd..0000000000
--- a/Tools/NUnit/nunit-agent.exe.config
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Tools/NUnit/nunit-console-x86.exe b/Tools/NUnit/nunit-console-x86.exe
deleted file mode 100644
index 672a80ee51..0000000000
Binary files a/Tools/NUnit/nunit-console-x86.exe and /dev/null differ
diff --git a/Tools/NUnit/nunit-console-x86.exe.config b/Tools/NUnit/nunit-console-x86.exe.config
deleted file mode 100644
index 81e5346c83..0000000000
--- a/Tools/NUnit/nunit-console-x86.exe.config
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Tools/NUnit/nunit-console.exe b/Tools/NUnit/nunit-console.exe
deleted file mode 100644
index 28734cb44c..0000000000
Binary files a/Tools/NUnit/nunit-console.exe and /dev/null differ
diff --git a/Tools/NUnit/nunit-console.exe.config b/Tools/NUnit/nunit-console.exe.config
deleted file mode 100644
index 81e5346c83..0000000000
--- a/Tools/NUnit/nunit-console.exe.config
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Tools/NUnit/nunit-x86.exe b/Tools/NUnit/nunit-x86.exe
deleted file mode 100644
index 9c8147f7a8..0000000000
Binary files a/Tools/NUnit/nunit-x86.exe and /dev/null differ
diff --git a/Tools/NUnit/nunit-x86.exe.config b/Tools/NUnit/nunit-x86.exe.config
deleted file mode 100644
index 9301f94653..0000000000
--- a/Tools/NUnit/nunit-x86.exe.config
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Tools/NUnit/nunit.exe b/Tools/NUnit/nunit.exe
deleted file mode 100644
index 6d24caf6e9..0000000000
Binary files a/Tools/NUnit/nunit.exe and /dev/null differ
diff --git a/Tools/NUnit/nunit.exe.config b/Tools/NUnit/nunit.exe.config
deleted file mode 100644
index 9301f94653..0000000000
--- a/Tools/NUnit/nunit.exe.config
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/UnitsNet.AllTargets.sln b/UnitsNet.AllTargets.sln
deleted file mode 100644
index 17dd988da7..0000000000
--- a/UnitsNet.AllTargets.sln
+++ /dev/null
@@ -1,151 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2027
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.NetStandard10", "UnitsNet\UnitsNet.NetStandard10.csproj", "{CBEAD842-07BC-4B08-9D9D-D6659813776F}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet", "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj", "{FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet.Signed", "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj", "{7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.NetStandard10.Signed", "UnitsNet\UnitsNet.NetStandard10.Signed.csproj", "{21C1AFDC-354E-4D97-947B-2DB63C529E6E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet.Tests", "UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.csproj", "{FFEEDF44-F32D-4D92-A75E-487CB0582EB1}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Tests", "UnitsNet.Tests\UnitsNet.Tests.csproj", "{0E3B7567-5DF2-44BD-88DB-CCF050D3F943}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.WindowsRuntimeComponent", "UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.csproj", "{2DA428CA-BFE1-43FA-86D2-7CB42289D596}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|ARM = Debug|ARM
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|ARM = Release|ARM
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|ARM.Build.0 = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|x64.ActiveCfg = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|x64.Build.0 = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Debug|x86.Build.0 = Debug|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|Any CPU.Build.0 = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|ARM.ActiveCfg = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|ARM.Build.0 = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|x64.ActiveCfg = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|x64.Build.0 = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|x86.ActiveCfg = Release|Any CPU
- {CBEAD842-07BC-4B08-9D9D-D6659813776F}.Release|x86.Build.0 = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|ARM.Build.0 = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|x64.ActiveCfg = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|x64.Build.0 = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Debug|x86.Build.0 = Debug|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|Any CPU.Build.0 = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|ARM.ActiveCfg = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|ARM.Build.0 = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|x64.ActiveCfg = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|x64.Build.0 = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|x86.ActiveCfg = Release|Any CPU
- {FB696BFE-B303-4EBD-A0E6-4A7B19DE429B}.Release|x86.Build.0 = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|ARM.Build.0 = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|x64.ActiveCfg = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|x64.Build.0 = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Debug|x86.Build.0 = Debug|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|Any CPU.Build.0 = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|ARM.ActiveCfg = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|ARM.Build.0 = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|x64.ActiveCfg = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|x64.Build.0 = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|x86.ActiveCfg = Release|Any CPU
- {7798DBCF-DD59-4CAD-A754-FB7DCC6BD312}.Release|x86.Build.0 = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|ARM.Build.0 = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|x64.ActiveCfg = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|x64.Build.0 = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|x86.ActiveCfg = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Debug|x86.Build.0 = Debug|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|Any CPU.Build.0 = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|ARM.ActiveCfg = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|ARM.Build.0 = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|x64.ActiveCfg = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|x64.Build.0 = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|x86.ActiveCfg = Release|Any CPU
- {21C1AFDC-354E-4D97-947B-2DB63C529E6E}.Release|x86.Build.0 = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|ARM.Build.0 = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|x64.ActiveCfg = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|x64.Build.0 = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|x86.ActiveCfg = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Debug|x86.Build.0 = Debug|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|Any CPU.Build.0 = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|ARM.ActiveCfg = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|ARM.Build.0 = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|x64.ActiveCfg = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|x64.Build.0 = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|x86.ActiveCfg = Release|Any CPU
- {FFEEDF44-F32D-4D92-A75E-487CB0582EB1}.Release|x86.Build.0 = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|ARM.Build.0 = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|x64.ActiveCfg = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|x64.Build.0 = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|x86.ActiveCfg = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|x86.Build.0 = Debug|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.Build.0 = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|ARM.ActiveCfg = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|ARM.Build.0 = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|x64.ActiveCfg = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|x64.Build.0 = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|x86.ActiveCfg = Release|Any CPU
- {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|x86.Build.0 = Release|Any CPU
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|ARM.ActiveCfg = Debug|ARM
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|ARM.Build.0 = Debug|ARM
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x64.ActiveCfg = Debug|x64
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x64.Build.0 = Debug|x64
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x86.ActiveCfg = Debug|x86
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x86.Build.0 = Debug|x86
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|Any CPU.Build.0 = Release|Any CPU
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|ARM.ActiveCfg = Release|ARM
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|ARM.Build.0 = Release|ARM
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x64.ActiveCfg = Release|x64
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x64.Build.0 = Release|x64
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x86.ActiveCfg = Release|x86
- {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {554906B2-5972-4EBF-9DD5-EEFA77D735D8}
- EndGlobalSection
-EndGlobal
diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj
index ce0cc63fc0..cc13296fe9 100644
--- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj
+++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj
@@ -1,8 +1,9 @@
- netcoreapp1.1
+ netcoreapp2.0
UnitsNet.Serialization.JsonNet.CompatibilityTests
+ 7.3
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj
index 95c2d6467d..4f7084831d 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj
@@ -1,8 +1,9 @@
- netcoreapp1.1
+ netcoreapp2.0
UnitsNet.Serialization.JsonNet.Tests
+ 7.3
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonConverterTests.cs
index b6c77c84af..4514d5be1d 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonConverterTests.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonConverterTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -121,12 +121,8 @@ public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected()
[Fact]
public void NullValue_ExpectJsonContainsNullString()
{
- Mass? nullMass = null;
- var expectedJson = "null";
-
- string json = SerializeObject(nullMass);
-
- Assert.Equal(expectedJson, json);
+ string json = SerializeObject(null);
+ Assert.Equal("null", json);
}
[Fact]
@@ -242,7 +238,7 @@ public void UnitInIComparable_ExpectUnitCorrectlyDeserialized()
string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings);
var deserializedTestObject = JsonConvert.DeserializeObject(json,jsonSerializerSettings);
-
+
Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType());
Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value);
}
diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Common.props b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Common.props
deleted file mode 100644
index d459f6833a..0000000000
--- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Common.props
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
- UnitsNet.Serialization.JsonNet
- 1.3.1
- Andreas Gullberg Larsen
- Units.NET Serialization with Json.NET
- A helper library for serializing and deserializing types in Units.NET using Json.NET.
- Copyright (c) 2015 Andreas Gullberg Larsen
- true
- true
- true
- https://github.com/angularsen/UnitsNet
- https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png
- https://github.com/angularsen/UnitsNet
- https://github.com/angularsen/UnitsNet/blob/master/LICENSE
- false
- unit units measurement json Json.NET Newtonsoft serialize deserialize serialization deserialization
-
-
-
-
- netstandard1.0;net35;net40
- UnitsNet.Serialization.JsonNet
-
- C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client
- CS1701;CS1702;CS1705;CS0618
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Signed.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Signed.csproj
deleted file mode 100644
index 3460bf9f9f..0000000000
--- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Signed.csproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
- UnitsNet.Serialization.JsonNet.Signed
- Units.NET Serialization with Json.NET (signed) - DEPRECATED
- DEPRECATED! Use UnitsNet.Serialization.JsonNet 4.0.0 or later instead, which is now signed. This package will be unlisted sometime later. A helper library for serializing and deserializing types in Units.NET using Json.NET.
-
-
-
-
- SIGNED
- true
- $(MSBuildProjectDirectory)\..\UnitsNet.snk
-
-
-
-
-
-
-
diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj
index e2f31d9cec..41c83e9d19 100644
--- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj
+++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj
@@ -1,7 +1,52 @@
-
-
+
+
+
+ UnitsNet.Serialization.JsonNet
+ 4.0.0-beta2
+ Andreas Gullberg Larsen
+ Units.NET Serialization with Json.NET
+ A helper library for serializing and deserializing types in Units.NET using Json.NET.
+ Copyright (c) 2015 Andreas Gullberg Larsen
+ true
+ https://github.com/angularsen/UnitsNet
+ https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png
+ https://github.com/angularsen/UnitsNet
+ https://github.com/angularsen/UnitsNet/blob/master/LICENSE
+ false
+ unit units measurement json Json.NET Newtonsoft serialize deserialize serialization deserialization
+
-
+
+
+ 4.0.0.0
+ 7.3
+ CS1701;CS1702;CS1705;CS0618
+ UnitsNet.Serialization.JsonNet
+ netstandard2.0;net40
+
+
+
+
+ true
+ true
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
+
+
+
+
+ ../UnitsNet.snk
+ false
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs
index f80cc16cc5..27f99eff09 100644
--- a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs
+++ b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs
@@ -26,6 +26,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnitsNet.Serialization.JsonNet.Internal;
+using UnitsNet.Units;
namespace UnitsNet.Serialization.JsonNet
{
@@ -129,9 +130,7 @@ private static object CreateQuantity(Type quantityType, double value, object uni
object quantityValue = GetFromMethodValueArgument(notNullableFromMethod, value);
// Ex: Mass.From(55, MassUnit.Gram)
- // TODO: there is a possible loss of precision if base value requires higher precision than double can represent.
- // Example: Serializing Information.FromExabytes(100) then deserializing to Information
- // will likely return a very different result. Not sure how we can handle this?
+ // See ValueUnit about precision loss for quantities using decimal type.
return notNullableFromMethod.Invoke(null, new[] {quantityValue, unitValue});
}
@@ -206,7 +205,7 @@ public override void WriteJson(JsonWriter writer, object obj, JsonSerializer ser
serializer.Serialize(writer, new ValueUnit
{
- // TODO Should we serialize long, decimal and long differently?
+ // See ValueUnit about precision loss for quantities using decimal type.
Value = Convert.ToDouble(quantityValue),
Unit = quantityUnitName
});
@@ -232,9 +231,7 @@ private static object GetValueOfQuantity(object value, Type quantityType)
{
FieldInfo valueField = GetPrivateInstanceField(quantityType, ValueFieldName);
- // Unit base type can be double, long or decimal,
- // so make sure we serialize the real type to avoid
- // loss of precision
+ // See ValueUnit about precision loss for quantities using decimal type.
object quantityValue = valueField.GetValue(value);
return quantityValue;
}
@@ -277,10 +274,13 @@ private static FieldInfo GetPrivateInstanceField(Type quantityType, string field
/// A structure used to serialize/deserialize Units.NET unit instances.
///
///
- /// TODO Units may use decimal, long or double as base value type and might result
+ /// Quantities may use decimal, long or double as base value type and this might result
/// in a loss of precision when serializing/deserializing to decimal.
/// Decimal is the highest precision type available in .NET, but has a smaller
/// range than double.
+ ///
+ /// Json: Support decimal precision #503
+ /// https://github.com/angularsen/UnitsNet/issues/503
///
private class ValueUnit
{
diff --git a/UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp_TemporaryKey.pfx b/UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp_TemporaryKey.pfx
deleted file mode 100644
index f9430b979e..0000000000
Binary files a/UnitsNet.TestApps.Uwp.Csharp/UnitsNet.TestApps.Uwp.Csharp_TemporaryKey.pfx and /dev/null differ
diff --git a/UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS_TemporaryKey.pfx b/UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS_TemporaryKey.pfx
deleted file mode 100644
index 69ade5ebf1..0000000000
Binary files a/UnitsNet.TestApps.Uwp.WinJS/UnitsNet.TestApps.Uwp.WinJS_TemporaryKey.pfx and /dev/null differ
diff --git a/UnitsNet.TestApps.sln b/UnitsNet.TestApps.sln
deleted file mode 100644
index 1cd5c2919c..0000000000
--- a/UnitsNet.TestApps.sln
+++ /dev/null
@@ -1,63 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2027
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.TestApps.Uwp.Csharp", "UnitsNet.TestApps.Uwp.Csharp\UnitsNet.TestApps.Uwp.Csharp.csproj", "{76255CC9-A854-441F-AF5C-2606509D3C5E}"
-EndProject
-Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "UnitsNet.TestApps.Uwp.WinJS", "UnitsNet.TestApps.Uwp.WinJS\UnitsNet.TestApps.Uwp.WinJS.jsproj", "{F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|ARM = Debug|ARM
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|ARM = Release|ARM
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.ActiveCfg = Debug|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Build.0 = Debug|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Deploy.0 = Debug|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x64.ActiveCfg = Debug|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x64.Build.0 = Debug|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x64.Deploy.0 = Debug|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.ActiveCfg = Debug|x86
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Build.0 = Debug|x86
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Deploy.0 = Debug|x86
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.ActiveCfg = Release|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Build.0 = Release|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Deploy.0 = Release|ARM
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x64.ActiveCfg = Release|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x64.Build.0 = Release|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x64.Deploy.0 = Release|x64
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.ActiveCfg = Release|x86
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Build.0 = Release|x86
- {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Deploy.0 = Release|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.ActiveCfg = Debug|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Build.0 = Debug|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Deploy.0 = Debug|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x64.ActiveCfg = Debug|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x64.Build.0 = Debug|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x64.Deploy.0 = Debug|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.ActiveCfg = Debug|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Build.0 = Debug|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Deploy.0 = Debug|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.ActiveCfg = Release|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Build.0 = Release|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Deploy.0 = Release|ARM
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x64.ActiveCfg = Release|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x64.Build.0 = Release|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x64.Deploy.0 = Release|x64
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.ActiveCfg = Release|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Build.0 = Release|x86
- {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Deploy.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {C28E940D-1A2A-43AC-BF2D-5BF50546156F}
- EndGlobalSection
-EndGlobal
diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs
index 7e553f92bc..cf90732786 100644
--- a/UnitsNet.Tests/AssertEx.cs
+++ b/UnitsNet.Tests/AssertEx.cs
@@ -12,7 +12,7 @@ public static void EqualTolerance(double expected, double actual, double toleran
{
if(comparisonType == ComparisonType.Relative)
{
- bool areEqual = UnitsNet.Comparison.EqualsRelative(expected, actual, tolerance);
+ bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance);
double difference = Math.Abs(expected - actual);
double relativeDifference = difference / expected;
@@ -21,7 +21,7 @@ public static void EqualTolerance(double expected, double actual, double toleran
}
else if( comparisonType == ComparisonType.Absolute )
{
- bool areEqual = UnitsNet.Comparison.EqualsAbsolute(expected, actual, tolerance);
+ bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance);
Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" );
}
}
diff --git a/UnitsNet.Tests/BaseDimensionsTests.cs b/UnitsNet.Tests/BaseDimensionsTests.cs
index 3d35b0c00d..f147649381 100644
--- a/UnitsNet.Tests/BaseDimensionsTests.cs
+++ b/UnitsNet.Tests/BaseDimensionsTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Xunit;
namespace UnitsNet.Tests
@@ -6,13 +7,135 @@ namespace UnitsNet.Tests
public class BaseDimensionsTests
{
[Fact]
- public void EqualityWorksAsExpected()
+ public void ConstructorImplementedCorrectly()
+ {
+ var baseDimensions = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+
+ Assert.True(baseDimensions.Length == 1);
+ Assert.True(baseDimensions.Mass == 2);
+ Assert.True(baseDimensions.Time == 3);
+ Assert.True(baseDimensions.Current == 4);
+ Assert.True(baseDimensions.Temperature == 5);
+ Assert.True(baseDimensions.Amount == 6);
+ Assert.True(baseDimensions.LuminousIntensity == 7);
+ }
+
+ [Theory]
+ [InlineData(1, 0, 0, 0, 0, 0, 0)]
+ [InlineData(0, 1, 0, 0, 0, 0, 0)]
+ [InlineData(0, 0, 1, 0, 0, 0, 0)]
+ [InlineData(0, 0, 0, 1, 0, 0, 0)]
+ [InlineData(0, 0, 0, 0, 1, 0, 0)]
+ [InlineData(0, 0, 0, 0, 0, 1, 0)]
+ [InlineData(0, 0, 0, 0, 0, 0, 1)]
+ public void IsBaseQuantityImplementedProperly(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
+ {
+ var baseDimensions = new BaseDimensions(length, mass, time, current, temperature, amount, luminousIntensity);
+ var derivedDimensions = new BaseDimensions(length * 2, mass * 2, time * 2, current * 2, temperature * 2, amount * 2, luminousIntensity * 2);
+
+ Assert.True(baseDimensions.IsBaseQuantity());
+ Assert.False(derivedDimensions.IsBaseQuantity());
+ }
+
+ [Theory]
+ [InlineData(2, 0, 0, 0, 0, 0, 0)]
+ [InlineData(0, 2, 0, 0, 0, 0, 0)]
+ [InlineData(0, 0, 2, 0, 0, 0, 0)]
+ [InlineData(0, 0, 0, 2, 0, 0, 0)]
+ [InlineData(0, 0, 0, 0, 2, 0, 0)]
+ [InlineData(0, 0, 0, 0, 0, 2, 0)]
+ [InlineData(0, 0, 0, 0, 0, 0, 2)]
+ public void IsDerivedQuantityImplementedProperly(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
+ {
+ var baseDimensions = new BaseDimensions(length / 2, mass / 2, time / 2, current / 2, temperature / 2, amount / 2, luminousIntensity / 2);
+ var derivedDimensions = new BaseDimensions(length, mass, time, current, temperature, amount, luminousIntensity);
+
+ Assert.False(baseDimensions.IsDerivedQuantity());
+ Assert.True(derivedDimensions.IsDerivedQuantity());
+ }
+
+ [Fact]
+ public void EqualsWorksAsExpected()
{
var baseDimensions1 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
var baseDimensions2 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
Assert.True(baseDimensions1.Equals(baseDimensions2));
Assert.True(baseDimensions2.Equals(baseDimensions1));
+
+ Assert.False(baseDimensions1.Equals(null));
+ }
+
+ [Fact]
+ public void EqualityOperatorsWorkAsExpected()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+ var baseDimensions2 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+
+ Assert.True(baseDimensions1 == baseDimensions2);
+ Assert.True(baseDimensions2 == baseDimensions1);
+
+ Assert.False(baseDimensions1 == null);
+ Assert.False(null == baseDimensions1);
+
+ Assert.False(baseDimensions2 == null);
+ Assert.False(null == baseDimensions2);
+
+ BaseDimensions nullBaseDimensions1 = null;
+ BaseDimensions nullBaseDimensions2 = null;
+
+ Assert.True(nullBaseDimensions1 == nullBaseDimensions2);
+ }
+
+ [Fact]
+ public void InequalityOperatorsWorkAsExpected()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+ var baseDimensions2 = new BaseDimensions(7, 6, 5, 4, 3, 2, 1);
+
+ Assert.True(baseDimensions1 != baseDimensions2);
+ Assert.True(baseDimensions2 != baseDimensions1);
+
+ Assert.True(baseDimensions1 != null);
+ Assert.True(null != baseDimensions1);
+
+ Assert.True(baseDimensions2 != null);
+ Assert.True(null != baseDimensions2);
+
+ BaseDimensions nullBaseDimensions1 = null;
+ BaseDimensions nullBaseDimensions2 = null;
+
+ Assert.False(nullBaseDimensions1 != nullBaseDimensions2);
+ }
+
+ [Fact]
+ public void MultiplyThrowsExceptionIfPassedNull()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 0, 0, 0, 0, 0, 0);
+ Assert.Throws(() => baseDimensions1.Multiply(null));
+ }
+
+ [Fact]
+ public void DivideThrowsExceptionIfPassedNull()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 0, 0, 0, 0, 0, 0);
+ Assert.Throws(() => baseDimensions1.Divide(null));
+ }
+
+ [Fact]
+ public void MultiplyOperatorThrowsExceptionWithNull()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 0, 0, 0, 0, 0, 0);
+ Assert.Throws(() => baseDimensions1 / null);
+ Assert.Throws(() => null / baseDimensions1);
+ }
+
+ [Fact]
+ public void DivideOperatorThrowsExceptionWithNull()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 0, 0, 0, 0, 0, 0);
+ Assert.Throws(() => baseDimensions1 * null);
+ Assert.Throws(() => null * baseDimensions1);
}
[Fact]
@@ -576,5 +699,46 @@ public void CheckToStringUsingMolarEntropy()
{
Assert.Equal("[Length]^2[Mass][Time]^-2[Temperature][Amount]", MolarEntropy.BaseDimensions.ToString());
}
+
+ [Fact]
+ public void GetHashCodeWorksProperly()
+ {
+ var baseDimensions1 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+ var baseDimensions2 = new BaseDimensions(7, 6, 5, 4, 3, 2, 1);
+ var baseDimensions3 = new BaseDimensions(1, 2, 3, 4, 5, 6, 7);
+
+ var hashSet = new HashSet();
+
+ hashSet.Add(baseDimensions1);
+ Assert.Contains(baseDimensions1, hashSet);
+
+ hashSet.Add(baseDimensions2);
+ Assert.Contains(baseDimensions2, hashSet);
+
+ // Should be the same as baseDimensions1
+ Assert.Contains(baseDimensions3, hashSet);
+
+ Assert.True(baseDimensions1.GetHashCode() != baseDimensions2.GetHashCode());
+ Assert.True(baseDimensions1.GetHashCode() == baseDimensions3.GetHashCode());
+ }
+
+ [Fact]
+ public void DimensionlessPropertyIsCorrect()
+ {
+ Assert.True(BaseDimensions.Dimensionless == new BaseDimensions(0, 0, 0, 0, 0, 0, 0));
+ }
+
+ [Fact]
+ public void IsDimensionlessMethodImplementedCorrectly()
+ {
+ Assert.True(BaseDimensions.Dimensionless.IsDimensionless());
+ Assert.True(new BaseDimensions(0, 0, 0, 0, 0, 0, 0).IsDimensionless());
+
+ Assert.False(BaseDimensions.Dimensionless.IsBaseQuantity());
+ Assert.False(BaseDimensions.Dimensionless.IsDerivedQuantity());
+
+ // Example case
+ Assert.True(Level.BaseDimensions.IsDimensionless());
+ }
}
}
diff --git a/UnitsNet.Tests/BaseUnitsTests.cs b/UnitsNet.Tests/BaseUnitsTests.cs
new file mode 100644
index 0000000000..ad3a31370d
--- /dev/null
+++ b/UnitsNet.Tests/BaseUnitsTests.cs
@@ -0,0 +1,121 @@
+// 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;
+
+namespace UnitsNet.Tests
+{
+ public class BaseUnitsTests
+ {
+ private static BaseUnits siBaseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second,
+ ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela);
+
+ private static BaseUnits siBaseUnitsCopy = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second,
+ ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela);
+
+ private static BaseUnits nonSiBaseUnits = new BaseUnits(LengthUnit.Foot, MassUnit.Pound, DurationUnit.Second,
+ ElectricCurrentUnit.Ampere, TemperatureUnit.DegreeFahrenheit, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela);
+
+ [Fact]
+ public void ConstructorSetsUnitsProperly()
+ {
+ var baseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second,
+ ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela);
+
+ Assert.Equal(LengthUnit.Meter, baseUnits.Length);
+ Assert.Equal(MassUnit.Kilogram, baseUnits.Mass);
+ Assert.Equal(DurationUnit.Second, baseUnits.Time);
+ Assert.Equal(ElectricCurrentUnit.Ampere, baseUnits.Current);
+ Assert.Equal(TemperatureUnit.Kelvin, baseUnits.Temperature);
+ Assert.Equal(AmountOfSubstanceUnit.Mole, baseUnits.Amount);
+ Assert.Equal(LuminousIntensityUnit.Candela, baseUnits.LuminousIntensity);
+ }
+
+ [Fact]
+ public void EqualsObjectIsImplementedCorrectly()
+ {
+ Assert.True(siBaseUnits.Equals((object)siBaseUnitsCopy));
+ Assert.False(siBaseUnits.Equals((object)nonSiBaseUnits));
+
+ Assert.False(siBaseUnits.Equals("Some object."));
+ Assert.False(siBaseUnits.Equals((IFormatProvider)null));
+ }
+
+ [Fact]
+ public void EqualsBaseUnitsIsImplementedCorrectly()
+ {
+ Assert.True(siBaseUnits.Equals(siBaseUnitsCopy));
+ Assert.True(siBaseUnitsCopy.Equals(siBaseUnits));
+
+ Assert.False(siBaseUnits.Equals(nonSiBaseUnits));
+ Assert.False(nonSiBaseUnits.Equals(siBaseUnits));
+
+ Assert.False(siBaseUnits.Equals(null));
+ }
+
+ [Fact]
+ public void EqualityOperatorIsImplementedCorrectly()
+ {
+ Assert.True(siBaseUnits == siBaseUnitsCopy);
+ Assert.True(siBaseUnitsCopy == siBaseUnits);
+
+ Assert.False(siBaseUnits == nonSiBaseUnits);
+ Assert.False(nonSiBaseUnits == siBaseUnits);
+
+ Assert.False(siBaseUnits == null);
+ Assert.False(null == siBaseUnits);
+
+ BaseUnits nullBaseUnits1 = null;
+ BaseUnits nullBaseUnits2 = null;
+
+ Assert.True(nullBaseUnits1 == nullBaseUnits2);
+ }
+
+ [Fact]
+ public void InequalityOperatorIsImplementedCorrectly()
+ {
+ Assert.False(siBaseUnits != siBaseUnitsCopy);
+ Assert.False(siBaseUnitsCopy != siBaseUnits);
+
+ Assert.True(siBaseUnits != nonSiBaseUnits);
+ Assert.True(nonSiBaseUnits != siBaseUnits);
+
+ Assert.True(siBaseUnits != null);
+ Assert.True(null != siBaseUnits);
+
+ BaseUnits nullBaseUnits1 = null;
+ BaseUnits nullBaseUnits2 = null;
+
+ Assert.False(nullBaseUnits1 != nullBaseUnits2);
+ }
+
+ [Fact]
+ public void ToStringGivesExpectedResult()
+ {
+ var siBaseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second,
+ ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela);
+
+ Assert.Equal("[Length]: m, [Mass]: kg, [Time]: s, [Current]: A, [Temperature]: K, [Amount]: mol, [LuminousIntensity]: cd", siBaseUnits.ToString());
+ }
+ }
+}
diff --git a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs
index ef6c3ed41b..d284b7f023 100644
--- a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs
index 9b7482563f..a650941520 100644
--- a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs
+++ b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs
@@ -21,7 +21,6 @@
using System;
using Xunit;
-using UnitsNet.CustomCode.Extensions;
namespace UnitsNet.Tests.CustomCode
{
@@ -84,7 +83,7 @@ public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRati
// Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio.
AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio);
- double actual = AmplitudeRatio.ToElectricPotential(ar).Volts;
+ double actual = ar.ToElectricPotential().Volts;
Assert.Equal(expected, actual);
}
@@ -116,4 +115,4 @@ public void AmplitudeRatioToPowerRatio_75OhmImpedance(double dBmV, double expect
Assert.Equal(expected, actual);
}
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/ApparentEnergyTests.cs b/UnitsNet.Tests/CustomCode/ApparentEnergyTests.cs
index bc236df045..b001be250f 100644
--- a/UnitsNet.Tests/CustomCode/ApparentEnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/ApparentEnergyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ApparentPowerTests.cs b/UnitsNet.Tests/CustomCode/ApparentPowerTests.cs
index 07a48e333e..066da56e4f 100644
--- a/UnitsNet.Tests/CustomCode/ApparentPowerTests.cs
+++ b/UnitsNet.Tests/CustomCode/ApparentPowerTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs
index 922c143ebb..b6bf0a4f41 100644
--- a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs b/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs
index 280bab5459..b19e8aa559 100644
--- a/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs
+++ b/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs
index 8976f45049..2029c00eca 100644
--- a/UnitsNet.Tests/CustomCode/BitRateTests.cs
+++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs
index fbe02ac43f..e141a6ac58 100644
--- a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs
+++ b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -21,7 +21,6 @@
using Xunit;
-using System;
namespace UnitsNet.Tests.CustomCode
{
diff --git a/UnitsNet.Tests/CustomCode/CapacitanceTests.cs b/UnitsNet.Tests/CustomCode/CapacitanceTests.cs
index e86764476e..a2ab1a95d5 100644
--- a/UnitsNet.Tests/CustomCode/CapacitanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/CapacitanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/DensityTests.cs b/UnitsNet.Tests/CustomCode/DensityTests.cs
index 6901649b4a..4905088137 100644
--- a/UnitsNet.Tests/CustomCode/DensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/DensityTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -19,9 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xunit;
-using UnitsNet.CustomCode.Extensions;
namespace UnitsNet.Tests.CustomCode
{
diff --git a/UnitsNet.Tests/CustomCode/DurationTests.cs b/UnitsNet.Tests/CustomCode/DurationTests.cs
index 4ad5c3338e..75249bc3ab 100644
--- a/UnitsNet.Tests/CustomCode/DurationTests.cs
+++ b/UnitsNet.Tests/CustomCode/DurationTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -36,8 +36,6 @@ public class DurationTests : DurationTestsBase
protected override double MinutesInOneSecond => 0.0166667;
- protected override double MonthsInOneSecond => 3.858024691358024e-7;
-
protected override double Months30InOneSecond => 3.858024691358024e-7;
protected override double NanosecondsInOneSecond => 1e+9;
@@ -46,8 +44,6 @@ public class DurationTests : DurationTestsBase
protected override double WeeksInOneSecond => 1.653439153439153e-6;
- protected override double YearsInOneSecond => 3.170979198376458e-8;
-
protected override double Years365InOneSecond => 3.170979198376458e-8;
[Fact]
@@ -180,38 +176,6 @@ public static void DurationGreaterThanOrEqualTimeSpanShouldReturnCorrectly()
Assert.True(duration >= timeSpan, "duration should be greater than timeSpan");
}
- [Fact]
- public static void DurationEqualToTimeSpanShouldReturnCorrectly()
- {
- TimeSpan timeSpan = TimeSpan.FromHours(11);
- Duration duration = Duration.FromHours(11);
- Assert.True(duration == timeSpan, "duration should be equal to timeSpan");
- }
-
- [Fact]
- public static void TimeSpanEqualToDurationShouldReturnCorrectly()
- {
- TimeSpan timeSpan = TimeSpan.FromHours(11);
- Duration duration = Duration.FromHours(11);
- Assert.True(timeSpan == duration, "timeSpan should be equal to duration");
- }
-
- [Fact]
- public static void DurationNotEqualToTimeSpanShouldReturnCorrectly()
- {
- TimeSpan timeSpan = TimeSpan.FromHours(12);
- Duration duration = Duration.FromHours(11);
- Assert.True(duration != timeSpan, "duration should not be equal to timeSpan");
- }
-
- [Fact]
- public static void TimeSpanNotEqualToDurationShouldReturnCorrectly()
- {
- TimeSpan timeSpan = TimeSpan.FromHours(12);
- Duration duration = Duration.FromHours(11);
- Assert.True(timeSpan != duration, "timeSpan should not be equal to duration");
- }
-
[Fact]
public void DurationTimesVolumeFlowEqualsVolume()
{
diff --git a/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs b/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs
index f4042366cd..553665afe4 100644
--- a/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs
+++ b/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -20,7 +20,6 @@
// THE SOFTWARE.
-using System;
using Xunit;
namespace UnitsNet.Tests.CustomCode
diff --git a/UnitsNet.Tests/CustomCode/ElectricAdmittanceTests.cs b/UnitsNet.Tests/CustomCode/ElectricAdmittanceTests.cs
index f959da1045..835c7855a8 100644
--- a/UnitsNet.Tests/CustomCode/ElectricAdmittanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricAdmittanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricChargeDensityTests.cs b/UnitsNet.Tests/CustomCode/ElectricChargeDensityTests.cs
index b5008086dd..abcd5331a1 100644
--- a/UnitsNet.Tests/CustomCode/ElectricChargeDensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricChargeDensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricChargeTests.cs b/UnitsNet.Tests/CustomCode/ElectricChargeTests.cs
index e2107792e7..98075fb856 100644
--- a/UnitsNet.Tests/CustomCode/ElectricChargeTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricChargeTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs
index 32ee7dc2ff..fa3cf847dd 100644
--- a/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
index 10ea9c0615..ac2f37a5e7 100644
--- a/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricCurrentDensityTests.cs b/UnitsNet.Tests/CustomCode/ElectricCurrentDensityTests.cs
index fd8ab2446f..421f3f14d0 100644
--- a/UnitsNet.Tests/CustomCode/ElectricCurrentDensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricCurrentDensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricCurrentGradientTests.cs b/UnitsNet.Tests/CustomCode/ElectricCurrentGradientTests.cs
index 937e22b069..9e62a7759c 100644
--- a/UnitsNet.Tests/CustomCode/ElectricCurrentGradientTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricCurrentGradientTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricCurrentTests.cs b/UnitsNet.Tests/CustomCode/ElectricCurrentTests.cs
index c79bf46a8a..92cc98f875 100644
--- a/UnitsNet.Tests/CustomCode/ElectricCurrentTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricCurrentTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -19,8 +19,6 @@
// 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 ElectricCurrentTests : ElectricCurrentTestsBase
diff --git a/UnitsNet.Tests/CustomCode/ElectricFieldTests.cs b/UnitsNet.Tests/CustomCode/ElectricFieldTests.cs
index 61e5f68e53..40d8a00324 100644
--- a/UnitsNet.Tests/CustomCode/ElectricFieldTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricFieldTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricInductanceTests.cs b/UnitsNet.Tests/CustomCode/ElectricInductanceTests.cs
index 3154f54719..1553851dba 100644
--- a/UnitsNet.Tests/CustomCode/ElectricInductanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricInductanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricPotentialAcTests.cs b/UnitsNet.Tests/CustomCode/ElectricPotentialAcTests.cs
index 8a5f7a5cc3..1be6811f5a 100644
--- a/UnitsNet.Tests/CustomCode/ElectricPotentialAcTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricPotentialAcTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricPotentialDcTests.cs b/UnitsNet.Tests/CustomCode/ElectricPotentialDcTests.cs
index 56fc31aaa6..80036962cc 100644
--- a/UnitsNet.Tests/CustomCode/ElectricPotentialDcTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricPotentialDcTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs b/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
index 8ed53eaeac..0ddb5cc712 100644
--- a/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/EnergyTests.cs b/UnitsNet.Tests/CustomCode/EnergyTests.cs
index c13006e2f1..3febc639e3 100644
--- a/UnitsNet.Tests/CustomCode/EnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/EnergyTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -23,7 +23,6 @@ namespace UnitsNet.Tests.CustomCode
{
public class EnergyTests : EnergyTestsBase
{
- // TODO Override properties in base class here
protected override double ThermsImperialInOneJoule => 9.478171203551087813109937767482e-9;
protected override double JoulesInOneJoule => 1;
diff --git a/UnitsNet.Tests/CustomCode/EntropyTests.cs b/UnitsNet.Tests/CustomCode/EntropyTests.cs
index 69c474b096..9f98fcf392 100644
--- a/UnitsNet.Tests/CustomCode/EntropyTests.cs
+++ b/UnitsNet.Tests/CustomCode/EntropyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/FlowTests.cs b/UnitsNet.Tests/CustomCode/FlowTests.cs
deleted file mode 100644
index 9742af1064..0000000000
--- a/UnitsNet.Tests/CustomCode/FlowTests.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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.
-
-namespace UnitsNet.Tests.CustomCode
-{
- public class FlowTests : FlowTestsBase
- {
- protected override double CubicMetersPerHourInOneCubicMeterPerSecond => 3600.0;
-
- protected override double CubicDecimetersPerMinuteInOneCubicMeterPerSecond => 60000.00000;
-
- protected override double CubicFeetPerHourInOneCubicMeterPerSecond => 1.271328001973604e+5;
-
- protected override double CubicFeetPerSecondInOneCubicMeterPerSecond => 35.314666721489;
-
- protected override double MillionUsGallonsPerDayInOneCubicMeterPerSecond => 22.824465227;
-
- protected override double CubicMetersPerSecondInOneCubicMeterPerSecond => 1;
-
- protected override double UsGallonsPerMinuteInOneCubicMeterPerSecond => 15850.323141489;
- protected override double LitersPerHourInOneCubicMeterPerSecond => 3600000;
-
- protected override double LitersPerMinuteInOneCubicMeterPerSecond => 60000.00000;
-
- protected override double NanolitersPerMinuteInOneCubicMeterPerSecond => 60000000000000.00000;
- protected override double LitersPerSecondInOneCubicMeterPerSecond => 1000;
-
- protected override double MicrolitersPerMinuteInOneCubicMeterPerSecond => 60000000000.00000;
-
- protected override double MillilitersPerMinuteInOneCubicMeterPerSecond => 60000000.00000;
-
- protected override double CentilitersPerMinuteInOneCubicMeterPerSecond => 6000000.00000;
-
- protected override double DecilitersPerMinuteInOneCubicMeterPerSecond => 600000.00000;
-
- protected override double KilolitersPerMinuteInOneCubicMeterPerSecond => 60.00000;
-
- protected override double OilBarrelsPerDayInOneCubicMeterPerSecond => 543439.65056533388306722269588172;
-
- protected override double CubicFeetPerMinuteInOneCubicMeterPerSecond => 2.11888E3;
-
- protected override double CubicMetersPerMinuteInOneCubicMeterPerSecond => 6.0E1;
-
- protected override double CubicYardsPerHourInOneCubicMeterPerSecond => 4.708622232E3;
-
- protected override double CubicYardsPerMinuteInOneCubicMeterPerSecond => 7.84770372E1;
-
- protected override double CubicYardsPerSecondInOneCubicMeterPerSecond => 1.30795062;
-
- protected override double UsGallonsPerHourInOneCubicMeterPerSecond => 9.510193884893328E5;
-
- protected override double UsGallonsPerSecondInOneCubicMeterPerSecond => 2.64172052358148E2;
- }
-}
\ No newline at end of file
diff --git a/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs b/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs
index f745d802aa..8edf0b4aa0 100644
--- a/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs
+++ b/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -19,8 +19,6 @@
// 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 ForceChangeRateTests : ForceChangeRateTestsBase
@@ -37,4 +35,4 @@ public class ForceChangeRateTests : ForceChangeRateTestsBase
protected override double MicronewtonsPerSecondInOneNewtonPerSecond => 1E6;
protected override double NanonewtonsPerSecondInOneNewtonPerSecond => 1E9;
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs b/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs
index 38a9735808..5d5b8241b3 100644
--- a/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs
+++ b/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs
@@ -9,7 +9,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs
index 1e157075fb..305300776b 100644
--- a/UnitsNet.Tests/CustomCode/ForceTests.cs
+++ b/UnitsNet.Tests/CustomCode/ForceTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -57,26 +57,19 @@ public void ForceDividedByAreaEqualsPressure()
}
[Fact]
- public void PressureByAreaEqualsForceUsingArea()
+ public void PressureByAreaEqualsForce()
{
Force force = Force.FromPressureByArea(Pressure.FromNewtonsPerSquareMeter(5), Area.FromSquareMeters(7));
Assert.Equal(force, Force.FromNewtons(35));
}
- [Fact]
- public void PressureByAreaEqualsForceUsingLength2D()
- {
- var force = Force.FromPressureByArea(Pressure.FromNewtonsPerSquareMeter(6), Length2d.FromMeters(5, 2));
- Assert.Equal(force, Force.FromNewtons(60));
- }
-
[Fact]
public void ForceDividedByMassEqualsAcceleration()
{
Acceleration acceleration = Force.FromNewtons(27)/Mass.FromKilograms(9);
Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(3));
}
-
+
[Fact]
public void ForceDividedByAccelerationEqualsMass()
{
@@ -91,12 +84,6 @@ public void ForceDividedByLengthEqualsForcePerLength()
Assert.Equal(forcePerLength, ForcePerLength.FromNewtonsPerMeter(4));
}
- [Fact]
- public void MassByAccelerationEqualsForceUsingDouble()
- {
- var force = Force.FromMassByAcceleration(Mass.FromKilograms(9), 3);
- Assert.Equal(force, Force.FromNewtons(27));
- }
[Fact]
public void MassByAccelerationEqualsForce()
{
diff --git a/UnitsNet.Tests/CustomCode/HeatFluxTests.cs b/UnitsNet.Tests/CustomCode/HeatFluxTests.cs
index 6382cb5821..d6633e3eab 100644
--- a/UnitsNet.Tests/CustomCode/HeatFluxTests.cs
+++ b/UnitsNet.Tests/CustomCode/HeatFluxTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/HeatTransferCoefficientTests.cs b/UnitsNet.Tests/CustomCode/HeatTransferCoefficientTests.cs
index 382367f6a7..80e8eec10f 100644
--- a/UnitsNet.Tests/CustomCode/HeatTransferCoefficientTests.cs
+++ b/UnitsNet.Tests/CustomCode/HeatTransferCoefficientTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/IlluminanceTests.cs b/UnitsNet.Tests/CustomCode/IlluminanceTests.cs
index b7888ebb4d..3857dd38e8 100644
--- a/UnitsNet.Tests/CustomCode/IlluminanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/IlluminanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/IrradianceTests.cs b/UnitsNet.Tests/CustomCode/IrradianceTests.cs
index 3ee6591e6b..ec11504bc0 100644
--- a/UnitsNet.Tests/CustomCode/IrradianceTests.cs
+++ b/UnitsNet.Tests/CustomCode/IrradianceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/IrradiationTests.cs b/UnitsNet.Tests/CustomCode/IrradiationTests.cs
index 555b488d70..4881e68d08 100644
--- a/UnitsNet.Tests/CustomCode/IrradiationTests.cs
+++ b/UnitsNet.Tests/CustomCode/IrradiationTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/LapseRateTests.cs b/UnitsNet.Tests/CustomCode/LapseRateTests.cs
index 4ae15baa1e..f65015bd56 100644
--- a/UnitsNet.Tests/CustomCode/LapseRateTests.cs
+++ b/UnitsNet.Tests/CustomCode/LapseRateTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
@@ -52,14 +51,14 @@ public class LapseRateTests : LapseRateTestsBase
[Fact]
public void TemperatureDeltaDividedByLapseRateEqualsLength()
{
- Length length = TemperatureDelta.FromDegreesCelsiusDelta(50) / LapseRate.FromDegreesCelciusPerKilometer(5);
+ Length length = TemperatureDelta.FromDegreesCelsius(50) / LapseRate.FromDegreesCelciusPerKilometer(5);
Assert.Equal(length, Length.FromKilometers(10));
}
[Fact]
public void TemperatureDeltaDividedByLengthEqualsLapseRate()
{
- LapseRate lapseRate = TemperatureDelta.FromDegreesCelsiusDelta(50) / Length.FromKilometers(10);
+ LapseRate lapseRate = TemperatureDelta.FromDegreesCelsius(50) / Length.FromKilometers(10);
Assert.Equal(lapseRate, LapseRate.FromDegreesCelciusPerKilometer(5));
}
@@ -67,14 +66,14 @@ public void TemperatureDeltaDividedByLengthEqualsLapseRate()
public void LengthMultipliedByLapseRateEqualsTemperatureDelta()
{
TemperatureDelta temperatureDelta = Length.FromKilometers(10) * LapseRate.FromDegreesCelciusPerKilometer(5);
- Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsiusDelta(50));
+ Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50));
}
[Fact]
public void LapseRateMultipliedByLengthEqualsTemperatureDelta()
{
TemperatureDelta temperatureDelta = LapseRate.FromDegreesCelciusPerKilometer(5) * Length.FromKilometers(10);
- Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsiusDelta(50));
+ Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50));
}
}
}
diff --git a/UnitsNet.Tests/CustomCode/Length2dTests.cs b/UnitsNet.Tests/CustomCode/Length2dTests.cs
deleted file mode 100644
index 06f0b3ff5b..0000000000
--- a/UnitsNet.Tests/CustomCode/Length2dTests.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-// 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 Xunit;
-
-namespace UnitsNet.Tests.CustomCode
-{
-// ReSharper disable once InconsistentNaming
- public class Length2dTests
- {
- private const double Delta = 1E-5;
-
- private void AssertAreEqual(Vector2 expected, Vector2 actual, double delta)
- {
- AssertEx.EqualTolerance(expected.X, actual.X, Delta);
- AssertEx.EqualTolerance(expected.Y, actual.Y, Delta);
- }
-
-
- [Fact]
- public void ArithmeticOperators()
- {
- Length2d v = Length2d.FromMeters(1, 2);
- AssertEx.EqualTolerance(-1, -v.Meters.X, Delta);
- AssertEx.EqualTolerance(-2, -v.Meters.Y, Delta);
- AssertEx.EqualTolerance(2, (Length2d.FromMeters(3, 3) - v).Meters.X, Delta);
- AssertEx.EqualTolerance(1, (Length2d.FromMeters(3, 3) - v).Meters.Y, Delta);
- AssertEx.EqualTolerance(2, (v + v).Meters.X, Delta);
- AssertEx.EqualTolerance(4, (v + v).Meters.Y, Delta);
- AssertEx.EqualTolerance(10, (v*10).Meters.X, Delta);
- AssertEx.EqualTolerance(20, (v*10).Meters.Y, Delta);
- AssertEx.EqualTolerance(10, (10*v).Meters.X, Delta);
- AssertEx.EqualTolerance(20, (10*v).Meters.Y, Delta);
- AssertEx.EqualTolerance(2, (Length2d.FromMeters(2, 2)*v).Meters.X, Delta);
- AssertEx.EqualTolerance(4, (Length2d.FromMeters(2, 2)*v).Meters.Y, Delta);
- AssertEx.EqualTolerance(2, (Length2d.FromMeters(10, 20)/5).Meters.X, Delta);
- AssertEx.EqualTolerance(4, (Length2d.FromMeters(10, 20)/5).Meters.Y, Delta);
- AssertEx.EqualTolerance(2, (Length2d.FromMeters(10, 20)/Length2d.FromMeters(5, 5)).X, Delta);
- AssertEx.EqualTolerance(4, (Length2d.FromMeters(10, 20)/Length2d.FromMeters(5, 5)).Y, Delta);
- }
-
- [Fact]
- public void DistanceUnitsRoundTrip()
- {
- Length meter = Length.FromMeters(1);
-
- AssertEx.EqualTolerance(1, Length.FromKilometers(meter.Kilometers).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromMeters(meter.Meters).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromDecimeters(meter.Decimeters).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromCentimeters(meter.Centimeters).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromMillimeters(meter.Millimeters).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromMicrometers(meter.Micrometers).Meters, Delta);
- AssertEx.EqualTolerance(1, Length.FromNanometers(meter.Nanometers).Meters, Delta);
- }
-
- [Fact]
- public void EqualityOperators()
- {
- Length2d a = Length2d.FromMeters(1, 2);
- Length2d b = Length2d.FromMeters(2, 1);
-
- // ReSharper disable EqualExpressionComparison
- // Disable build warning: Comparison made to same variable; did you mean to compare something else?
-#pragma warning disable 1718
- Assert.True(a == a);
- Assert.True(a != b);
-
- Assert.False(a == b);
- Assert.False(a != a);
-#pragma warning restore 1718
- // ReSharper restore EqualExpressionComparison
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- Length2d v = Length2d.FromMeters(1, 2);
- Assert.True(v.Equals(Length2d.FromMeters(1, 2)));
- Assert.False(v.Equals(Length2d.Zero));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Length2d newton = Length2d.FromMeters(1, 2);
- Assert.False(newton.Equals(null));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Length2d newton = Length2d.FromMeters(1, 2);
- Assert.False(newton.Equals(new object()));
- }
-
- [Fact]
- public void MetersToDistanceUnits()
- {
- Length2d meter = Length2d.FromMeters(1, 1);
-
- AssertAreEqual(new Vector2(1), meter.Meters, Delta);
- AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
- AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
- AssertAreEqual(new Vector2(1E-3), meter.Kilometers, Delta);
- AssertAreEqual(new Vector2(1), meter.Meters, Delta);
- AssertAreEqual(new Vector2(1E1), meter.Decimeters, Delta);
- AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
- AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
- AssertAreEqual(new Vector2(1E6), meter.Micrometers, Delta);
- AssertAreEqual(new Vector2(1E9), meter.Nanometers, Delta);
-
- AssertEx.EqualTolerance(0.000621371, meter.Miles.X, Delta);
- AssertEx.EqualTolerance(0.000621371, meter.Miles.Y, Delta);
- AssertEx.EqualTolerance(1.09361, meter.Yards.X, Delta);
- AssertEx.EqualTolerance(1.09361, meter.Yards.Y, Delta);
- AssertEx.EqualTolerance(3.28084, meter.Feet.X, Delta);
- AssertEx.EqualTolerance(3.28084, meter.Feet.Y, Delta);
- AssertEx.EqualTolerance(39.37007874, meter.Inches.X, Delta);
- AssertEx.EqualTolerance(39.37007874, meter.Inches.Y, Delta);
- }
-
- [Fact]
- public void VectorLength()
- {
- var v = new Length2d(3, 4);
- Assert.Equal(5, v.Length.Meters);
- }
- }
-}
\ No newline at end of file
diff --git a/UnitsNet.Tests/CustomCode/FeetInchesTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs
similarity index 54%
rename from UnitsNet.Tests/CustomCode/FeetInchesTests.cs
rename to UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs
index 73dd817f8e..715a655fed 100644
--- a/UnitsNet.Tests/CustomCode/FeetInchesTests.cs
+++ b/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs
@@ -1,16 +1,16 @@
// 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
@@ -46,5 +46,46 @@ public void FeetInchesRoundTrip()
AssertEx.EqualTolerance(2, feetInches.Feet, FeetTolerance);
AssertEx.EqualTolerance(3, feetInches.Inches, InchesTolerance);
}
+
+ [Theory]
+ [InlineData("1'", 1)] // Feet only
+ [InlineData("1′", 1)] // Feet only
+ [InlineData("1\"", 0.08333333)] // Inches only
+ [InlineData("1″", 0.08333333)] // Inches only
+ [InlineData("1' 1\"", 1.08333333)] // Normal form
+ [InlineData("1′ 1″", 1.08333333)] // Normal form
+ [InlineData(" 1′ 1″ ", 1.08333333)] // Normal form, requires trimming
+ [InlineData("1'1\"", 1.08333333)] // Without space
+ [InlineData("1′1″", 1.08333333)] // Without space
+ [InlineData("1 ft 1 in", 1.08333333)]
+ [InlineData("1ft 1in", 1.08333333)]
+ public void TryParseFeetInches(string str, double expectedFeet)
+ {
+ Assert.True(Length.TryParseFeetInches(str, out Length result));
+ AssertEx.EqualTolerance(expectedFeet, result.Feet, 1e-5);
+ }
+
+ [Theory]
+ [InlineData("a")] // Missing or invalid apostrophe or double prime chars
+ [InlineData("1")]
+ [InlineData("1`")]
+ [InlineData("1^")]
+ [InlineData("1' 1'")] // Feet apostrophe twice
+ [InlineData("1′ 1′")]
+ [InlineData("1' 1")] // No inches double prime
+ [InlineData("1′ 1")]
+ [InlineData("1′ 1`")] // Invalid inches double prime
+ [InlineData("1' 1`")]
+ [InlineData("1'1'")] // Same without space
+ [InlineData("1′1′")]
+ [InlineData("1'1")]
+ [InlineData("1′1")]
+ [InlineData("1′1`")]
+ [InlineData("1'1`")]
+ public void TryParseFeetInches_GivenInvalidString_ReturnsFalseAndZeroOut(string str)
+ {
+ Assert.False(Length.TryParseFeetInches(str, out Length result));
+ Assert.Equal(Length.Zero, result);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs
index 9b64a25383..df789dbdca 100644
--- a/UnitsNet.Tests/CustomCode/LengthTests.cs
+++ b/UnitsNet.Tests/CustomCode/LengthTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -19,7 +19,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xunit;
using UnitsNet.Units;
@@ -28,7 +27,7 @@ namespace UnitsNet.Tests.CustomCode
// Avoid accessing static prop DefaultToString in parallel from multiple tests:
// UnitSystemTests.DefaultToStringFormatting()
// LengthTests.ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit()
- [Collection(nameof(UnitSystemFixture))]
+ [Collection(nameof(UnitAbbreviationsCacheFixture))]
public class LengthTests : LengthTestsBase
{
protected override double CentimetersInOneMeter => 100;
@@ -61,7 +60,7 @@ public class LengthTests : LengthTestsBase
protected override double NanometersInOneMeter => 1E9;
protected override double YardsInOneMeter => 1.09361;
-
+
protected override double FathomsInOneMeter => 0.546806649;
protected override double PrinterPicasInOneMeter => 237.10630158;
@@ -130,22 +129,16 @@ public void LengthTimesSpecificWeightEqualsPressure()
[Fact]
public void ToStringReturnsCorrectNumberAndUnitWithDefaultUnitWhichIsMeter()
{
- LengthUnit oldUnit = Length.ToStringDefaultUnit;
- Length.ToStringDefaultUnit = LengthUnit.Meter;
- Length meter = Length.FromMeters(5);
+ var meter = Length.FromMeters(5);
string meterString = meter.ToString();
- Length.ToStringDefaultUnit = oldUnit;
Assert.Equal("5 m", meterString);
}
[Fact]
public void ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit()
{
- LengthUnit oldUnit = Length.ToStringDefaultUnit;
- Length.ToStringDefaultUnit = LengthUnit.Centimeter;
- Length value = Length.From(2, LengthUnit.Centimeter);
+ var value = Length.From(2, LengthUnit.Centimeter);
string valueString = value.ToString();
- Length.ToStringDefaultUnit = oldUnit;
Assert.Equal("2 cm", valueString);
}
diff --git a/UnitsNet.Tests/CustomCode/LinearDensityTests.cs b/UnitsNet.Tests/CustomCode/LinearDensityTests.cs
index 12a3e096d7..dba00a625b 100644
--- a/UnitsNet.Tests/CustomCode/LinearDensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/LinearDensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs b/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs
index 28249e44b2..bcffaaaa54 100644
--- a/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs
+++ b/UnitsNet.Tests/CustomCode/LuminousFluxTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/LuminousIntensityTests.cs b/UnitsNet.Tests/CustomCode/LuminousIntensityTests.cs
index e5628edd65..f23f7f7901 100644
--- a/UnitsNet.Tests/CustomCode/LuminousIntensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/LuminousIntensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MagneticFieldTests.cs b/UnitsNet.Tests/CustomCode/MagneticFieldTests.cs
index 84574014f7..8aa59ffb31 100644
--- a/UnitsNet.Tests/CustomCode/MagneticFieldTests.cs
+++ b/UnitsNet.Tests/CustomCode/MagneticFieldTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MagneticFluxTests.cs b/UnitsNet.Tests/CustomCode/MagneticFluxTests.cs
index 40cf6c214f..647cc7e9d4 100644
--- a/UnitsNet.Tests/CustomCode/MagneticFluxTests.cs
+++ b/UnitsNet.Tests/CustomCode/MagneticFluxTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MagnetizationTests.cs b/UnitsNet.Tests/CustomCode/MagnetizationTests.cs
index d2be75815d..bb4ab57af1 100644
--- a/UnitsNet.Tests/CustomCode/MagnetizationTests.cs
+++ b/UnitsNet.Tests/CustomCode/MagnetizationTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MassFluxTests.cs b/UnitsNet.Tests/CustomCode/MassFluxTests.cs
index 797e0f01aa..18ff2333d8 100644
--- a/UnitsNet.Tests/CustomCode/MassFluxTests.cs
+++ b/UnitsNet.Tests/CustomCode/MassFluxTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MassMomentOfInertiaTests.cs b/UnitsNet.Tests/CustomCode/MassMomentOfInertiaTests.cs
index fb6722c264..79c3cae71e 100644
--- a/UnitsNet.Tests/CustomCode/MassMomentOfInertiaTests.cs
+++ b/UnitsNet.Tests/CustomCode/MassMomentOfInertiaTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs b/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs
index 3bf535be10..b9aaf18adf 100644
--- a/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/MolarEnergyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MolarEntropyTests.cs b/UnitsNet.Tests/CustomCode/MolarEntropyTests.cs
index 1b24dd86bf..b8a012804f 100644
--- a/UnitsNet.Tests/CustomCode/MolarEntropyTests.cs
+++ b/UnitsNet.Tests/CustomCode/MolarEntropyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MolarMassTests.cs b/UnitsNet.Tests/CustomCode/MolarMassTests.cs
index d05b1e8f40..231ecab43e 100644
--- a/UnitsNet.Tests/CustomCode/MolarMassTests.cs
+++ b/UnitsNet.Tests/CustomCode/MolarMassTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/MolarityTests.cs b/UnitsNet.Tests/CustomCode/MolarityTests.cs
index 305fa12c2d..92ebb8735e 100644
--- a/UnitsNet.Tests/CustomCode/MolarityTests.cs
+++ b/UnitsNet.Tests/CustomCode/MolarityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
@@ -42,7 +41,6 @@
using Xunit;
using System;
-using UnitsNet.CustomCode.Extensions;
namespace UnitsNet.Tests.CustomCode
{
diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs
index 3fb03de1a0..294c12d0e1 100644
--- a/UnitsNet.Tests/CustomCode/ParseTests.cs
+++ b/UnitsNet.Tests/CustomCode/ParseTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -21,8 +21,8 @@
using System;
using System.Globalization;
-using Xunit;
using UnitsNet.Units;
+using Xunit;
namespace UnitsNet.Tests.CustomCode
{
@@ -33,10 +33,12 @@ namespace UnitsNet.Tests.CustomCode
/// reasonable to assume that testing one unit class would cover
/// all of them. Obviously, that can change in the future.
///
+ [Collection(nameof(UnitAbbreviationsCacheFixture))]
public class ParseTests
{
[Theory]
[InlineData("1km", 1000)]
+ [InlineData(" 1km ", 1000)] // Check that it also trims string
[InlineData("1 km", 1000)]
[InlineData("1e-3 km", 1)]
[InlineData("5.5 m", 5.5)]
@@ -49,31 +51,16 @@ public void ParseLengthToMetersUsEnglish(string s, double expected)
}
[Theory]
- [InlineData(null, "System.ArgumentNullException")] // Can't parse null.
- [InlineData("1", "System.ArgumentException")] // No unit abbreviation.
- [InlineData("km", "UnitsNet.UnitsNetException")] // No value, wrong measurement type.
- [InlineData("1 kg", "UnitsNet.UnitsNetException")] // Wrong measurement type.
- [InlineData("1ft monkey 1in", "UnitsNet.UnitsNetException")] // Invalid separator between two valid measurements.
- [InlineData("1ft 1invalid", "UnitsNet.UnitsNetException")] // Valid
- public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, string expected)
- {
- CultureInfo usEnglish = new CultureInfo("en-US");
- string actual = AssertExceptionAndGetFullTypeName(() => Length.Parse(s, usEnglish));
- Assert.Equal(expected, actual);
- }
-
- [Theory]
- [InlineData("1 ft 1 in", 13)]
- [InlineData("1ft 1in", 13)]
- [InlineData("1' 1\"", 13)]
- [InlineData("1'1\"", 13)]
- [InlineData("1ft1in", 13)]
- [InlineData("1ft and 1in", 13)]
- public void ParseLength_FeetInchesString_USEnglish(string s, double expected)
+ [InlineData(null, typeof(ArgumentNullException))] // Can't parse null.
+ [InlineData("1", typeof(FormatException))] // No unit abbreviation.
+ [InlineData("km", typeof(FormatException))] // No value, wrong measurement type.
+ [InlineData("1 kg", typeof(FormatException))] // Wrong measurement type.
+ [InlineData("1ft monkey 1in", typeof(FormatException))] // Invalid separator between two valid measurements.
+ [InlineData("1ft 1invalid", typeof(FormatException))] // Valid
+ public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, Type expectedExceptionType)
{
- CultureInfo usEnglish = new CultureInfo("en-US");
- double actual = Length.Parse(s, usEnglish).Inches;
- Assert.Equal(expected, actual);
+ var usEnglish = new CultureInfo("en-US");
+ Assert.Throws(expectedExceptionType, () => Length.Parse(s, usEnglish));
}
/// Error parsing string.
@@ -85,23 +72,26 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expe
{
var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone();
numberFormat.NumberGroupSeparator = " ";
+ numberFormat.CurrencyGroupSeparator = " ";
numberFormat.NumberDecimalSeparator = ".";
+ numberFormat.CurrencyDecimalSeparator = ".";
double actual = Length.Parse(s, numberFormat).Meters;
Assert.Equal(expected, actual);
}
[Theory]
- [InlineData("500.005.050,001 m", "UnitsNet.UnitsNetException")]
+ [InlineData("500.005.050,001 m", typeof(FormatException))]
// quantity doesn't match number format
- public void ParseWithCultureUsingSpaceAsThousandSeparators_ThrowsExceptionOnInvalidString(string s, string expected)
+ public void ParseWithCultureUsingSpaceAsThousandSeparators_ThrowsExceptionOnInvalidString(string s, Type expectedExceptionType)
{
var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone();
numberFormat.NumberGroupSeparator = " ";
+ numberFormat.CurrencyGroupSeparator = " ";
numberFormat.NumberDecimalSeparator = ".";
+ numberFormat.CurrencyDecimalSeparator = ".";
- string actual = AssertExceptionAndGetFullTypeName(() => Length.Parse(s, numberFormat));
- Assert.Equal(expected, actual);
+ Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat));
}
/// Error parsing string.
@@ -113,7 +103,9 @@ public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expect
{
var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone();
numberFormat.NumberGroupSeparator = ".";
+ numberFormat.CurrencyGroupSeparator = ".";
numberFormat.NumberDecimalSeparator = ",";
+ numberFormat.CurrencyDecimalSeparator = ",";
double actual = Length.Parse(s, numberFormat).Meters;
Assert.Equal(expected, actual);
@@ -127,15 +119,16 @@ public void ParseMultiWordAbbreviations()
}
[Theory]
- [InlineData("500 005 m", "UnitsNet.UnitsNetException")] // Quantity doesn't match number format.
- public void ParseWithCultureUsingDotAsThousandSeparators_ThrowsExceptionOnInvalidString(string s, string expected)
+ [InlineData("500 005 m", typeof(FormatException))] // Quantity doesn't match number format.
+ public void ParseWithCultureUsingDotAsThousandSeparators_ThrowsExceptionOnInvalidString(string s, Type expectedExceptionType)
{
var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone();
numberFormat.NumberGroupSeparator = ".";
+ numberFormat.CurrencyGroupSeparator = ".";
numberFormat.NumberDecimalSeparator = ",";
+ numberFormat.CurrencyDecimalSeparator = ",";
- string actual = AssertExceptionAndGetFullTypeName(() => Length.Parse(s, numberFormat));
- Assert.Equal(expected, actual);
+ Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat));
}
[Theory]
@@ -148,18 +141,17 @@ public void ParseLengthUnitUsEnglish(string s, LengthUnit expected)
}
[Theory]
- [InlineData("kg", "UnitsNet.UnitNotFoundException")]
- [InlineData(null, "System.ArgumentNullException")]
- public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, string expected)
+ [InlineData("kg", typeof(UnitNotFoundException))]
+ [InlineData(null, typeof(ArgumentNullException))]
+ public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, Type expectedExceptionType)
{
- CultureInfo usEnglish = new CultureInfo("en-US");
- string actual = AssertExceptionAndGetFullTypeName(() => Length.ParseUnit(s, usEnglish));
- Assert.Equal(expected, actual);
+ var usEnglish = new CultureInfo("en-US");
+ Assert.Throws(expectedExceptionType, () => Length.ParseUnit(s, usEnglish));
}
[Theory]
[InlineData("1 m", true)]
- [InlineData("1 m 50 cm", true)]
+ [InlineData("1 m 50 cm", false)]
[InlineData("2 kg", false)]
[InlineData(null, false)]
[InlineData("foo", false)]
@@ -169,70 +161,5 @@ public void TryParseLengthUnitUsEnglish(string s, bool expected)
bool actual = Length.TryParse(s, usEnglish, out Length _);
Assert.Equal(expected, actual);
}
-
- [Theory]
- [InlineData("!")]
- [InlineData("@")]
- [InlineData("#")]
- [InlineData("$")]
- [InlineData("%")]
- [InlineData("^")]
- [InlineData("&")]
- [InlineData("*")]
- [InlineData("-")]
- [InlineData("_")]
- [InlineData("?")]
- [InlineData("123")]
- [InlineData(" ")]
- public void TryParseLengthUnitAbbreviationSpecialCharacters(string s)
- {
- string abbrev = $"m{s}s";
-
- UnitSystem unitSystem = UnitSystem.GetCached();
- unitSystem.MapUnitToAbbreviation(LengthUnit.Meter, abbrev);
-
- // Act
- bool ok = unitSystem.TryParse(abbrev, out LengthUnit result);
-
- // Assert
- Assert.True(ok, "TryParse " + abbrev);
- Assert.Equal(LengthUnit.Meter, result);
- }
-
- [Theory]
- [InlineData("!")]
- [InlineData("@")]
- [InlineData("#")]
- [InlineData("$")]
- [InlineData("%")]
- [InlineData("^")]
- [InlineData("&")]
- [InlineData("*")]
- [InlineData("-")]
- [InlineData("_")]
- [InlineData("?")]
- [InlineData("123")]
- [InlineData(" ")]
- public void TryParseLengthSpecialCharacters(string s)
- {
- string abbrev = $"m{s}s";
-
- UnitSystem unitSystem = UnitSystem.GetCached();
- unitSystem.MapUnitToAbbreviation(LengthUnit.Meter, abbrev);
-
- // Act
- bool ok = Length.TryParse($"10 {abbrev}", out Length result);
-
- // Assert
- Assert.True(ok, $"TryParse \"10 {abbrev}\"");
- Assert.Equal(10, result.Meters);
- }
-
- private static string AssertExceptionAndGetFullTypeName(Action code)
- {
- var exception = Assert.ThrowsAny(code);
- return exception.GetType().FullName;
- }
-
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/PermeabilityTests.cs b/UnitsNet.Tests/CustomCode/PermeabilityTests.cs
index 05a96b3d83..6e111e4400 100644
--- a/UnitsNet.Tests/CustomCode/PermeabilityTests.cs
+++ b/UnitsNet.Tests/CustomCode/PermeabilityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/PermittivityTests.cs b/UnitsNet.Tests/CustomCode/PermittivityTests.cs
index 71d26f7f1d..9cd30ffd5d 100644
--- a/UnitsNet.Tests/CustomCode/PermittivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/PermittivityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/PowerDensityTests.cs b/UnitsNet.Tests/CustomCode/PowerDensityTests.cs
index abc3dfac11..39194a47b9 100644
--- a/UnitsNet.Tests/CustomCode/PowerDensityTests.cs
+++ b/UnitsNet.Tests/CustomCode/PowerDensityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
index 3229634f59..5d84f0cab3 100644
--- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
+++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
@@ -21,7 +21,6 @@
using System;
using Xunit;
-using UnitsNet.CustomCode.Extensions;
namespace UnitsNet.Tests.CustomCode
{
@@ -72,7 +71,7 @@ public void ExpectPowerConvertedCorrectly(double power, double expected)
public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected)
{
PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio);
- double actual = PowerRatio.ToPower(pr).Watts;
+ double actual = pr.ToPower().Watts;
Assert.Equal(expected, actual);
}
@@ -104,4 +103,4 @@ public void PowerRatioToAmplitudeRatio_75OhmImpedance(double dBmW, double expect
Assert.Equal(expected, actual);
}
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/PressureTests.cs b/UnitsNet.Tests/CustomCode/PressureTests.cs
index 89ed3967ae..58dd5cea48 100644
--- a/UnitsNet.Tests/CustomCode/PressureTests.cs
+++ b/UnitsNet.Tests/CustomCode/PressureTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -19,7 +19,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xunit;
namespace UnitsNet.Tests.CustomCode
@@ -66,8 +65,6 @@ public class PressureTests : PressureTestsBase
protected override double PoundsForcePerSquareInchInOnePascal => 1.450377377302092e-4;
- protected override double PsiInOnePascal => 1.450377377302092e-4;
-
protected override double TechnicalAtmospheresInOnePascal => 1.0197*1E-5;
protected override double TonnesForcePerSquareCentimeterInOnePascal => 1.019716212977928e-8;
diff --git a/UnitsNet.Tests/CustomCode/ReactiveEnergyTests.cs b/UnitsNet.Tests/CustomCode/ReactiveEnergyTests.cs
index f31bd68f08..8fa7fe3ad5 100644
--- a/UnitsNet.Tests/CustomCode/ReactiveEnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/ReactiveEnergyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ReactivePowerTests.cs b/UnitsNet.Tests/CustomCode/ReactivePowerTests.cs
index a000168a07..6cf738d778 100644
--- a/UnitsNet.Tests/CustomCode/ReactivePowerTests.cs
+++ b/UnitsNet.Tests/CustomCode/ReactivePowerTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/RotationalAccelerationTests.cs b/UnitsNet.Tests/CustomCode/RotationalAccelerationTests.cs
index 11b1be4f50..e390d5adc5 100644
--- a/UnitsNet.Tests/CustomCode/RotationalAccelerationTests.cs
+++ b/UnitsNet.Tests/CustomCode/RotationalAccelerationTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/RotationalStiffnessPerLengthTests.cs b/UnitsNet.Tests/CustomCode/RotationalStiffnessPerLengthTests.cs
index ec848ea3dd..cb77d0f51d 100644
--- a/UnitsNet.Tests/CustomCode/RotationalStiffnessPerLengthTests.cs
+++ b/UnitsNet.Tests/CustomCode/RotationalStiffnessPerLengthTests.cs
@@ -1,9 +1,9 @@
//------------------------------------------------------------------------------
//
// 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
+// 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
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
@@ -20,17 +19,17 @@
// 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
@@ -46,8 +45,6 @@ namespace UnitsNet.Tests.CustomCode
{
public class RotationalStiffnessPerLengthTests : RotationalStiffnessPerLengthTestsBase
{
- // TODO Override properties in base class here
-
protected override double KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter => 1E-3;
protected override double MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter => 1E-6;
protected override double NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter => 1;
diff --git a/UnitsNet.Tests/CustomCode/RotationalStiffnessTests.cs b/UnitsNet.Tests/CustomCode/RotationalStiffnessTests.cs
index af62b987fd..a1dae7613d 100644
--- a/UnitsNet.Tests/CustomCode/RotationalStiffnessTests.cs
+++ b/UnitsNet.Tests/CustomCode/RotationalStiffnessTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/SolidAngleTests.cs b/UnitsNet.Tests/CustomCode/SolidAngleTests.cs
index 0b0fde3e05..523833f0b3 100644
--- a/UnitsNet.Tests/CustomCode/SolidAngleTests.cs
+++ b/UnitsNet.Tests/CustomCode/SolidAngleTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/SpecificEntropyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEntropyTests.cs
index d3417e7e43..7c928f8f52 100644
--- a/UnitsNet.Tests/CustomCode/SpecificEntropyTests.cs
+++ b/UnitsNet.Tests/CustomCode/SpecificEntropyTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs
index 49d9dbf222..7f5ced0f45 100644
--- a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs
+++ b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs
index d1254bc451..a4f51502d4 100644
--- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs
+++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
@@ -45,15 +44,6 @@ namespace UnitsNet.Tests.CustomCode
{
public class TemperatureDeltaTests : TemperatureDeltaTestsBase
{
- protected override double DegreesCelsiusDeltaInOneKelvin => 1;
- protected override double DegreesDelisleDeltaInOneKelvin => -1.5d;
- protected override double DegreesFahrenheitDeltaInOneKelvin => 1.8;
- protected override double DegreesNewtonDeltaInOneKelvin => 0.33d;
- protected override double DegreesRankineDeltaInOneKelvin => 1.8;
- protected override double DegreesReaumurDeltaInOneKelvin => 0.8;
- protected override double DegreesRoemerDeltaInOneKelvin => 21/40d;
- protected override double KelvinsDeltaInOneKelvin => 1;
-
protected override double DegreesCelsiusInOneKelvin => 1;
protected override double DegreesDelisleInOneKelvin => -1.5d;
protected override double DegreesFahrenheitInOneKelvin => 1.8;
diff --git a/UnitsNet.Tests/CustomCode/TemperatureTests.cs b/UnitsNet.Tests/CustomCode/TemperatureTests.cs
index ad2c029b78..0aa5f9d234 100644
--- a/UnitsNet.Tests/CustomCode/TemperatureTests.cs
+++ b/UnitsNet.Tests/CustomCode/TemperatureTests.cs
@@ -61,7 +61,7 @@ public void DividedByTemperatureDeltaEqualsTemperature(TemperatureUnit unit, int
// Act
Temperature resultTemp = temperature.Divide(divisor, unit);
- string actual = resultTemp.ToString(unit, CultureInfo.InvariantCulture, "{0:0} {1}");
+ string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
Assert.Equal(expected, actual);
}
@@ -81,7 +81,7 @@ public void MultiplyByTemperatureDeltaEqualsTemperature(TemperatureUnit unit, in
// Act
Temperature resultTemp = temperature.Multiply(factor, unit);
- string actual = resultTemp.ToString(unit, CultureInfo.InvariantCulture, "{0:0} {1}");
+ string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
Assert.Equal(expected, actual);
}
@@ -100,7 +100,7 @@ public void TemperatureDeltaPlusTemperatureEqualsTemperature(TemperatureUnit uni
// Act
Temperature resultTemp = delta + temperature;
- string actual = resultTemp.ToString(unit, CultureInfo.InvariantCulture, "{0:0} {1}");
+ string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
Assert.Equal(expected, actual);
}
@@ -119,7 +119,7 @@ public void TemperatureMinusTemperatureDeltaEqualsTemperature(TemperatureUnit un
// Act
Temperature resultTemp = temperature - delta;
- string actual = resultTemp.ToString(unit, CultureInfo.InvariantCulture, "{0:0} {1}");
+ string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
Assert.Equal(expected, actual);
}
@@ -138,8 +138,8 @@ public void TemperaturePlusTemperatureDeltaEqualsTemperature(TemperatureUnit uni
// Act
Temperature resultTemp = temperature + delta;
- string actual = resultTemp.ToString(unit, CultureInfo.InvariantCulture, "{0:0} {1}");
+ string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
Assert.Equal(expected, actual);
}
}
-}
\ No newline at end of file
+}
diff --git a/UnitsNet.Tests/CustomCode/ThermalConductivityTests.cs b/UnitsNet.Tests/CustomCode/ThermalConductivityTests.cs
index 469f727fe2..1a4f97977d 100644
--- a/UnitsNet.Tests/CustomCode/ThermalConductivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ThermalConductivityTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/ThermalResistanceTests.cs b/UnitsNet.Tests/CustomCode/ThermalResistanceTests.cs
index 44d65ef57f..2cba064ee4 100644
--- a/UnitsNet.Tests/CustomCode/ThermalResistanceTests.cs
+++ b/UnitsNet.Tests/CustomCode/ThermalResistanceTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\UnitClasses\MyQuantity.extra.cs files to add code to generated unit classes.
-// Add Extensions\MyQuantityExtensions.cs to decorate unit classes with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or unit classes.
//
//
diff --git a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs
index bc88c7dff3..1eb1ff61d1 100644
--- a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs
+++ b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs
@@ -12,7 +12,6 @@
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
//
diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs
index c64002bcbb..34f3f7900c 100644
--- a/UnitsNet.Tests/CustomCode/VolumeTests.cs
+++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs
@@ -77,25 +77,17 @@ public class VolumeTests : VolumeTestsBase
protected override double AuTablespoonsInOneCubicMeter => 50000;
protected override double UsTablespoonsInOneCubicMeter => 67628.0454;
-
- protected override double TablespoonsInOneCubicMeter => 67628.0454;
-
- protected override double TablespoonsTolerance => 1E-4;
protected override double MetricTeaspoonsInOneCubicMeter => 200000;
protected override double UsTeaspoonsInOneCubicMeter => 202884.13621105801;
- protected override double TeaspoonsInOneCubicMeter => 202884.13621105801;
-
protected override double ImperialBeerBarrelsInOneCubicMeter => 6.1102568972;
protected override double UkTablespoonsInOneCubicMeter => 66666.6666667;
protected override double UsBeerBarrelsInOneCubicMeter => 8.5216790723083;
- protected override double TeaspoonsTolerance => 1E-3;
-
protected override double UsGallonsInOneCubicMeter => 264.17217;
protected override double UsOuncesInOneCubicMeter => 33814.02270;
diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs
index f19e131a14..6865026af6 100644
--- a/UnitsNet.Tests/DecimalOverloadTests.cs
+++ b/UnitsNet.Tests/DecimalOverloadTests.cs
@@ -1,16 +1,16 @@
// 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
@@ -20,8 +20,6 @@
// THE SOFTWARE.
using Xunit;
-using UnitsNet.Extensions.NumberToAcceleration;
-using UnitsNet.Extensions.NumberToPower;
namespace UnitsNet.Tests
{
@@ -30,101 +28,15 @@ public class DecimalOverloadTests
[Fact]
public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorrectValue()
{
- decimal oneMeterPerSecondSquared = 1m;
- Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(oneMeterPerSecondSquared);
+ Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1m);
Assert.Equal(1.0, acceleration.MetersPerSecondSquared);
}
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromNullableDecimalReturnsCorrectValue()
- {
- decimal? oneMeterPerSecondSquared = 1m;
- Acceleration? acceleration = Acceleration.FromMetersPerSecondSquared(oneMeterPerSecondSquared);
- Assert.NotNull(acceleration);
- Assert.Equal(1.0, acceleration.Value.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromNullableDecimalReturnsNullWhenGivenNull()
- {
- decimal? nullDecimal = null;
- Acceleration? acceleration = Acceleration.FromMetersPerSecondSquared(nullDecimal);
- Assert.Null(acceleration);
- }
-
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromDecimalWithExtensionMethodReturnsCorrectValue()
- {
- decimal oneMeterPerSecondSquared = 1m;
- Acceleration acceleration = oneMeterPerSecondSquared.MetersPerSecondSquared();
- Assert.Equal(1.0, acceleration.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromNullableDecimalWithExtensionMethodReturnsCorrectValue()
- {
- decimal? oneMeterPerSecondSquared = 1m;
- Acceleration? acceleration = oneMeterPerSecondSquared.MetersPerSecondSquared();
- Assert.NotNull(acceleration);
- Assert.Equal(1.0, acceleration.Value.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromNullableDecimalWithExtensionMethodReturnsNullWhenGivenNull()
- {
- decimal? nullDecimal = null;
- Acceleration? acceleration = nullDecimal.MetersPerSecondSquared();
- Assert.Null(acceleration);
- }
-
[Fact]
public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue()
{
- decimal oneWatt = 1m;
- Power power = Power.FromWatts(oneWatt);
+ Power power = Power.FromWatts(1m);
Assert.Equal(1.0, power.Watts);
}
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromNullableDecimalReturnsCorrectValue()
- {
- decimal? oneWatt = 1m;
- Power? power = Power.FromWatts(oneWatt);
- Assert.NotNull(power);
- Assert.Equal(1.0, power.Value.Watts);
- }
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromNullableDecimalReturnsNullWhenGivenNull()
- {
- decimal? nullDecimal = null;
- Power? power = Power.FromWatts(nullDecimal);
- Assert.Null(power);
- }
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromDecimalWithExtensionMethodReturnsCorrectValue()
- {
- decimal oneWatt = 1m;
- Power power = oneWatt.Watts();
- Assert.Equal(1.0, power.Watts);
- }
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromNullableDecimalWithExtensionMethodReturnsCorrectValue()
- {
- decimal? oneWatt = 1m;
- Power? power = oneWatt.Watts();
- Assert.NotNull(power);
- Assert.Equal(1.0, power.Value.Watts);
- }
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromNullableDecimalWithExtensionMethodReturnsNullWhenGivenNull()
- {
- decimal? nullDecimal = null;
- Power? power = nullDecimal.Watts();
- Assert.Null(power);
- }
}
}
diff --git a/UnitsNet.Tests/Extensions/NumberToTimeSpan/NumberToTimeSpanExtensionsTest.cs b/UnitsNet.Tests/Extensions/NumberToTimeSpan/NumberToTimeSpanExtensionsTest.cs
deleted file mode 100644
index de5e702403..0000000000
--- a/UnitsNet.Tests/Extensions/NumberToTimeSpan/NumberToTimeSpanExtensionsTest.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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 Xunit;
-using UnitsNet.Extensions.NumberToTimeSpan;
-
-namespace UnitsNet.Tests.Extensions.NumberToTimeSpan
-{
- public class NumberToTimeSpanExtensionsTest
- {
- [Fact]
- public void ExtensionMethodsReturnTimeSpanOfSameValue()
- {
- Assert.Equal(TimeSpan.FromDays(1), 1.d());
- Assert.Equal(TimeSpan.FromDays(1), 1L.d());
- Assert.Equal(TimeSpan.FromDays(1), 1f.d());
- Assert.Equal(TimeSpan.FromDays(1), 1d.d());
- Assert.Equal(TimeSpan.FromDays(1), 1m.d());
-
- Assert.Equal(TimeSpan.FromHours(1), 1.h());
- Assert.Equal(TimeSpan.FromHours(1), 1L.h());
- Assert.Equal(TimeSpan.FromHours(1), 1f.h());
- Assert.Equal(TimeSpan.FromHours(1), 1d.h());
- Assert.Equal(TimeSpan.FromHours(1), 1m.h());
-
- Assert.Equal(TimeSpan.FromMinutes(1), 1.m());
- Assert.Equal(TimeSpan.FromMinutes(1), 1L.m());
- Assert.Equal(TimeSpan.FromMinutes(1), 1f.m());
- Assert.Equal(TimeSpan.FromMinutes(1), 1d.m());
- Assert.Equal(TimeSpan.FromMinutes(1), 1m.m());
-
- Assert.Equal(TimeSpan.FromSeconds(1), 1.s());
- Assert.Equal(TimeSpan.FromSeconds(1), 1L.s());
- Assert.Equal(TimeSpan.FromSeconds(1), 1f.s());
- Assert.Equal(TimeSpan.FromSeconds(1), 1d.s());
- Assert.Equal(TimeSpan.FromSeconds(1), 1m.s());
-
- Assert.Equal(TimeSpan.FromMilliseconds(1), 1.ms());
- Assert.Equal(TimeSpan.FromMilliseconds(1), 1L.ms());
- Assert.Equal(TimeSpan.FromMilliseconds(1), 1f.ms());
- Assert.Equal(TimeSpan.FromMilliseconds(1), 1d.ms());
- Assert.Equal(TimeSpan.FromMilliseconds(1), 1m.ms());
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/.gitignore b/UnitsNet.Tests/GeneratedCode/.gitignore
new file mode 100644
index 0000000000..6dd350f428
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/.gitignore
@@ -0,0 +1,4 @@
+*.g.cs
+!InformationTestsBase.g.cs
+!LengthTestsBase.g.cs
+!LevelTestsBase.g.cs
diff --git a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
deleted file mode 100644
index 6312872176..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Acceleration.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AccelerationTestsBase
- {
- protected abstract double CentimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double DecimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double FeetPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double InchesPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double KilometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerHourInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerMinuteInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerSecondInOneMeterPerSecondSquared { get; }
- protected abstract double MetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double MicrometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double MillimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double NanometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double StandardGravityInOneMeterPerSecondSquared { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double FeetPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double InchesPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double KilometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerHourTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerMinuteTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double NanometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double StandardGravityTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void MeterPerSecondSquaredToAccelerationUnits()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.FeetPerSecondSquared, FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.InchesPerSecondSquared, InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.KilometersPerSecondSquared, KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerHour, KnotsPerHourTolerance);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerMinute, KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerSecond, KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MicrometersPerSecondSquared, MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MillimetersPerSecondSquared, MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.NanometersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, meterpersecondsquared.StandardGravity, StandardGravityTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.CentimeterPerSecondSquared).CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.DecimeterPerSecondSquared).DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.FootPerSecondSquared).FeetPerSecondSquared, FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.InchPerSecondSquared).InchesPerSecondSquared, InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KilometerPerSecondSquared).KilometersPerSecondSquared, KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerHour).KnotsPerHour, KnotsPerHourTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerMinute).KnotsPerMinute, KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerSecond).KnotsPerSecond, KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MeterPerSecondSquared).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MicrometerPerSecondSquared).MicrometersPerSecondSquared, MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MillimeterPerSecondSquared).MillimetersPerSecondSquared, MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.NanometerPerSecondSquared).NanometersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.StandardGravity).StandardGravity, StandardGravityTolerance);
- }
-
- [Fact]
- public void As()
- {
- var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.CentimeterPerSecondSquared), CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.DecimeterPerSecondSquared), DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.FootPerSecondSquared), FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.InchPerSecondSquared), InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KilometerPerSecondSquared), KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerHour), KnotsPerHourTolerance);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerMinute), KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerSecond), KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MeterPerSecondSquared), MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MicrometerPerSecondSquared), MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MillimeterPerSecondSquared), MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.NanometerPerSecondSquared), NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.StandardGravity), StandardGravityTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
-
- var centimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.CentimeterPerSecondSquared);
- AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)centimeterpersecondsquaredQuantity.Value, CentimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.CentimeterPerSecondSquared, centimeterpersecondsquaredQuantity.Unit);
-
- var decimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.DecimeterPerSecondSquared);
- AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)decimeterpersecondsquaredQuantity.Value, DecimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.DecimeterPerSecondSquared, decimeterpersecondsquaredQuantity.Unit);
-
- var footpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.FootPerSecondSquared);
- AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, (double)footpersecondsquaredQuantity.Value, FeetPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.FootPerSecondSquared, footpersecondsquaredQuantity.Unit);
-
- var inchpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.InchPerSecondSquared);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, (double)inchpersecondsquaredQuantity.Value, InchesPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.InchPerSecondSquared, inchpersecondsquaredQuantity.Unit);
-
- var kilometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KilometerPerSecondSquared);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, (double)kilometerpersecondsquaredQuantity.Value, KilometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.KilometerPerSecondSquared, kilometerpersecondsquaredQuantity.Unit);
-
- var knotperhourQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerHour);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, (double)knotperhourQuantity.Value, KnotsPerHourTolerance);
- Assert.Equal(AccelerationUnit.KnotPerHour, knotperhourQuantity.Unit);
-
- var knotperminuteQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerMinute);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, (double)knotperminuteQuantity.Value, KnotsPerMinuteTolerance);
- Assert.Equal(AccelerationUnit.KnotPerMinute, knotperminuteQuantity.Unit);
-
- var knotpersecondQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerSecond);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, (double)knotpersecondQuantity.Value, KnotsPerSecondTolerance);
- Assert.Equal(AccelerationUnit.KnotPerSecond, knotpersecondQuantity.Unit);
-
- var meterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MeterPerSecondSquared);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, (double)meterpersecondsquaredQuantity.Value, MetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MeterPerSecondSquared, meterpersecondsquaredQuantity.Unit);
-
- var micrometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MicrometerPerSecondSquared);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, (double)micrometerpersecondsquaredQuantity.Value, MicrometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MicrometerPerSecondSquared, micrometerpersecondsquaredQuantity.Unit);
-
- var millimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MillimeterPerSecondSquared);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)millimeterpersecondsquaredQuantity.Value, MillimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MillimeterPerSecondSquared, millimeterpersecondsquaredQuantity.Unit);
-
- var nanometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.NanometerPerSecondSquared);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, (double)nanometerpersecondsquaredQuantity.Value, NanometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.NanometerPerSecondSquared, nanometerpersecondsquaredQuantity.Unit);
-
- var standardgravityQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.StandardGravity);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, (double)standardgravityQuantity.Value, StandardGravityTolerance);
- Assert.Equal(AccelerationUnit.StandardGravity, standardgravityQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(1, Acceleration.FromCentimetersPerSecondSquared(meterpersecondsquared.CentimetersPerSecondSquared).MetersPerSecondSquared, CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromDecimetersPerSecondSquared(meterpersecondsquared.DecimetersPerSecondSquared).MetersPerSecondSquared, DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromFeetPerSecondSquared(meterpersecondsquared.FeetPerSecondSquared).MetersPerSecondSquared, FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromInchesPerSecondSquared(meterpersecondsquared.InchesPerSecondSquared).MetersPerSecondSquared, InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromKilometersPerSecondSquared(meterpersecondsquared.KilometersPerSecondSquared).MetersPerSecondSquared, KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerHour(meterpersecondsquared.KnotsPerHour).MetersPerSecondSquared, KnotsPerHourTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerMinute(meterpersecondsquared.KnotsPerMinute).MetersPerSecondSquared, KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerSecond(meterpersecondsquared.KnotsPerSecond).MetersPerSecondSquared, KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromMetersPerSecondSquared(meterpersecondsquared.MetersPerSecondSquared).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromMicrometersPerSecondSquared(meterpersecondsquared.MicrometersPerSecondSquared).MetersPerSecondSquared, MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromMillimetersPerSecondSquared(meterpersecondsquared.MillimetersPerSecondSquared).MetersPerSecondSquared, MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromNanometersPerSecondSquared(meterpersecondsquared.NanometersPerSecondSquared).MetersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromStandardGravity(meterpersecondsquared.StandardGravity).MetersPerSecondSquared, StandardGravityTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Acceleration v = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(-1, -v.MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(3)-v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(2, (v + v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(10, (v*10).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(10, (10*v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(10)/5).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(2, Acceleration.FromMetersPerSecondSquared(10)/Acceleration.FromMetersPerSecondSquared(5), MetersPerSecondSquaredTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Acceleration oneMeterPerSecondSquared = Acceleration.FromMetersPerSecondSquared(1);
- Acceleration twoMetersPerSecondSquared = Acceleration.FromMetersPerSecondSquared(2);
-
- Assert.True(oneMeterPerSecondSquared < twoMetersPerSecondSquared);
- Assert.True(oneMeterPerSecondSquared <= twoMetersPerSecondSquared);
- Assert.True(twoMetersPerSecondSquared > oneMeterPerSecondSquared);
- Assert.True(twoMetersPerSecondSquared >= oneMeterPerSecondSquared);
-
- Assert.False(oneMeterPerSecondSquared > twoMetersPerSecondSquared);
- Assert.False(oneMeterPerSecondSquared >= twoMetersPerSecondSquared);
- Assert.False(twoMetersPerSecondSquared < oneMeterPerSecondSquared);
- Assert.False(twoMetersPerSecondSquared <= oneMeterPerSecondSquared);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Equal(0, meterpersecondsquared.CompareTo(meterpersecondsquared));
- Assert.True(meterpersecondsquared.CompareTo(Acceleration.Zero) > 0);
- Assert.True(Acceleration.Zero.CompareTo(meterpersecondsquared) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Throws(() => meterpersecondsquared.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Throws(() => meterpersecondsquared.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Acceleration a = Acceleration.FromMetersPerSecondSquared(1);
- Acceleration b = Acceleration.FromMetersPerSecondSquared(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()
- {
- Acceleration v = Acceleration.FromMetersPerSecondSquared(1);
- Assert.True(v.Equals(Acceleration.FromMetersPerSecondSquared(1), Acceleration.FromMetersPerSecondSquared(MetersPerSecondSquaredTolerance)));
- Assert.False(v.Equals(Acceleration.Zero, Acceleration.FromMetersPerSecondSquared(MetersPerSecondSquaredTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.False(meterpersecondsquared.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.False(meterpersecondsquared.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
deleted file mode 100644
index 8e81e74de8..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
+++ /dev/null
@@ -1,337 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 AmountOfSubstance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AmountOfSubstanceTestsBase
- {
- protected abstract double CentimolesInOneMole { get; }
- protected abstract double CentipoundMolesInOneMole { get; }
- protected abstract double DecimolesInOneMole { get; }
- protected abstract double DecipoundMolesInOneMole { get; }
- protected abstract double KilomolesInOneMole { get; }
- protected abstract double KilopoundMolesInOneMole { get; }
- protected abstract double MegamolesInOneMole { get; }
- protected abstract double MicromolesInOneMole { get; }
- protected abstract double MicropoundMolesInOneMole { get; }
- protected abstract double MillimolesInOneMole { get; }
- protected abstract double MillipoundMolesInOneMole { get; }
- protected abstract double MolesInOneMole { get; }
- protected abstract double NanomolesInOneMole { get; }
- protected abstract double NanopoundMolesInOneMole { get; }
- protected abstract double PoundMolesInOneMole { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentimolesTolerance { get { return 1e-5; } }
- protected virtual double CentipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double DecimolesTolerance { get { return 1e-5; } }
- protected virtual double DecipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double KilomolesTolerance { get { return 1e-5; } }
- protected virtual double KilopoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MegamolesTolerance { get { return 1e-5; } }
- protected virtual double MicromolesTolerance { get { return 1e-5; } }
- protected virtual double MicropoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MillimolesTolerance { get { return 1e-5; } }
- protected virtual double MillipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MolesTolerance { get { return 1e-5; } }
- protected virtual double NanomolesTolerance { get { return 1e-5; } }
- protected virtual double NanopoundMolesTolerance { get { return 1e-5; } }
- protected virtual double PoundMolesTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void MoleToAmountOfSubstanceUnits()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- AssertEx.EqualTolerance(CentimolesInOneMole, mole.Centimoles, CentimolesTolerance);
- AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.CentipoundMoles, CentipoundMolesTolerance);
- AssertEx.EqualTolerance(DecimolesInOneMole, mole.Decimoles, DecimolesTolerance);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.DecipoundMoles, DecipoundMolesTolerance);
- AssertEx.EqualTolerance(KilomolesInOneMole, mole.Kilomoles, KilomolesTolerance);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.KilopoundMoles, KilopoundMolesTolerance);
- AssertEx.EqualTolerance(MegamolesInOneMole, mole.Megamoles, MegamolesTolerance);
- AssertEx.EqualTolerance(MicromolesInOneMole, mole.Micromoles, MicromolesTolerance);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.MicropoundMoles, MicropoundMolesTolerance);
- AssertEx.EqualTolerance(MillimolesInOneMole, mole.Millimoles, MillimolesTolerance);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.MillipoundMoles, MillipoundMolesTolerance);
- AssertEx.EqualTolerance(MolesInOneMole, mole.Moles, MolesTolerance);
- AssertEx.EqualTolerance(NanomolesInOneMole, mole.Nanomoles, NanomolesTolerance);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.NanopoundMoles, NanopoundMolesTolerance);
- AssertEx.EqualTolerance(PoundMolesInOneMole, mole.PoundMoles, PoundMolesTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Centimole).Centimoles, CentimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.CentipoundMole).CentipoundMoles, CentipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Decimole).Decimoles, DecimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.DecipoundMole).DecipoundMoles, DecipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Kilomole).Kilomoles, KilomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.KilopoundMole).KilopoundMoles, KilopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Megamole).Megamoles, MegamolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Micromole).Micromoles, MicromolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MicropoundMole).MicropoundMoles, MicropoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Millimole).Millimoles, MillimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MillipoundMole).MillipoundMoles, MillipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Mole).Moles, MolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Nanomole).Nanomoles, NanomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.NanopoundMole).NanopoundMoles, NanopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.PoundMole).PoundMoles, PoundMolesTolerance);
- }
-
- [Fact]
- public void As()
- {
- var mole = AmountOfSubstance.FromMoles(1);
- AssertEx.EqualTolerance(CentimolesInOneMole, mole.As(AmountOfSubstanceUnit.Centimole), CentimolesTolerance);
- AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.CentipoundMole), CentipoundMolesTolerance);
- AssertEx.EqualTolerance(DecimolesInOneMole, mole.As(AmountOfSubstanceUnit.Decimole), DecimolesTolerance);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.DecipoundMole), DecipoundMolesTolerance);
- AssertEx.EqualTolerance(KilomolesInOneMole, mole.As(AmountOfSubstanceUnit.Kilomole), KilomolesTolerance);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.KilopoundMole), KilopoundMolesTolerance);
- AssertEx.EqualTolerance(MegamolesInOneMole, mole.As(AmountOfSubstanceUnit.Megamole), MegamolesTolerance);
- AssertEx.EqualTolerance(MicromolesInOneMole, mole.As(AmountOfSubstanceUnit.Micromole), MicromolesTolerance);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MicropoundMole), MicropoundMolesTolerance);
- AssertEx.EqualTolerance(MillimolesInOneMole, mole.As(AmountOfSubstanceUnit.Millimole), MillimolesTolerance);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MillipoundMole), MillipoundMolesTolerance);
- AssertEx.EqualTolerance(MolesInOneMole, mole.As(AmountOfSubstanceUnit.Mole), MolesTolerance);
- AssertEx.EqualTolerance(NanomolesInOneMole, mole.As(AmountOfSubstanceUnit.Nanomole), NanomolesTolerance);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.NanopoundMole), NanopoundMolesTolerance);
- AssertEx.EqualTolerance(PoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.PoundMole), PoundMolesTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var mole = AmountOfSubstance.FromMoles(1);
-
- var centimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Centimole);
- AssertEx.EqualTolerance(CentimolesInOneMole, (double)centimoleQuantity.Value, CentimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Centimole, centimoleQuantity.Unit);
-
- var centipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.CentipoundMole);
- AssertEx.EqualTolerance(CentipoundMolesInOneMole, (double)centipoundmoleQuantity.Value, CentipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.CentipoundMole, centipoundmoleQuantity.Unit);
-
- var decimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Decimole);
- AssertEx.EqualTolerance(DecimolesInOneMole, (double)decimoleQuantity.Value, DecimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Decimole, decimoleQuantity.Unit);
-
- var decipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.DecipoundMole);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, (double)decipoundmoleQuantity.Value, DecipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.DecipoundMole, decipoundmoleQuantity.Unit);
-
- var kilomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Kilomole);
- AssertEx.EqualTolerance(KilomolesInOneMole, (double)kilomoleQuantity.Value, KilomolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Kilomole, kilomoleQuantity.Unit);
-
- var kilopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.KilopoundMole);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, (double)kilopoundmoleQuantity.Value, KilopoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.KilopoundMole, kilopoundmoleQuantity.Unit);
-
- var megamoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Megamole);
- AssertEx.EqualTolerance(MegamolesInOneMole, (double)megamoleQuantity.Value, MegamolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Megamole, megamoleQuantity.Unit);
-
- var micromoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Micromole);
- AssertEx.EqualTolerance(MicromolesInOneMole, (double)micromoleQuantity.Value, MicromolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Micromole, micromoleQuantity.Unit);
-
- var micropoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MicropoundMole);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, (double)micropoundmoleQuantity.Value, MicropoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.MicropoundMole, micropoundmoleQuantity.Unit);
-
- var millimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Millimole);
- AssertEx.EqualTolerance(MillimolesInOneMole, (double)millimoleQuantity.Value, MillimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Millimole, millimoleQuantity.Unit);
-
- var millipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MillipoundMole);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, (double)millipoundmoleQuantity.Value, MillipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.MillipoundMole, millipoundmoleQuantity.Unit);
-
- var moleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Mole);
- AssertEx.EqualTolerance(MolesInOneMole, (double)moleQuantity.Value, MolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Mole, moleQuantity.Unit);
-
- var nanomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Nanomole);
- AssertEx.EqualTolerance(NanomolesInOneMole, (double)nanomoleQuantity.Value, NanomolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Nanomole, nanomoleQuantity.Unit);
-
- var nanopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.NanopoundMole);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, (double)nanopoundmoleQuantity.Value, NanopoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.NanopoundMole, nanopoundmoleQuantity.Unit);
-
- var poundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.PoundMole);
- AssertEx.EqualTolerance(PoundMolesInOneMole, (double)poundmoleQuantity.Value, PoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.PoundMole, poundmoleQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentimoles(mole.Centimoles).Moles, CentimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentipoundMoles(mole.CentipoundMoles).Moles, CentipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecimoles(mole.Decimoles).Moles, DecimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecipoundMoles(mole.DecipoundMoles).Moles, DecipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilomoles(mole.Kilomoles).Moles, KilomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilopoundMoles(mole.KilopoundMoles).Moles, KilopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMegamoles(mole.Megamoles).Moles, MegamolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicromoles(mole.Micromoles).Moles, MicromolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicropoundMoles(mole.MicropoundMoles).Moles, MicropoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillimoles(mole.Millimoles).Moles, MillimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillipoundMoles(mole.MillipoundMoles).Moles, MillipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromMoles(mole.Moles).Moles, MolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanomoles(mole.Nanomoles).Moles, NanomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanopoundMoles(mole.NanopoundMoles).Moles, NanopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.FromPoundMoles(mole.PoundMoles).Moles, PoundMolesTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- AmountOfSubstance v = AmountOfSubstance.FromMoles(1);
- AssertEx.EqualTolerance(-1, -v.Moles, MolesTolerance);
- AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(3)-v).Moles, MolesTolerance);
- AssertEx.EqualTolerance(2, (v + v).Moles, MolesTolerance);
- AssertEx.EqualTolerance(10, (v*10).Moles, MolesTolerance);
- AssertEx.EqualTolerance(10, (10*v).Moles, MolesTolerance);
- AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(10)/5).Moles, MolesTolerance);
- AssertEx.EqualTolerance(2, AmountOfSubstance.FromMoles(10)/AmountOfSubstance.FromMoles(5), MolesTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- AmountOfSubstance oneMole = AmountOfSubstance.FromMoles(1);
- AmountOfSubstance twoMoles = AmountOfSubstance.FromMoles(2);
-
- Assert.True(oneMole < twoMoles);
- Assert.True(oneMole <= twoMoles);
- Assert.True(twoMoles > oneMole);
- Assert.True(twoMoles >= oneMole);
-
- Assert.False(oneMole > twoMoles);
- Assert.False(oneMole >= twoMoles);
- Assert.False(twoMoles < oneMole);
- Assert.False(twoMoles <= oneMole);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.Equal(0, mole.CompareTo(mole));
- Assert.True(mole.CompareTo(AmountOfSubstance.Zero) > 0);
- Assert.True(AmountOfSubstance.Zero.CompareTo(mole) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.Throws(() => mole.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.Throws(() => mole.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- AmountOfSubstance a = AmountOfSubstance.FromMoles(1);
- AmountOfSubstance b = AmountOfSubstance.FromMoles(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()
- {
- AmountOfSubstance v = AmountOfSubstance.FromMoles(1);
- Assert.True(v.Equals(AmountOfSubstance.FromMoles(1), AmountOfSubstance.FromMoles(MolesTolerance)));
- Assert.False(v.Equals(AmountOfSubstance.Zero, AmountOfSubstance.FromMoles(MolesTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.False(mole.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.False(mole.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
deleted file mode 100644
index 5ef7153039..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
+++ /dev/null
@@ -1,232 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 AmplitudeRatio.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AmplitudeRatioTestsBase
- {
- protected abstract double DecibelMicrovoltsInOneDecibelVolt { get; }
- protected abstract double DecibelMillivoltsInOneDecibelVolt { get; }
- protected abstract double DecibelsUnloadedInOneDecibelVolt { get; }
- protected abstract double DecibelVoltsInOneDecibelVolt { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double DecibelMicrovoltsTolerance { get { return 1e-5; } }
- protected virtual double DecibelMillivoltsTolerance { get { return 1e-5; } }
- protected virtual double DecibelsUnloadedTolerance { get { return 1e-5; } }
- protected virtual double DecibelVoltsTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void DecibelVoltToAmplitudeRatioUnits()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.DecibelMicrovolts, DecibelMicrovoltsTolerance);
- AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.DecibelMillivolts, DecibelMillivoltsTolerance);
- AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.DecibelsUnloaded, DecibelsUnloadedTolerance);
- AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.DecibelVolts, DecibelVoltsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMicrovolt).DecibelMicrovolts, DecibelMicrovoltsTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMillivolt).DecibelMillivolts, DecibelMillivoltsTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelUnloaded).DecibelsUnloaded, DecibelsUnloadedTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelVolt).DecibelVolts, DecibelVoltsTolerance);
- }
-
- [Fact]
- public void As()
- {
- var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMicrovolt), DecibelMicrovoltsTolerance);
- AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMillivolt), DecibelMillivoltsTolerance);
- AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelUnloaded), DecibelsUnloadedTolerance);
- AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelVolt), DecibelVoltsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
-
- var decibelmicrovoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt);
- AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, (double)decibelmicrovoltQuantity.Value, DecibelMicrovoltsTolerance);
- Assert.Equal(AmplitudeRatioUnit.DecibelMicrovolt, decibelmicrovoltQuantity.Unit);
-
- var decibelmillivoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMillivolt);
- AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, (double)decibelmillivoltQuantity.Value, DecibelMillivoltsTolerance);
- Assert.Equal(AmplitudeRatioUnit.DecibelMillivolt, decibelmillivoltQuantity.Unit);
-
- var decibelunloadedQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelUnloaded);
- AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, (double)decibelunloadedQuantity.Value, DecibelsUnloadedTolerance);
- Assert.Equal(AmplitudeRatioUnit.DecibelUnloaded, decibelunloadedQuantity.Unit);
-
- var decibelvoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelVolt);
- AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, (double)decibelvoltQuantity.Value, DecibelVoltsTolerance);
- Assert.Equal(AmplitudeRatioUnit.DecibelVolt, decibelvoltQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelsUnloaded(decibelvolt.DecibelsUnloaded).DecibelVolts, DecibelsUnloadedTolerance);
- AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance);
- }
-
- [Fact]
- public void LogarithmicArithmeticOperators()
- {
- AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40);
- AssertEx.EqualTolerance(-40, -v.DecibelVolts, DecibelVoltsTolerance);
- AssertLogarithmicAddition();
- AssertLogarithmicSubtraction();
- AssertEx.EqualTolerance(50, (v*10).DecibelVolts, DecibelVoltsTolerance);
- AssertEx.EqualTolerance(50, (10*v).DecibelVolts, DecibelVoltsTolerance);
- AssertEx.EqualTolerance(35, (v/5).DecibelVolts, DecibelVoltsTolerance);
- AssertEx.EqualTolerance(35, v/AmplitudeRatio.FromDecibelVolts(5), DecibelVoltsTolerance);
- }
-
- protected abstract void AssertLogarithmicAddition();
-
- protected abstract void AssertLogarithmicSubtraction();
-
-
- [Fact]
- public void ComparisonOperators()
- {
- AmplitudeRatio oneDecibelVolt = AmplitudeRatio.FromDecibelVolts(1);
- AmplitudeRatio twoDecibelVolts = AmplitudeRatio.FromDecibelVolts(2);
-
- Assert.True(oneDecibelVolt < twoDecibelVolts);
- Assert.True(oneDecibelVolt <= twoDecibelVolts);
- Assert.True(twoDecibelVolts > oneDecibelVolt);
- Assert.True(twoDecibelVolts >= oneDecibelVolt);
-
- Assert.False(oneDecibelVolt > twoDecibelVolts);
- Assert.False(oneDecibelVolt >= twoDecibelVolts);
- Assert.False(twoDecibelVolts < oneDecibelVolt);
- Assert.False(twoDecibelVolts <= oneDecibelVolt);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- Assert.Equal(0, decibelvolt.CompareTo(decibelvolt));
- Assert.True(decibelvolt.CompareTo(AmplitudeRatio.Zero) > 0);
- Assert.True(AmplitudeRatio.Zero.CompareTo(decibelvolt) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- Assert.Throws(() => decibelvolt.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- Assert.Throws(() => decibelvolt.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- AmplitudeRatio a = AmplitudeRatio.FromDecibelVolts(1);
- AmplitudeRatio b = AmplitudeRatio.FromDecibelVolts(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()
- {
- AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(1);
- Assert.True(v.Equals(AmplitudeRatio.FromDecibelVolts(1), AmplitudeRatio.FromDecibelVolts(DecibelVoltsTolerance)));
- Assert.False(v.Equals(AmplitudeRatio.Zero, AmplitudeRatio.FromDecibelVolts(DecibelVoltsTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- Assert.False(decibelvolt.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
- Assert.False(decibelvolt.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
deleted file mode 100644
index 6589478a78..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
+++ /dev/null
@@ -1,327 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Angle.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AngleTestsBase
- {
- protected abstract double ArcminutesInOneDegree { get; }
- protected abstract double ArcsecondsInOneDegree { get; }
- protected abstract double CentiradiansInOneDegree { get; }
- protected abstract double DeciradiansInOneDegree { get; }
- protected abstract double DegreesInOneDegree { get; }
- protected abstract double GradiansInOneDegree { get; }
- protected abstract double MicrodegreesInOneDegree { get; }
- protected abstract double MicroradiansInOneDegree { get; }
- protected abstract double MillidegreesInOneDegree { get; }
- protected abstract double MilliradiansInOneDegree { get; }
- protected abstract double NanodegreesInOneDegree { get; }
- protected abstract double NanoradiansInOneDegree { get; }
- protected abstract double RadiansInOneDegree { get; }
- protected abstract double RevolutionsInOneDegree { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double ArcminutesTolerance { get { return 1e-5; } }
- protected virtual double ArcsecondsTolerance { get { return 1e-5; } }
- protected virtual double CentiradiansTolerance { get { return 1e-5; } }
- protected virtual double DeciradiansTolerance { get { return 1e-5; } }
- protected virtual double DegreesTolerance { get { return 1e-5; } }
- protected virtual double GradiansTolerance { get { return 1e-5; } }
- protected virtual double MicrodegreesTolerance { get { return 1e-5; } }
- protected virtual double MicroradiansTolerance { get { return 1e-5; } }
- protected virtual double MillidegreesTolerance { get { return 1e-5; } }
- protected virtual double MilliradiansTolerance { get { return 1e-5; } }
- protected virtual double NanodegreesTolerance { get { return 1e-5; } }
- protected virtual double NanoradiansTolerance { get { return 1e-5; } }
- protected virtual double RadiansTolerance { get { return 1e-5; } }
- protected virtual double RevolutionsTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void DegreeToAngleUnits()
- {
- Angle degree = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(ArcminutesInOneDegree, degree.Arcminutes, ArcminutesTolerance);
- AssertEx.EqualTolerance(ArcsecondsInOneDegree, degree.Arcseconds, ArcsecondsTolerance);
- AssertEx.EqualTolerance(CentiradiansInOneDegree, degree.Centiradians, CentiradiansTolerance);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, degree.Deciradians, DeciradiansTolerance);
- AssertEx.EqualTolerance(DegreesInOneDegree, degree.Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(GradiansInOneDegree, degree.Gradians, GradiansTolerance);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, degree.Microdegrees, MicrodegreesTolerance);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, degree.Microradians, MicroradiansTolerance);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, degree.Millidegrees, MillidegreesTolerance);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, degree.Milliradians, MilliradiansTolerance);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, degree.Nanodegrees, NanodegreesTolerance);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, degree.Nanoradians, NanoradiansTolerance);
- AssertEx.EqualTolerance(RadiansInOneDegree, degree.Radians, RadiansTolerance);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, degree.Revolutions, RevolutionsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Arcminute).Arcminutes, ArcminutesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Arcsecond).Arcseconds, ArcsecondsTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Centiradian).Centiradians, CentiradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Deciradian).Deciradians, DeciradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Degree).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Gradian).Gradians, GradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Microdegree).Microdegrees, MicrodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Microradian).Microradians, MicroradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Millidegree).Millidegrees, MillidegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Milliradian).Milliradians, MilliradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Nanodegree).Nanodegrees, NanodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Nanoradian).Nanoradians, NanoradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Radian).Radians, RadiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Revolution).Revolutions, RevolutionsTolerance);
- }
-
- [Fact]
- public void As()
- {
- var degree = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(ArcminutesInOneDegree, degree.As(AngleUnit.Arcminute), ArcminutesTolerance);
- AssertEx.EqualTolerance(ArcsecondsInOneDegree, degree.As(AngleUnit.Arcsecond), ArcsecondsTolerance);
- AssertEx.EqualTolerance(CentiradiansInOneDegree, degree.As(AngleUnit.Centiradian), CentiradiansTolerance);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, degree.As(AngleUnit.Deciradian), DeciradiansTolerance);
- AssertEx.EqualTolerance(DegreesInOneDegree, degree.As(AngleUnit.Degree), DegreesTolerance);
- AssertEx.EqualTolerance(GradiansInOneDegree, degree.As(AngleUnit.Gradian), GradiansTolerance);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, degree.As(AngleUnit.Microdegree), MicrodegreesTolerance);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, degree.As(AngleUnit.Microradian), MicroradiansTolerance);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, degree.As(AngleUnit.Millidegree), MillidegreesTolerance);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, degree.As(AngleUnit.Milliradian), MilliradiansTolerance);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, degree.As(AngleUnit.Nanodegree), NanodegreesTolerance);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, degree.As(AngleUnit.Nanoradian), NanoradiansTolerance);
- AssertEx.EqualTolerance(RadiansInOneDegree, degree.As(AngleUnit.Radian), RadiansTolerance);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, degree.As(AngleUnit.Revolution), RevolutionsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var degree = Angle.FromDegrees(1);
-
- var arcminuteQuantity = degree.ToUnit(AngleUnit.Arcminute);
- AssertEx.EqualTolerance(ArcminutesInOneDegree, (double)arcminuteQuantity.Value, ArcminutesTolerance);
- Assert.Equal(AngleUnit.Arcminute, arcminuteQuantity.Unit);
-
- var arcsecondQuantity = degree.ToUnit(AngleUnit.Arcsecond);
- AssertEx.EqualTolerance(ArcsecondsInOneDegree, (double)arcsecondQuantity.Value, ArcsecondsTolerance);
- Assert.Equal(AngleUnit.Arcsecond, arcsecondQuantity.Unit);
-
- var centiradianQuantity = degree.ToUnit(AngleUnit.Centiradian);
- AssertEx.EqualTolerance(CentiradiansInOneDegree, (double)centiradianQuantity.Value, CentiradiansTolerance);
- Assert.Equal(AngleUnit.Centiradian, centiradianQuantity.Unit);
-
- var deciradianQuantity = degree.ToUnit(AngleUnit.Deciradian);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, (double)deciradianQuantity.Value, DeciradiansTolerance);
- Assert.Equal(AngleUnit.Deciradian, deciradianQuantity.Unit);
-
- var degreeQuantity = degree.ToUnit(AngleUnit.Degree);
- AssertEx.EqualTolerance(DegreesInOneDegree, (double)degreeQuantity.Value, DegreesTolerance);
- Assert.Equal(AngleUnit.Degree, degreeQuantity.Unit);
-
- var gradianQuantity = degree.ToUnit(AngleUnit.Gradian);
- AssertEx.EqualTolerance(GradiansInOneDegree, (double)gradianQuantity.Value, GradiansTolerance);
- Assert.Equal(AngleUnit.Gradian, gradianQuantity.Unit);
-
- var microdegreeQuantity = degree.ToUnit(AngleUnit.Microdegree);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, (double)microdegreeQuantity.Value, MicrodegreesTolerance);
- Assert.Equal(AngleUnit.Microdegree, microdegreeQuantity.Unit);
-
- var microradianQuantity = degree.ToUnit(AngleUnit.Microradian);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, (double)microradianQuantity.Value, MicroradiansTolerance);
- Assert.Equal(AngleUnit.Microradian, microradianQuantity.Unit);
-
- var millidegreeQuantity = degree.ToUnit(AngleUnit.Millidegree);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, (double)millidegreeQuantity.Value, MillidegreesTolerance);
- Assert.Equal(AngleUnit.Millidegree, millidegreeQuantity.Unit);
-
- var milliradianQuantity = degree.ToUnit(AngleUnit.Milliradian);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, (double)milliradianQuantity.Value, MilliradiansTolerance);
- Assert.Equal(AngleUnit.Milliradian, milliradianQuantity.Unit);
-
- var nanodegreeQuantity = degree.ToUnit(AngleUnit.Nanodegree);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, (double)nanodegreeQuantity.Value, NanodegreesTolerance);
- Assert.Equal(AngleUnit.Nanodegree, nanodegreeQuantity.Unit);
-
- var nanoradianQuantity = degree.ToUnit(AngleUnit.Nanoradian);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, (double)nanoradianQuantity.Value, NanoradiansTolerance);
- Assert.Equal(AngleUnit.Nanoradian, nanoradianQuantity.Unit);
-
- var radianQuantity = degree.ToUnit(AngleUnit.Radian);
- AssertEx.EqualTolerance(RadiansInOneDegree, (double)radianQuantity.Value, RadiansTolerance);
- Assert.Equal(AngleUnit.Radian, radianQuantity.Unit);
-
- var revolutionQuantity = degree.ToUnit(AngleUnit.Revolution);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, (double)revolutionQuantity.Value, RevolutionsTolerance);
- Assert.Equal(AngleUnit.Revolution, revolutionQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Angle degree = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(1, Angle.FromArcminutes(degree.Arcminutes).Degrees, ArcminutesTolerance);
- AssertEx.EqualTolerance(1, Angle.FromArcseconds(degree.Arcseconds).Degrees, ArcsecondsTolerance);
- AssertEx.EqualTolerance(1, Angle.FromCentiradians(degree.Centiradians).Degrees, CentiradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromDeciradians(degree.Deciradians).Degrees, DeciradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromDegrees(degree.Degrees).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.FromGradians(degree.Gradians).Degrees, GradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromMicrodegrees(degree.Microdegrees).Degrees, MicrodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.FromMicroradians(degree.Microradians).Degrees, MicroradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromMillidegrees(degree.Millidegrees).Degrees, MillidegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.FromMilliradians(degree.Milliradians).Degrees, MilliradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromNanodegrees(degree.Nanodegrees).Degrees, NanodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.FromNanoradians(degree.Nanoradians).Degrees, NanoradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromRadians(degree.Radians).Degrees, RadiansTolerance);
- AssertEx.EqualTolerance(1, Angle.FromRevolutions(degree.Revolutions).Degrees, RevolutionsTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Angle v = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(-1, -v.Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(2, (Angle.FromDegrees(3)-v).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(2, (v + v).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(10, (v*10).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(10, (10*v).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(2, (Angle.FromDegrees(10)/5).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(2, Angle.FromDegrees(10)/Angle.FromDegrees(5), DegreesTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Angle oneDegree = Angle.FromDegrees(1);
- Angle twoDegrees = Angle.FromDegrees(2);
-
- Assert.True(oneDegree < twoDegrees);
- Assert.True(oneDegree <= twoDegrees);
- Assert.True(twoDegrees > oneDegree);
- Assert.True(twoDegrees >= oneDegree);
-
- Assert.False(oneDegree > twoDegrees);
- Assert.False(oneDegree >= twoDegrees);
- Assert.False(twoDegrees < oneDegree);
- Assert.False(twoDegrees <= oneDegree);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.Equal(0, degree.CompareTo(degree));
- Assert.True(degree.CompareTo(Angle.Zero) > 0);
- Assert.True(Angle.Zero.CompareTo(degree) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.Throws(() => degree.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.Throws(() => degree.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Angle a = Angle.FromDegrees(1);
- Angle b = Angle.FromDegrees(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()
- {
- Angle v = Angle.FromDegrees(1);
- Assert.True(v.Equals(Angle.FromDegrees(1), Angle.FromDegrees(DegreesTolerance)));
- Assert.False(v.Equals(Angle.Zero, Angle.FromDegrees(DegreesTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.False(degree.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.False(degree.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
deleted file mode 100644
index 7515f60b10..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ApparentEnergy.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ApparentEnergyTestsBase
- {
- protected abstract double KilovoltampereHoursInOneVoltampereHour { get; }
- protected abstract double MegavoltampereHoursInOneVoltampereHour { get; }
- protected abstract double VoltampereHoursInOneVoltampereHour { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double KilovoltampereHoursTolerance { get { return 1e-5; } }
- protected virtual double MegavoltampereHoursTolerance { get { return 1e-5; } }
- protected virtual double VoltampereHoursTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void VoltampereHourToApparentEnergyUnits()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.KilovoltampereHours, KilovoltampereHoursTolerance);
- AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.MegavoltampereHours, MegavoltampereHoursTolerance);
- AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.VoltampereHours, VoltampereHoursTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.KilovoltampereHour).KilovoltampereHours, KilovoltampereHoursTolerance);
- AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.MegavoltampereHour).MegavoltampereHours, MegavoltampereHoursTolerance);
- AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.VoltampereHour).VoltampereHours, VoltampereHoursTolerance);
- }
-
- [Fact]
- public void As()
- {
- var voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.KilovoltampereHour), KilovoltampereHoursTolerance);
- AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.MegavoltampereHour), MegavoltampereHoursTolerance);
- AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.VoltampereHour), VoltampereHoursTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var voltamperehour = ApparentEnergy.FromVoltampereHours(1);
-
- var kilovoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.KilovoltampereHour);
- AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, (double)kilovoltamperehourQuantity.Value, KilovoltampereHoursTolerance);
- Assert.Equal(ApparentEnergyUnit.KilovoltampereHour, kilovoltamperehourQuantity.Unit);
-
- var megavoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.MegavoltampereHour);
- AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, (double)megavoltamperehourQuantity.Value, MegavoltampereHoursTolerance);
- Assert.Equal(ApparentEnergyUnit.MegavoltampereHour, megavoltamperehourQuantity.Unit);
-
- var voltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.VoltampereHour);
- AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, (double)voltamperehourQuantity.Value, VoltampereHoursTolerance);
- Assert.Equal(ApparentEnergyUnit.VoltampereHour, voltamperehourQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- AssertEx.EqualTolerance(1, ApparentEnergy.FromKilovoltampereHours(voltamperehour.KilovoltampereHours).VoltampereHours, KilovoltampereHoursTolerance);
- AssertEx.EqualTolerance(1, ApparentEnergy.FromMegavoltampereHours(voltamperehour.MegavoltampereHours).VoltampereHours, MegavoltampereHoursTolerance);
- AssertEx.EqualTolerance(1, ApparentEnergy.FromVoltampereHours(voltamperehour.VoltampereHours).VoltampereHours, VoltampereHoursTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ApparentEnergy v = ApparentEnergy.FromVoltampereHours(1);
- AssertEx.EqualTolerance(-1, -v.VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(3)-v).VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(2, (v + v).VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(10, (v*10).VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(10, (10*v).VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(10)/5).VoltampereHours, VoltampereHoursTolerance);
- AssertEx.EqualTolerance(2, ApparentEnergy.FromVoltampereHours(10)/ApparentEnergy.FromVoltampereHours(5), VoltampereHoursTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ApparentEnergy oneVoltampereHour = ApparentEnergy.FromVoltampereHours(1);
- ApparentEnergy twoVoltampereHours = ApparentEnergy.FromVoltampereHours(2);
-
- Assert.True(oneVoltampereHour < twoVoltampereHours);
- Assert.True(oneVoltampereHour <= twoVoltampereHours);
- Assert.True(twoVoltampereHours > oneVoltampereHour);
- Assert.True(twoVoltampereHours >= oneVoltampereHour);
-
- Assert.False(oneVoltampereHour > twoVoltampereHours);
- Assert.False(oneVoltampereHour >= twoVoltampereHours);
- Assert.False(twoVoltampereHours < oneVoltampereHour);
- Assert.False(twoVoltampereHours <= oneVoltampereHour);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- Assert.Equal(0, voltamperehour.CompareTo(voltamperehour));
- Assert.True(voltamperehour.CompareTo(ApparentEnergy.Zero) > 0);
- Assert.True(ApparentEnergy.Zero.CompareTo(voltamperehour) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- Assert.Throws(() => voltamperehour.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- Assert.Throws(() => voltamperehour.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ApparentEnergy a = ApparentEnergy.FromVoltampereHours(1);
- ApparentEnergy b = ApparentEnergy.FromVoltampereHours(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()
- {
- ApparentEnergy v = ApparentEnergy.FromVoltampereHours(1);
- Assert.True(v.Equals(ApparentEnergy.FromVoltampereHours(1), ApparentEnergy.FromVoltampereHours(VoltampereHoursTolerance)));
- Assert.False(v.Equals(ApparentEnergy.Zero, ApparentEnergy.FromVoltampereHours(VoltampereHoursTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- Assert.False(voltamperehour.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1);
- Assert.False(voltamperehour.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
deleted file mode 100644
index 198401e9cd..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ApparentPower.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ApparentPowerTestsBase
- {
- protected abstract double GigavoltamperesInOneVoltampere { get; }
- protected abstract double KilovoltamperesInOneVoltampere { get; }
- protected abstract double MegavoltamperesInOneVoltampere { get; }
- protected abstract double VoltamperesInOneVoltampere { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double GigavoltamperesTolerance { get { return 1e-5; } }
- protected virtual double KilovoltamperesTolerance { get { return 1e-5; } }
- protected virtual double MegavoltamperesTolerance { get { return 1e-5; } }
- protected virtual double VoltamperesTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void VoltampereToApparentPowerUnits()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.Gigavoltamperes, GigavoltamperesTolerance);
- AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.Kilovoltamperes, KilovoltamperesTolerance);
- AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.Megavoltamperes, MegavoltamperesTolerance);
- AssertEx.EqualTolerance(VoltamperesInOneVoltampere, voltampere.Voltamperes, VoltamperesTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Gigavoltampere).Gigavoltamperes, GigavoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Kilovoltampere).Kilovoltamperes, KilovoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Megavoltampere).Megavoltamperes, MegavoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Voltampere).Voltamperes, VoltamperesTolerance);
- }
-
- [Fact]
- public void As()
- {
- var voltampere = ApparentPower.FromVoltamperes(1);
- AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Gigavoltampere), GigavoltamperesTolerance);
- AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Kilovoltampere), KilovoltamperesTolerance);
- AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Megavoltampere), MegavoltamperesTolerance);
- AssertEx.EqualTolerance(VoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Voltampere), VoltamperesTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var voltampere = ApparentPower.FromVoltamperes(1);
-
- var gigavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Gigavoltampere);
- AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, (double)gigavoltampereQuantity.Value, GigavoltamperesTolerance);
- Assert.Equal(ApparentPowerUnit.Gigavoltampere, gigavoltampereQuantity.Unit);
-
- var kilovoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Kilovoltampere);
- AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, (double)kilovoltampereQuantity.Value, KilovoltamperesTolerance);
- Assert.Equal(ApparentPowerUnit.Kilovoltampere, kilovoltampereQuantity.Unit);
-
- var megavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Megavoltampere);
- AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, (double)megavoltampereQuantity.Value, MegavoltamperesTolerance);
- Assert.Equal(ApparentPowerUnit.Megavoltampere, megavoltampereQuantity.Unit);
-
- var voltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Voltampere);
- AssertEx.EqualTolerance(VoltamperesInOneVoltampere, (double)voltampereQuantity.Value, VoltamperesTolerance);
- Assert.Equal(ApparentPowerUnit.Voltampere, voltampereQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- AssertEx.EqualTolerance(1, ApparentPower.FromGigavoltamperes(voltampere.Gigavoltamperes).Voltamperes, GigavoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.FromKilovoltamperes(voltampere.Kilovoltamperes).Voltamperes, KilovoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.FromMegavoltamperes(voltampere.Megavoltamperes).Voltamperes, MegavoltamperesTolerance);
- AssertEx.EqualTolerance(1, ApparentPower.FromVoltamperes(voltampere.Voltamperes).Voltamperes, VoltamperesTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ApparentPower v = ApparentPower.FromVoltamperes(1);
- AssertEx.EqualTolerance(-1, -v.Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(3)-v).Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(2, (v + v).Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(10, (v*10).Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(10, (10*v).Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(10)/5).Voltamperes, VoltamperesTolerance);
- AssertEx.EqualTolerance(2, ApparentPower.FromVoltamperes(10)/ApparentPower.FromVoltamperes(5), VoltamperesTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ApparentPower oneVoltampere = ApparentPower.FromVoltamperes(1);
- ApparentPower twoVoltamperes = ApparentPower.FromVoltamperes(2);
-
- Assert.True(oneVoltampere < twoVoltamperes);
- Assert.True(oneVoltampere <= twoVoltamperes);
- Assert.True(twoVoltamperes > oneVoltampere);
- Assert.True(twoVoltamperes >= oneVoltampere);
-
- Assert.False(oneVoltampere > twoVoltamperes);
- Assert.False(oneVoltampere >= twoVoltamperes);
- Assert.False(twoVoltamperes < oneVoltampere);
- Assert.False(twoVoltamperes <= oneVoltampere);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- Assert.Equal(0, voltampere.CompareTo(voltampere));
- Assert.True(voltampere.CompareTo(ApparentPower.Zero) > 0);
- Assert.True(ApparentPower.Zero.CompareTo(voltampere) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- Assert.Throws(() => voltampere.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- Assert.Throws(() => voltampere.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ApparentPower a = ApparentPower.FromVoltamperes(1);
- ApparentPower b = ApparentPower.FromVoltamperes(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()
- {
- ApparentPower v = ApparentPower.FromVoltamperes(1);
- Assert.True(v.Equals(ApparentPower.FromVoltamperes(1), ApparentPower.FromVoltamperes(VoltamperesTolerance)));
- Assert.False(v.Equals(ApparentPower.Zero, ApparentPower.FromVoltamperes(VoltamperesTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- Assert.False(voltampere.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ApparentPower voltampere = ApparentPower.FromVoltamperes(1);
- Assert.False(voltampere.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
deleted file mode 100644
index bb580bc641..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 AreaDensity.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AreaDensityTestsBase
- {
- protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void KilogramPerSquareMeterToAreaDensityUnits()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, AreaDensity.From(1, AreaDensityUnit.KilogramPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
-
- var kilogrampersquaremeterQuantity = kilogrampersquaremeter.ToUnit(AreaDensityUnit.KilogramPerSquareMeter);
- AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, (double)kilogrampersquaremeterQuantity.Value, KilogramsPerSquareMeterTolerance);
- Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, kilogrampersquaremeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- AreaDensity v = AreaDensity.FromKilogramsPerSquareMeter(1);
- AssertEx.EqualTolerance(-1, -v.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(3)-v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(10)/5).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, AreaDensity.FromKilogramsPerSquareMeter(10)/AreaDensity.FromKilogramsPerSquareMeter(5), KilogramsPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- AreaDensity oneKilogramPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- AreaDensity twoKilogramsPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(2);
-
- Assert.True(oneKilogramPerSquareMeter < twoKilogramsPerSquareMeter);
- Assert.True(oneKilogramPerSquareMeter <= twoKilogramsPerSquareMeter);
- Assert.True(twoKilogramsPerSquareMeter > oneKilogramPerSquareMeter);
- Assert.True(twoKilogramsPerSquareMeter >= oneKilogramPerSquareMeter);
-
- Assert.False(oneKilogramPerSquareMeter > twoKilogramsPerSquareMeter);
- Assert.False(oneKilogramPerSquareMeter >= twoKilogramsPerSquareMeter);
- Assert.False(twoKilogramsPerSquareMeter < oneKilogramPerSquareMeter);
- Assert.False(twoKilogramsPerSquareMeter <= oneKilogramPerSquareMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.Equal(0, kilogrampersquaremeter.CompareTo(kilogrampersquaremeter));
- Assert.True(kilogrampersquaremeter.CompareTo(AreaDensity.Zero) > 0);
- Assert.True(AreaDensity.Zero.CompareTo(kilogrampersquaremeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.Throws(() => kilogrampersquaremeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.Throws(() => kilogrampersquaremeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- AreaDensity a = AreaDensity.FromKilogramsPerSquareMeter(1);
- AreaDensity b = AreaDensity.FromKilogramsPerSquareMeter(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()
- {
- AreaDensity v = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.True(v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), AreaDensity.FromKilogramsPerSquareMeter(KilogramsPerSquareMeterTolerance)));
- Assert.False(v.Equals(AreaDensity.Zero, AreaDensity.FromKilogramsPerSquareMeter(KilogramsPerSquareMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.False(kilogrampersquaremeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
- Assert.False(kilogrampersquaremeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
deleted file mode 100644
index 0811084f53..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 AreaMomentOfInertia.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AreaMomentOfInertiaTestsBase
- {
- protected abstract double CentimetersToTheFourthInOneMeterToTheFourth { get; }
- protected abstract double DecimetersToTheFourthInOneMeterToTheFourth { get; }
- protected abstract double FeetToTheFourthInOneMeterToTheFourth { get; }
- protected abstract double InchesToTheFourthInOneMeterToTheFourth { get; }
- protected abstract double MetersToTheFourthInOneMeterToTheFourth { get; }
- protected abstract double MillimetersToTheFourthInOneMeterToTheFourth { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentimetersToTheFourthTolerance { get { return 1e-5; } }
- protected virtual double DecimetersToTheFourthTolerance { get { return 1e-5; } }
- protected virtual double FeetToTheFourthTolerance { get { return 1e-5; } }
- protected virtual double InchesToTheFourthTolerance { get { return 1e-5; } }
- protected virtual double MetersToTheFourthTolerance { get { return 1e-5; } }
- protected virtual double MillimetersToTheFourthTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void MeterToTheFourthToAreaMomentOfInertiaUnits()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.CentimetersToTheFourth, CentimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.DecimetersToTheFourth, DecimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.FeetToTheFourth, FeetToTheFourthTolerance);
- AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, metertothefourth.InchesToTheFourth, InchesToTheFourthTolerance);
- AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, metertothefourth.MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, metertothefourth.MillimetersToTheFourth, MillimetersToTheFourthTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth).CentimetersToTheFourth, CentimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth).DecimetersToTheFourth, DecimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.FootToTheFourth).FeetToTheFourth, FeetToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.InchToTheFourth).InchesToTheFourth, InchesToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MeterToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MillimeterToTheFourth).MillimetersToTheFourth, MillimetersToTheFourthTolerance);
- }
-
- [Fact]
- public void As()
- {
- var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.CentimeterToTheFourth), CentimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.DecimeterToTheFourth), DecimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.FootToTheFourth), FeetToTheFourthTolerance);
- AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.InchToTheFourth), InchesToTheFourthTolerance);
- AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.MeterToTheFourth), MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.MillimeterToTheFourth), MillimetersToTheFourthTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
-
- var centimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth);
- AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, (double)centimetertothefourthQuantity.Value, CentimetersToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.CentimeterToTheFourth, centimetertothefourthQuantity.Unit);
-
- var decimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth);
- AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, (double)decimetertothefourthQuantity.Value, DecimetersToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.DecimeterToTheFourth, decimetertothefourthQuantity.Unit);
-
- var foottothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth);
- AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, (double)foottothefourthQuantity.Value, FeetToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.FootToTheFourth, foottothefourthQuantity.Unit);
-
- var inchtothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth);
- AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, (double)inchtothefourthQuantity.Value, InchesToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.InchToTheFourth, inchtothefourthQuantity.Unit);
-
- var metertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MeterToTheFourth);
- AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, (double)metertothefourthQuantity.Value, MetersToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, metertothefourthQuantity.Unit);
-
- var millimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth);
- AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, (double)millimetertothefourthQuantity.Value, MillimetersToTheFourthTolerance);
- Assert.Equal(AreaMomentOfInertiaUnit.MillimeterToTheFourth, millimetertothefourthQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromCentimetersToTheFourth(metertothefourth.CentimetersToTheFourth).MetersToTheFourth, CentimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromDecimetersToTheFourth(metertothefourth.DecimetersToTheFourth).MetersToTheFourth, DecimetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromFeetToTheFourth(metertothefourth.FeetToTheFourth).MetersToTheFourth, FeetToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromInchesToTheFourth(metertothefourth.InchesToTheFourth).MetersToTheFourth, InchesToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMetersToTheFourth(metertothefourth.MetersToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMillimetersToTheFourth(metertothefourth.MillimetersToTheFourth).MetersToTheFourth, MillimetersToTheFourthTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- AreaMomentOfInertia v = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AssertEx.EqualTolerance(-1, -v.MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(3)-v).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(2, (v + v).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(10, (v*10).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(10, (10*v).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(10)/5).MetersToTheFourth, MetersToTheFourthTolerance);
- AssertEx.EqualTolerance(2, AreaMomentOfInertia.FromMetersToTheFourth(10)/AreaMomentOfInertia.FromMetersToTheFourth(5), MetersToTheFourthTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- AreaMomentOfInertia oneMeterToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AreaMomentOfInertia twoMetersToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(2);
-
- Assert.True(oneMeterToTheFourth < twoMetersToTheFourth);
- Assert.True(oneMeterToTheFourth <= twoMetersToTheFourth);
- Assert.True(twoMetersToTheFourth > oneMeterToTheFourth);
- Assert.True(twoMetersToTheFourth >= oneMeterToTheFourth);
-
- Assert.False(oneMeterToTheFourth > twoMetersToTheFourth);
- Assert.False(oneMeterToTheFourth >= twoMetersToTheFourth);
- Assert.False(twoMetersToTheFourth < oneMeterToTheFourth);
- Assert.False(twoMetersToTheFourth <= oneMeterToTheFourth);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.Equal(0, metertothefourth.CompareTo(metertothefourth));
- Assert.True(metertothefourth.CompareTo(AreaMomentOfInertia.Zero) > 0);
- Assert.True(AreaMomentOfInertia.Zero.CompareTo(metertothefourth) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.Throws(() => metertothefourth.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.Throws(() => metertothefourth.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- AreaMomentOfInertia a = AreaMomentOfInertia.FromMetersToTheFourth(1);
- AreaMomentOfInertia b = AreaMomentOfInertia.FromMetersToTheFourth(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()
- {
- AreaMomentOfInertia v = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.True(v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), AreaMomentOfInertia.FromMetersToTheFourth(MetersToTheFourthTolerance)));
- Assert.False(v.Equals(AreaMomentOfInertia.Zero, AreaMomentOfInertia.FromMetersToTheFourth(MetersToTheFourthTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.False(metertothefourth.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
- Assert.False(metertothefourth.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
deleted file mode 100644
index bc77c9e71f..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Area.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AreaTestsBase
- {
- protected abstract double AcresInOneSquareMeter { get; }
- protected abstract double HectaresInOneSquareMeter { get; }
- protected abstract double SquareCentimetersInOneSquareMeter { get; }
- protected abstract double SquareDecimetersInOneSquareMeter { get; }
- protected abstract double SquareFeetInOneSquareMeter { get; }
- protected abstract double SquareInchesInOneSquareMeter { get; }
- protected abstract double SquareKilometersInOneSquareMeter { get; }
- protected abstract double SquareMetersInOneSquareMeter { get; }
- protected abstract double SquareMicrometersInOneSquareMeter { get; }
- protected abstract double SquareMilesInOneSquareMeter { get; }
- protected abstract double SquareMillimetersInOneSquareMeter { get; }
- protected abstract double SquareYardsInOneSquareMeter { get; }
- protected abstract double UsSurveySquareFeetInOneSquareMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double AcresTolerance { get { return 1e-5; } }
- protected virtual double HectaresTolerance { get { return 1e-5; } }
- protected virtual double SquareCentimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareDecimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareFeetTolerance { get { return 1e-5; } }
- protected virtual double SquareInchesTolerance { get { return 1e-5; } }
- protected virtual double SquareKilometersTolerance { get { return 1e-5; } }
- protected virtual double SquareMetersTolerance { get { return 1e-5; } }
- protected virtual double SquareMicrometersTolerance { get { return 1e-5; } }
- protected virtual double SquareMilesTolerance { get { return 1e-5; } }
- protected virtual double SquareMillimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareYardsTolerance { get { return 1e-5; } }
- protected virtual double UsSurveySquareFeetTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void SquareMeterToAreaUnits()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.Acres, AcresTolerance);
- AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.Hectares, HectaresTolerance);
- AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.SquareCentimeters, SquareCentimetersTolerance);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.SquareDecimeters, SquareDecimetersTolerance);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, squaremeter.SquareFeet, SquareFeetTolerance);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, squaremeter.SquareInches, SquareInchesTolerance);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, squaremeter.SquareKilometers, SquareKilometersTolerance);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, squaremeter.SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, squaremeter.SquareMicrometers, SquareMicrometersTolerance);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, squaremeter.SquareMiles, SquareMilesTolerance);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, squaremeter.SquareMillimeters, SquareMillimetersTolerance);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, squaremeter.SquareYards, SquareYardsTolerance);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, squaremeter.UsSurveySquareFeet, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Acre).Acres, AcresTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Hectare).Hectares, HectaresTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareCentimeter).SquareCentimeters, SquareCentimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareDecimeter).SquareDecimeters, SquareDecimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareFoot).SquareFeet, SquareFeetTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareInch).SquareInches, SquareInchesTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareKilometer).SquareKilometers, SquareKilometersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMeter).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMicrometer).SquareMicrometers, SquareMicrometersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMile).SquareMiles, SquareMilesTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMillimeter).SquareMillimeters, SquareMillimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareYard).SquareYards, SquareYardsTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.UsSurveySquareFoot).UsSurveySquareFeet, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void As()
- {
- var squaremeter = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.As(AreaUnit.Acre), AcresTolerance);
- AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.As(AreaUnit.Hectare), HectaresTolerance);
- AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareCentimeter), SquareCentimetersTolerance);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareDecimeter), SquareDecimetersTolerance);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, squaremeter.As(AreaUnit.SquareFoot), SquareFeetTolerance);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, squaremeter.As(AreaUnit.SquareInch), SquareInchesTolerance);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, squaremeter.As(AreaUnit.SquareKilometer), SquareKilometersTolerance);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMeter), SquareMetersTolerance);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMicrometer), SquareMicrometersTolerance);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, squaremeter.As(AreaUnit.SquareMile), SquareMilesTolerance);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMillimeter), SquareMillimetersTolerance);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, squaremeter.As(AreaUnit.SquareYard), SquareYardsTolerance);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, squaremeter.As(AreaUnit.UsSurveySquareFoot), UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var squaremeter = Area.FromSquareMeters(1);
-
- var acreQuantity = squaremeter.ToUnit(AreaUnit.Acre);
- AssertEx.EqualTolerance(AcresInOneSquareMeter, (double)acreQuantity.Value, AcresTolerance);
- Assert.Equal(AreaUnit.Acre, acreQuantity.Unit);
-
- var hectareQuantity = squaremeter.ToUnit(AreaUnit.Hectare);
- AssertEx.EqualTolerance(HectaresInOneSquareMeter, (double)hectareQuantity.Value, HectaresTolerance);
- Assert.Equal(AreaUnit.Hectare, hectareQuantity.Unit);
-
- var squarecentimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareCentimeter);
- AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, (double)squarecentimeterQuantity.Value, SquareCentimetersTolerance);
- Assert.Equal(AreaUnit.SquareCentimeter, squarecentimeterQuantity.Unit);
-
- var squaredecimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareDecimeter);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, (double)squaredecimeterQuantity.Value, SquareDecimetersTolerance);
- Assert.Equal(AreaUnit.SquareDecimeter, squaredecimeterQuantity.Unit);
-
- var squarefootQuantity = squaremeter.ToUnit(AreaUnit.SquareFoot);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, (double)squarefootQuantity.Value, SquareFeetTolerance);
- Assert.Equal(AreaUnit.SquareFoot, squarefootQuantity.Unit);
-
- var squareinchQuantity = squaremeter.ToUnit(AreaUnit.SquareInch);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, (double)squareinchQuantity.Value, SquareInchesTolerance);
- Assert.Equal(AreaUnit.SquareInch, squareinchQuantity.Unit);
-
- var squarekilometerQuantity = squaremeter.ToUnit(AreaUnit.SquareKilometer);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, (double)squarekilometerQuantity.Value, SquareKilometersTolerance);
- Assert.Equal(AreaUnit.SquareKilometer, squarekilometerQuantity.Unit);
-
- var squaremeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMeter);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, (double)squaremeterQuantity.Value, SquareMetersTolerance);
- Assert.Equal(AreaUnit.SquareMeter, squaremeterQuantity.Unit);
-
- var squaremicrometerQuantity = squaremeter.ToUnit(AreaUnit.SquareMicrometer);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, (double)squaremicrometerQuantity.Value, SquareMicrometersTolerance);
- Assert.Equal(AreaUnit.SquareMicrometer, squaremicrometerQuantity.Unit);
-
- var squaremileQuantity = squaremeter.ToUnit(AreaUnit.SquareMile);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, (double)squaremileQuantity.Value, SquareMilesTolerance);
- Assert.Equal(AreaUnit.SquareMile, squaremileQuantity.Unit);
-
- var squaremillimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMillimeter);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, (double)squaremillimeterQuantity.Value, SquareMillimetersTolerance);
- Assert.Equal(AreaUnit.SquareMillimeter, squaremillimeterQuantity.Unit);
-
- var squareyardQuantity = squaremeter.ToUnit(AreaUnit.SquareYard);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, (double)squareyardQuantity.Value, SquareYardsTolerance);
- Assert.Equal(AreaUnit.SquareYard, squareyardQuantity.Unit);
-
- var ussurveysquarefootQuantity = squaremeter.ToUnit(AreaUnit.UsSurveySquareFoot);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, (double)ussurveysquarefootQuantity.Value, UsSurveySquareFeetTolerance);
- Assert.Equal(AreaUnit.UsSurveySquareFoot, ussurveysquarefootQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(1, Area.FromAcres(squaremeter.Acres).SquareMeters, AcresTolerance);
- AssertEx.EqualTolerance(1, Area.FromHectares(squaremeter.Hectares).SquareMeters, HectaresTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareCentimeters(squaremeter.SquareCentimeters).SquareMeters, SquareCentimetersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareDecimeters(squaremeter.SquareDecimeters).SquareMeters, SquareDecimetersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareFeet(squaremeter.SquareFeet).SquareMeters, SquareFeetTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareInches(squaremeter.SquareInches).SquareMeters, SquareInchesTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareKilometers(squaremeter.SquareKilometers).SquareMeters, SquareKilometersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareMeters(squaremeter.SquareMeters).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareMicrometers(squaremeter.SquareMicrometers).SquareMeters, SquareMicrometersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareMiles(squaremeter.SquareMiles).SquareMeters, SquareMilesTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareMillimeters(squaremeter.SquareMillimeters).SquareMeters, SquareMillimetersTolerance);
- AssertEx.EqualTolerance(1, Area.FromSquareYards(squaremeter.SquareYards).SquareMeters, SquareYardsTolerance);
- AssertEx.EqualTolerance(1, Area.FromUsSurveySquareFeet(squaremeter.UsSurveySquareFeet).SquareMeters, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Area v = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(-1, -v.SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(2, (Area.FromSquareMeters(3)-v).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(2, (v + v).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(10, (v*10).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(10, (10*v).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(2, (Area.FromSquareMeters(10)/5).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(2, Area.FromSquareMeters(10)/Area.FromSquareMeters(5), SquareMetersTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Area oneSquareMeter = Area.FromSquareMeters(1);
- Area twoSquareMeters = Area.FromSquareMeters(2);
-
- Assert.True(oneSquareMeter < twoSquareMeters);
- Assert.True(oneSquareMeter <= twoSquareMeters);
- Assert.True(twoSquareMeters > oneSquareMeter);
- Assert.True(twoSquareMeters >= oneSquareMeter);
-
- Assert.False(oneSquareMeter > twoSquareMeters);
- Assert.False(oneSquareMeter >= twoSquareMeters);
- Assert.False(twoSquareMeters < oneSquareMeter);
- Assert.False(twoSquareMeters <= oneSquareMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.Equal(0, squaremeter.CompareTo(squaremeter));
- Assert.True(squaremeter.CompareTo(Area.Zero) > 0);
- Assert.True(Area.Zero.CompareTo(squaremeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.Throws(() => squaremeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.Throws(() => squaremeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Area a = Area.FromSquareMeters(1);
- Area b = Area.FromSquareMeters(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()
- {
- Area v = Area.FromSquareMeters(1);
- Assert.True(v.Equals(Area.FromSquareMeters(1), Area.FromSquareMeters(SquareMetersTolerance)));
- Assert.False(v.Equals(Area.Zero, Area.FromSquareMeters(SquareMetersTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.False(squaremeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.False(squaremeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AreaUnit.Undefined, Area.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
deleted file mode 100644
index 6d249382a5..0000000000
--- a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
+++ /dev/null
@@ -1,447 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 BitRate.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class BitRateTestsBase
- {
- protected abstract double BitsPerSecondInOneBitPerSecond { get; }
- protected abstract double BytesPerSecondInOneBitPerSecond { get; }
- protected abstract double ExabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double ExabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double GibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double GibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double GigabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double GigabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double KibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double KibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double KilobitsPerSecondInOneBitPerSecond { get; }
- protected abstract double KilobytesPerSecondInOneBitPerSecond { get; }
- protected abstract double MebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double MebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double MegabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double MegabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double PebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double PebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double PetabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double PetabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double TebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double TebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double TerabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double TerabytesPerSecondInOneBitPerSecond { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double BitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double BytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void BitPerSecondToBitRateUnits()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, bitpersecond.BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, bitpersecond.BytesPerSecond, BytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, bitpersecond.ExabitsPerSecond, ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, bitpersecond.ExabytesPerSecond, ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, bitpersecond.ExbibitsPerSecond, ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, bitpersecond.ExbibytesPerSecond, ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, bitpersecond.GibibitsPerSecond, GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, bitpersecond.GibibytesPerSecond, GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, bitpersecond.GigabitsPerSecond, GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, bitpersecond.GigabytesPerSecond, GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, bitpersecond.KibibitsPerSecond, KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, bitpersecond.KibibytesPerSecond, KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, bitpersecond.KilobitsPerSecond, KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, bitpersecond.KilobytesPerSecond, KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, bitpersecond.MebibitsPerSecond, MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, bitpersecond.MebibytesPerSecond, MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, bitpersecond.MegabitsPerSecond, MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, bitpersecond.MegabytesPerSecond, MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, bitpersecond.PebibitsPerSecond, PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, bitpersecond.PebibytesPerSecond, PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, bitpersecond.PetabitsPerSecond, PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, bitpersecond.PetabytesPerSecond, PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, bitpersecond.TebibitsPerSecond, TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, bitpersecond.TebibytesPerSecond, TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, bitpersecond.TerabitsPerSecond, TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, bitpersecond.TerabytesPerSecond, TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.BitPerSecond).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.BytePerSecond).BytesPerSecond, BytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExabitPerSecond).ExabitsPerSecond, ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExabytePerSecond).ExabytesPerSecond, ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExbibitPerSecond).ExbibitsPerSecond, ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExbibytePerSecond).ExbibytesPerSecond, ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GibibitPerSecond).GibibitsPerSecond, GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GibibytePerSecond).GibibytesPerSecond, GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GigabitPerSecond).GigabitsPerSecond, GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GigabytePerSecond).GigabytesPerSecond, GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KibibitPerSecond).KibibitsPerSecond, KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KibibytePerSecond).KibibytesPerSecond, KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KilobitPerSecond).KilobitsPerSecond, KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KilobytePerSecond).KilobytesPerSecond, KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MebibitPerSecond).MebibitsPerSecond, MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MebibytePerSecond).MebibytesPerSecond, MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MegabitPerSecond).MegabitsPerSecond, MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MegabytePerSecond).MegabytesPerSecond, MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PebibitPerSecond).PebibitsPerSecond, PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PebibytePerSecond).PebibytesPerSecond, PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PetabitPerSecond).PetabitsPerSecond, PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PetabytePerSecond).PetabytesPerSecond, PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TebibitPerSecond).TebibitsPerSecond, TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TebibytePerSecond).TebibytesPerSecond, TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TerabitPerSecond).TerabitsPerSecond, TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TerabytePerSecond).TerabytesPerSecond, TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void As()
- {
- var bitpersecond = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.BitPerSecond), BitsPerSecondTolerance);
- AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.BytePerSecond), BytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExabitPerSecond), ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExabytePerSecond), ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExbibitPerSecond), ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExbibytePerSecond), ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GibibitPerSecond), GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GibibytePerSecond), GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GigabitPerSecond), GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GigabytePerSecond), GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KibibitPerSecond), KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KibibytePerSecond), KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KilobitPerSecond), KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KilobytePerSecond), KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MebibitPerSecond), MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MebibytePerSecond), MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MegabitPerSecond), MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MegabytePerSecond), MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PebibitPerSecond), PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PebibytePerSecond), PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PetabitPerSecond), PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PetabytePerSecond), PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TebibitPerSecond), TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TebibytePerSecond), TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TerabitPerSecond), TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TerabytePerSecond), TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var bitpersecond = BitRate.FromBitsPerSecond(1);
-
- var bitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BitPerSecond);
- AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, (double)bitpersecondQuantity.Value, BitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.BitPerSecond, bitpersecondQuantity.Unit);
-
- var bytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BytePerSecond);
- AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, (double)bytepersecondQuantity.Value, BytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.BytePerSecond, bytepersecondQuantity.Unit);
-
- var exabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabitPerSecond);
- AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, (double)exabitpersecondQuantity.Value, ExabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExabitPerSecond, exabitpersecondQuantity.Unit);
-
- var exabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabytePerSecond);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, (double)exabytepersecondQuantity.Value, ExabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExabytePerSecond, exabytepersecondQuantity.Unit);
-
- var exbibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibitPerSecond);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, (double)exbibitpersecondQuantity.Value, ExbibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExbibitPerSecond, exbibitpersecondQuantity.Unit);
-
- var exbibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibytePerSecond);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, (double)exbibytepersecondQuantity.Value, ExbibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExbibytePerSecond, exbibytepersecondQuantity.Unit);
-
- var gibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibitPerSecond);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, (double)gibibitpersecondQuantity.Value, GibibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.GibibitPerSecond, gibibitpersecondQuantity.Unit);
-
- var gibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibytePerSecond);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, (double)gibibytepersecondQuantity.Value, GibibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.GibibytePerSecond, gibibytepersecondQuantity.Unit);
-
- var gigabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabitPerSecond);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, (double)gigabitpersecondQuantity.Value, GigabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.GigabitPerSecond, gigabitpersecondQuantity.Unit);
-
- var gigabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabytePerSecond);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, (double)gigabytepersecondQuantity.Value, GigabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.GigabytePerSecond, gigabytepersecondQuantity.Unit);
-
- var kibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibitPerSecond);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, (double)kibibitpersecondQuantity.Value, KibibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.KibibitPerSecond, kibibitpersecondQuantity.Unit);
-
- var kibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibytePerSecond);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, (double)kibibytepersecondQuantity.Value, KibibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.KibibytePerSecond, kibibytepersecondQuantity.Unit);
-
- var kilobitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobitPerSecond);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, (double)kilobitpersecondQuantity.Value, KilobitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.KilobitPerSecond, kilobitpersecondQuantity.Unit);
-
- var kilobytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobytePerSecond);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, (double)kilobytepersecondQuantity.Value, KilobytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.KilobytePerSecond, kilobytepersecondQuantity.Unit);
-
- var mebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibitPerSecond);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, (double)mebibitpersecondQuantity.Value, MebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.MebibitPerSecond, mebibitpersecondQuantity.Unit);
-
- var mebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibytePerSecond);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, (double)mebibytepersecondQuantity.Value, MebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.MebibytePerSecond, mebibytepersecondQuantity.Unit);
-
- var megabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabitPerSecond);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, (double)megabitpersecondQuantity.Value, MegabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.MegabitPerSecond, megabitpersecondQuantity.Unit);
-
- var megabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabytePerSecond);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, (double)megabytepersecondQuantity.Value, MegabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.MegabytePerSecond, megabytepersecondQuantity.Unit);
-
- var pebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibitPerSecond);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, (double)pebibitpersecondQuantity.Value, PebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.PebibitPerSecond, pebibitpersecondQuantity.Unit);
-
- var pebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibytePerSecond);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, (double)pebibytepersecondQuantity.Value, PebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.PebibytePerSecond, pebibytepersecondQuantity.Unit);
-
- var petabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabitPerSecond);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, (double)petabitpersecondQuantity.Value, PetabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.PetabitPerSecond, petabitpersecondQuantity.Unit);
-
- var petabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabytePerSecond);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, (double)petabytepersecondQuantity.Value, PetabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.PetabytePerSecond, petabytepersecondQuantity.Unit);
-
- var tebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibitPerSecond);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, (double)tebibitpersecondQuantity.Value, TebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.TebibitPerSecond, tebibitpersecondQuantity.Unit);
-
- var tebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibytePerSecond);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, (double)tebibytepersecondQuantity.Value, TebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.TebibytePerSecond, tebibytepersecondQuantity.Unit);
-
- var terabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabitPerSecond);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, (double)terabitpersecondQuantity.Value, TerabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.TerabitPerSecond, terabitpersecondQuantity.Unit);
-
- var terabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabytePerSecond);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, (double)terabytepersecondQuantity.Value, TerabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.TerabytePerSecond, terabytepersecondQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(1, BitRate.FromBitsPerSecond(bitpersecond.BitsPerSecond).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromBytesPerSecond(bitpersecond.BytesPerSecond).BitsPerSecond, BytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromExabitsPerSecond(bitpersecond.ExabitsPerSecond).BitsPerSecond, ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromExabytesPerSecond(bitpersecond.ExabytesPerSecond).BitsPerSecond, ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromExbibitsPerSecond(bitpersecond.ExbibitsPerSecond).BitsPerSecond, ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromExbibytesPerSecond(bitpersecond.ExbibytesPerSecond).BitsPerSecond, ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromGibibitsPerSecond(bitpersecond.GibibitsPerSecond).BitsPerSecond, GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromGibibytesPerSecond(bitpersecond.GibibytesPerSecond).BitsPerSecond, GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromGigabitsPerSecond(bitpersecond.GigabitsPerSecond).BitsPerSecond, GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromGigabytesPerSecond(bitpersecond.GigabytesPerSecond).BitsPerSecond, GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromKibibitsPerSecond(bitpersecond.KibibitsPerSecond).BitsPerSecond, KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromKibibytesPerSecond(bitpersecond.KibibytesPerSecond).BitsPerSecond, KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromKilobitsPerSecond(bitpersecond.KilobitsPerSecond).BitsPerSecond, KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromKilobytesPerSecond(bitpersecond.KilobytesPerSecond).BitsPerSecond, KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromMebibitsPerSecond(bitpersecond.MebibitsPerSecond).BitsPerSecond, MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromMebibytesPerSecond(bitpersecond.MebibytesPerSecond).BitsPerSecond, MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromMegabitsPerSecond(bitpersecond.MegabitsPerSecond).BitsPerSecond, MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromMegabytesPerSecond(bitpersecond.MegabytesPerSecond).BitsPerSecond, MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromPebibitsPerSecond(bitpersecond.PebibitsPerSecond).BitsPerSecond, PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromPebibytesPerSecond(bitpersecond.PebibytesPerSecond).BitsPerSecond, PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromPetabitsPerSecond(bitpersecond.PetabitsPerSecond).BitsPerSecond, PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromPetabytesPerSecond(bitpersecond.PetabytesPerSecond).BitsPerSecond, PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromTebibitsPerSecond(bitpersecond.TebibitsPerSecond).BitsPerSecond, TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromTebibytesPerSecond(bitpersecond.TebibytesPerSecond).BitsPerSecond, TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromTerabitsPerSecond(bitpersecond.TerabitsPerSecond).BitsPerSecond, TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.FromTerabytesPerSecond(bitpersecond.TerabytesPerSecond).BitsPerSecond, TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- BitRate v = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(-1, -v.BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(3)-v).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(2, (v + v).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(10, (v*10).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(10, (10*v).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(10)/5).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(2, BitRate.FromBitsPerSecond(10)/BitRate.FromBitsPerSecond(5), BitsPerSecondTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- BitRate oneBitPerSecond = BitRate.FromBitsPerSecond(1);
- BitRate twoBitsPerSecond = BitRate.FromBitsPerSecond(2);
-
- Assert.True(oneBitPerSecond < twoBitsPerSecond);
- Assert.True(oneBitPerSecond <= twoBitsPerSecond);
- Assert.True(twoBitsPerSecond > oneBitPerSecond);
- Assert.True(twoBitsPerSecond >= oneBitPerSecond);
-
- Assert.False(oneBitPerSecond > twoBitsPerSecond);
- Assert.False(oneBitPerSecond >= twoBitsPerSecond);
- Assert.False(twoBitsPerSecond < oneBitPerSecond);
- Assert.False(twoBitsPerSecond <= oneBitPerSecond);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.Equal(0, bitpersecond.CompareTo(bitpersecond));
- Assert.True(bitpersecond.CompareTo(BitRate.Zero) > 0);
- Assert.True(BitRate.Zero.CompareTo(bitpersecond) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.Throws(() => bitpersecond.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.Throws(() => bitpersecond.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- BitRate a = BitRate.FromBitsPerSecond(1);
- BitRate b = BitRate.FromBitsPerSecond(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()
- {
- BitRate v = BitRate.FromBitsPerSecond(1);
- Assert.True(v.Equals(BitRate.FromBitsPerSecond(1), BitRate.FromBitsPerSecond(BitsPerSecondTolerance)));
- Assert.False(v.Equals(BitRate.Zero, BitRate.FromBitsPerSecond(BitsPerSecondTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.False(bitpersecond.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.False(bitpersecond.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
deleted file mode 100644
index 04aa19ffc5..0000000000
--- a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 BrakeSpecificFuelConsumption.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class BrakeSpecificFuelConsumptionTestsBase
- {
- protected abstract double GramsPerKiloWattHourInOneKilogramPerJoule { get; }
- protected abstract double KilogramsPerJouleInOneKilogramPerJoule { get; }
- protected abstract double PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double GramsPerKiloWattHourTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerJouleTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void KilogramPerJouleToBrakeSpecificFuelConsumptionUnits()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.GramsPerKiloWattHour, GramsPerKiloWattHourTolerance);
- AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour).GramsPerKiloWattHour, GramsPerKiloWattHourTolerance);
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour).PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance);
- }
-
- [Fact]
- public void As()
- {
- var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour), GramsPerKiloWattHourTolerance);
- AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), PoundsPerMechanicalHorsepowerHourTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
-
- var gramperkilowatthourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour);
- AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, (double)gramperkilowatthourQuantity.Value, GramsPerKiloWattHourTolerance);
- Assert.Equal(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, gramperkilowatthourQuantity.Unit);
-
- var kilogramperjouleQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule);
- AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, (double)kilogramperjouleQuantity.Value, KilogramsPerJouleTolerance);
- Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, kilogramperjouleQuantity.Unit);
-
- var poundpermechanicalhorsepowerhourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour);
- AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, (double)poundpermechanicalhorsepowerhourQuantity.Value, PoundsPerMechanicalHorsepowerHourTolerance);
- Assert.Equal(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, poundpermechanicalhorsepowerhourQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(kilogramperjoule.GramsPerKiloWattHour).KilogramsPerJoule, GramsPerKiloWattHourTolerance);
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(kilogramperjoule.KilogramsPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(kilogramperjoule.PoundsPerMechanicalHorsepowerHour).KilogramsPerJoule, PoundsPerMechanicalHorsepowerHourTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- AssertEx.EqualTolerance(-1, -v.KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3)-v).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(2, (v + v).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(10, (v*10).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(10, (10*v).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/5).KilogramsPerJoule, KilogramsPerJouleTolerance);
- AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- BrakeSpecificFuelConsumption oneKilogramPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- BrakeSpecificFuelConsumption twoKilogramsPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2);
-
- Assert.True(oneKilogramPerJoule < twoKilogramsPerJoule);
- Assert.True(oneKilogramPerJoule <= twoKilogramsPerJoule);
- Assert.True(twoKilogramsPerJoule > oneKilogramPerJoule);
- Assert.True(twoKilogramsPerJoule >= oneKilogramPerJoule);
-
- Assert.False(oneKilogramPerJoule > twoKilogramsPerJoule);
- Assert.False(oneKilogramPerJoule >= twoKilogramsPerJoule);
- Assert.False(twoKilogramsPerJoule < oneKilogramPerJoule);
- Assert.False(twoKilogramsPerJoule <= oneKilogramPerJoule);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.Equal(0, kilogramperjoule.CompareTo(kilogramperjoule));
- Assert.True(kilogramperjoule.CompareTo(BrakeSpecificFuelConsumption.Zero) > 0);
- Assert.True(BrakeSpecificFuelConsumption.Zero.CompareTo(kilogramperjoule) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.Throws(() => kilogramperjoule.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.Throws(() => kilogramperjoule.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- BrakeSpecificFuelConsumption a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- BrakeSpecificFuelConsumption b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(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()
- {
- BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), BrakeSpecificFuelConsumption.FromKilogramsPerJoule(KilogramsPerJouleTolerance)));
- Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(KilogramsPerJouleTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.False(kilogramperjoule.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
- Assert.False(kilogramperjoule.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
deleted file mode 100644
index fd3a45f621..0000000000
--- a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Capacitance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class CapacitanceTestsBase
- {
- protected abstract double FaradsInOneFarad { get; }
- protected abstract double MicrofaradsInOneFarad { get; }
- protected abstract double MillifaradsInOneFarad { get; }
- protected abstract double NanofaradsInOneFarad { get; }
- protected abstract double PicofaradsInOneFarad { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double FaradsTolerance { get { return 1e-5; } }
- protected virtual double MicrofaradsTolerance { get { return 1e-5; } }
- protected virtual double MillifaradsTolerance { get { return 1e-5; } }
- protected virtual double NanofaradsTolerance { get { return 1e-5; } }
- protected virtual double PicofaradsTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void FaradToCapacitanceUnits()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- AssertEx.EqualTolerance(FaradsInOneFarad, farad.Farads, FaradsTolerance);
- AssertEx.EqualTolerance(MicrofaradsInOneFarad, farad.Microfarads, MicrofaradsTolerance);
- AssertEx.EqualTolerance(MillifaradsInOneFarad, farad.Millifarads, MillifaradsTolerance);
- AssertEx.EqualTolerance(NanofaradsInOneFarad, farad.Nanofarads, NanofaradsTolerance);
- AssertEx.EqualTolerance(PicofaradsInOneFarad, farad.Picofarads, PicofaradsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Farad).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Microfarad).Microfarads, MicrofaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Millifarad).Millifarads, MillifaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Nanofarad).Nanofarads, NanofaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Picofarad).Picofarads, PicofaradsTolerance);
- }
-
- [Fact]
- public void As()
- {
- var farad = Capacitance.FromFarads(1);
- AssertEx.EqualTolerance(FaradsInOneFarad, farad.As(CapacitanceUnit.Farad), FaradsTolerance);
- AssertEx.EqualTolerance(MicrofaradsInOneFarad, farad.As(CapacitanceUnit.Microfarad), MicrofaradsTolerance);
- AssertEx.EqualTolerance(MillifaradsInOneFarad, farad.As(CapacitanceUnit.Millifarad), MillifaradsTolerance);
- AssertEx.EqualTolerance(NanofaradsInOneFarad, farad.As(CapacitanceUnit.Nanofarad), NanofaradsTolerance);
- AssertEx.EqualTolerance(PicofaradsInOneFarad, farad.As(CapacitanceUnit.Picofarad), PicofaradsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var farad = Capacitance.FromFarads(1);
-
- var faradQuantity = farad.ToUnit(CapacitanceUnit.Farad);
- AssertEx.EqualTolerance(FaradsInOneFarad, (double)faradQuantity.Value, FaradsTolerance);
- Assert.Equal(CapacitanceUnit.Farad, faradQuantity.Unit);
-
- var microfaradQuantity = farad.ToUnit(CapacitanceUnit.Microfarad);
- AssertEx.EqualTolerance(MicrofaradsInOneFarad, (double)microfaradQuantity.Value, MicrofaradsTolerance);
- Assert.Equal(CapacitanceUnit.Microfarad, microfaradQuantity.Unit);
-
- var millifaradQuantity = farad.ToUnit(CapacitanceUnit.Millifarad);
- AssertEx.EqualTolerance(MillifaradsInOneFarad, (double)millifaradQuantity.Value, MillifaradsTolerance);
- Assert.Equal(CapacitanceUnit.Millifarad, millifaradQuantity.Unit);
-
- var nanofaradQuantity = farad.ToUnit(CapacitanceUnit.Nanofarad);
- AssertEx.EqualTolerance(NanofaradsInOneFarad, (double)nanofaradQuantity.Value, NanofaradsTolerance);
- Assert.Equal(CapacitanceUnit.Nanofarad, nanofaradQuantity.Unit);
-
- var picofaradQuantity = farad.ToUnit(CapacitanceUnit.Picofarad);
- AssertEx.EqualTolerance(PicofaradsInOneFarad, (double)picofaradQuantity.Value, PicofaradsTolerance);
- Assert.Equal(CapacitanceUnit.Picofarad, picofaradQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.FromMicrofarads(farad.Microfarads).Farads, MicrofaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.FromMillifarads(farad.Millifarads).Farads, MillifaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.FromNanofarads(farad.Nanofarads).Farads, NanofaradsTolerance);
- AssertEx.EqualTolerance(1, Capacitance.FromPicofarads(farad.Picofarads).Farads, PicofaradsTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Capacitance v = Capacitance.FromFarads(1);
- AssertEx.EqualTolerance(-1, -v.Farads, FaradsTolerance);
- AssertEx.EqualTolerance(2, (Capacitance.FromFarads(3)-v).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(2, (v + v).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(10, (v*10).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(10, (10*v).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(2, (Capacitance.FromFarads(10)/5).Farads, FaradsTolerance);
- AssertEx.EqualTolerance(2, Capacitance.FromFarads(10)/Capacitance.FromFarads(5), FaradsTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Capacitance oneFarad = Capacitance.FromFarads(1);
- Capacitance twoFarads = Capacitance.FromFarads(2);
-
- Assert.True(oneFarad < twoFarads);
- Assert.True(oneFarad <= twoFarads);
- Assert.True(twoFarads > oneFarad);
- Assert.True(twoFarads >= oneFarad);
-
- Assert.False(oneFarad > twoFarads);
- Assert.False(oneFarad >= twoFarads);
- Assert.False(twoFarads < oneFarad);
- Assert.False(twoFarads <= oneFarad);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- Assert.Equal(0, farad.CompareTo(farad));
- Assert.True(farad.CompareTo(Capacitance.Zero) > 0);
- Assert.True(Capacitance.Zero.CompareTo(farad) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- Assert.Throws(() => farad.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- Assert.Throws(() => farad.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Capacitance a = Capacitance.FromFarads(1);
- Capacitance b = Capacitance.FromFarads(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()
- {
- Capacitance v = Capacitance.FromFarads(1);
- Assert.True(v.Equals(Capacitance.FromFarads(1), Capacitance.FromFarads(FaradsTolerance)));
- Assert.False(v.Equals(Capacitance.Zero, Capacitance.FromFarads(FaradsTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- Assert.False(farad.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- Assert.False(farad.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs
deleted file mode 100644
index b9cbd62f25..0000000000
--- a/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 CoefficientOfThermalExpansion.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class CoefficientOfThermalExpansionTestsBase
- {
- protected abstract double InverseDegreeCelsiusInOneInverseKelvin { get; }
- protected abstract double InverseDegreeFahrenheitInOneInverseKelvin { get; }
- protected abstract double InverseKelvinInOneInverseKelvin { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double InverseDegreeCelsiusTolerance { get { return 1e-5; } }
- protected virtual double InverseDegreeFahrenheitTolerance { get { return 1e-5; } }
- protected virtual double InverseKelvinTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void InverseKelvinToCoefficientOfThermalExpansionUnits()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.InverseDegreeCelsius, InverseDegreeCelsiusTolerance);
- AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance);
- AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.InverseKelvin, InverseKelvinTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius).InverseDegreeCelsius, InverseDegreeCelsiusTolerance);
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit).InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance);
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseKelvin).InverseKelvin, InverseKelvinTolerance);
- }
-
- [Fact]
- public void As()
- {
- var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius), InverseDegreeCelsiusTolerance);
- AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit), InverseDegreeFahrenheitTolerance);
- AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseKelvin), InverseKelvinTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
-
- var inversedegreecelsiusQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius);
- AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, (double)inversedegreecelsiusQuantity.Value, InverseDegreeCelsiusTolerance);
- Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, inversedegreecelsiusQuantity.Unit);
-
- var inversedegreefahrenheitQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit);
- AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, (double)inversedegreefahrenheitQuantity.Value, InverseDegreeFahrenheitTolerance);
- Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, inversedegreefahrenheitQuantity.Unit);
-
- var inversekelvinQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseKelvin);
- AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, (double)inversekelvinQuantity.Value, InverseKelvinTolerance);
- Assert.Equal(CoefficientOfThermalExpansionUnit.InverseKelvin, inversekelvinQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeCelsius(inversekelvin.InverseDegreeCelsius).InverseKelvin, InverseDegreeCelsiusTolerance);
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(inversekelvin.InverseDegreeFahrenheit).InverseKelvin, InverseDegreeFahrenheitTolerance);
- AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseKelvin(inversekelvin.InverseKelvin).InverseKelvin, InverseKelvinTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- CoefficientOfThermalExpansion v = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- AssertEx.EqualTolerance(-1, -v.InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(3)-v).InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(2, (v + v).InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(10, (v*10).InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(10, (10*v).InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(10)/5).InverseKelvin, InverseKelvinTolerance);
- AssertEx.EqualTolerance(2, CoefficientOfThermalExpansion.FromInverseKelvin(10)/CoefficientOfThermalExpansion.FromInverseKelvin(5), InverseKelvinTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- CoefficientOfThermalExpansion oneInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- CoefficientOfThermalExpansion twoInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(2);
-
- Assert.True(oneInverseKelvin < twoInverseKelvin);
- Assert.True(oneInverseKelvin <= twoInverseKelvin);
- Assert.True(twoInverseKelvin > oneInverseKelvin);
- Assert.True(twoInverseKelvin >= oneInverseKelvin);
-
- Assert.False(oneInverseKelvin > twoInverseKelvin);
- Assert.False(oneInverseKelvin >= twoInverseKelvin);
- Assert.False(twoInverseKelvin < oneInverseKelvin);
- Assert.False(twoInverseKelvin <= oneInverseKelvin);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.Equal(0, inversekelvin.CompareTo(inversekelvin));
- Assert.True(inversekelvin.CompareTo(CoefficientOfThermalExpansion.Zero) > 0);
- Assert.True(CoefficientOfThermalExpansion.Zero.CompareTo(inversekelvin) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.Throws(() => inversekelvin.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.Throws(() => inversekelvin.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- CoefficientOfThermalExpansion a = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- CoefficientOfThermalExpansion b = CoefficientOfThermalExpansion.FromInverseKelvin(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()
- {
- CoefficientOfThermalExpansion v = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.True(v.Equals(CoefficientOfThermalExpansion.FromInverseKelvin(1), CoefficientOfThermalExpansion.FromInverseKelvin(InverseKelvinTolerance)));
- Assert.False(v.Equals(CoefficientOfThermalExpansion.Zero, CoefficientOfThermalExpansion.FromInverseKelvin(InverseKelvinTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.False(inversekelvin.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1);
- Assert.False(inversekelvin.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
deleted file mode 100644
index 3a721ca51e..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
+++ /dev/null
@@ -1,567 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Density.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class DensityTestsBase
- {
- protected abstract double CentigramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double CentigramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double CentigramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilopoundsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double KilopoundsPerCubicInchInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerCubicInchInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerImperialGallonInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerUSGallonInOneKilogramPerCubicMeter { get; }
- protected abstract double SlugsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentigramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } }
- protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } }
- protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void KilogramPerCubicMeterToDensityUnits()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerLiter, CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerMilliliter, CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerDeciLiter, DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerLiter, DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerMilliliter, DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicMeter, GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerDeciLiter, GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerLiter, GramsPerLiterTolerance);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerMilliliter, GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerDeciLiter, MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerLiter, MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerDeciLiter, MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerLiter, MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerMilliliter, MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerDeciLiter, NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerLiter, NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerMilliliter, NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerDeciLiter, PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerLiter, PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerMilliliter, PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerCubicFoot, PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerCubicInch, PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerImperialGallon, PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerUSGallon, PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.SlugsPerCubicFoot, SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicMeter, TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerDeciliter).CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerLiter).CentigramsPerLiter, CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerMilliliter).CentigramsPerMilliliter, CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerDeciliter).DecigramsPerDeciLiter, DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerLiter).DecigramsPerLiter, DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerMilliliter).DecigramsPerMilliliter, DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicCentimeter).GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicMeter).GramsPerCubicMeter, GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicMillimeter).GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerDeciliter).GramsPerDeciLiter, GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerLiter).GramsPerLiter, GramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerMilliliter).GramsPerMilliliter, GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicCentimeter).KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicMillimeter).KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilopoundPerCubicFoot).KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilopoundPerCubicInch).KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerDeciliter).MicrogramsPerDeciLiter, MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerLiter).MicrogramsPerLiter, MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerMilliliter).MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerCubicMeter).MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerDeciliter).MilligramsPerDeciLiter, MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerLiter).MilligramsPerLiter, MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerMilliliter).MilligramsPerMilliliter, MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerDeciliter).NanogramsPerDeciLiter, NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerLiter).NanogramsPerLiter, NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerMilliliter).NanogramsPerMilliliter, NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerDeciliter).PicogramsPerDeciLiter, PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerLiter).PicogramsPerLiter, PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerMilliliter).PicogramsPerMilliliter, PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerCubicFoot).PoundsPerCubicFoot, PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerCubicInch).PoundsPerCubicInch, PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerImperialGallon).PoundsPerImperialGallon, PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerUSGallon).PoundsPerUSGallon, PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.SlugPerCubicFoot).SlugsPerCubicFoot, SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicCentimeter).TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicMeter).TonnesPerCubicMeter, TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicMillimeter).TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerDeciliter), CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerLiter), CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerMilliliter), CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerDeciliter), DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerLiter), DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerMilliliter), DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicCentimeter), GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicMeter), GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicMillimeter), GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerDeciliter), GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerLiter), GramsPerLiterTolerance);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerMilliliter), GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicCentimeter), KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicMeter), KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicMillimeter), KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilopoundPerCubicFoot), KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilopoundPerCubicInch), KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerDeciliter), MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerLiter), MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerMilliliter), MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerCubicMeter), MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerDeciliter), MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerLiter), MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerMilliliter), MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerDeciliter), NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerLiter), NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerMilliliter), NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerDeciliter), PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerLiter), PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerMilliliter), PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerCubicFoot), PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerCubicInch), PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerImperialGallon), PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerUSGallon), PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.SlugPerCubicFoot), SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicCentimeter), TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicMeter), TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicMillimeter), TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
-
- var centigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerDeciliter);
- AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)centigramperdeciliterQuantity.Value, CentigramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.CentigramPerDeciliter, centigramperdeciliterQuantity.Unit);
-
- var centigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerLiter);
- AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, (double)centigramperliterQuantity.Value, CentigramsPerLiterTolerance);
- Assert.Equal(DensityUnit.CentigramPerLiter, centigramperliterQuantity.Unit);
-
- var centigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerMilliliter);
- AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, (double)centigrampermilliliterQuantity.Value, CentigramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.CentigramPerMilliliter, centigrampermilliliterQuantity.Unit);
-
- var decigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerDeciliter);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)decigramperdeciliterQuantity.Value, DecigramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.DecigramPerDeciliter, decigramperdeciliterQuantity.Unit);
-
- var decigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerLiter);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, (double)decigramperliterQuantity.Value, DecigramsPerLiterTolerance);
- Assert.Equal(DensityUnit.DecigramPerLiter, decigramperliterQuantity.Unit);
-
- var decigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerMilliliter);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, (double)decigrampermilliliterQuantity.Value, DecigramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.DecigramPerMilliliter, decigrampermilliliterQuantity.Unit);
-
- var grampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicCentimeter);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)grampercubiccentimeterQuantity.Value, GramsPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicCentimeter, grampercubiccentimeterQuantity.Unit);
-
- var grampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMeter);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, (double)grampercubicmeterQuantity.Value, GramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicMeter, grampercubicmeterQuantity.Unit);
-
- var grampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMillimeter);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)grampercubicmillimeterQuantity.Value, GramsPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicMillimeter, grampercubicmillimeterQuantity.Unit);
-
- var gramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerDeciliter);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, (double)gramperdeciliterQuantity.Value, GramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.GramPerDeciliter, gramperdeciliterQuantity.Unit);
-
- var gramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerLiter);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, (double)gramperliterQuantity.Value, GramsPerLiterTolerance);
- Assert.Equal(DensityUnit.GramPerLiter, gramperliterQuantity.Unit);
-
- var grampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerMilliliter);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, (double)grampermilliliterQuantity.Value, GramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.GramPerMilliliter, grampermilliliterQuantity.Unit);
-
- var kilogrampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicCentimeter);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)kilogrampercubiccentimeterQuantity.Value, KilogramsPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicCentimeter, kilogrampercubiccentimeterQuantity.Unit);
-
- var kilogrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMeter);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmeterQuantity.Value, KilogramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicMeter, kilogrampercubicmeterQuantity.Unit);
-
- var kilogrampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMillimeter);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmillimeterQuantity.Value, KilogramsPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicMillimeter, kilogrampercubicmillimeterQuantity.Unit);
-
- var kilopoundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicFoot);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, (double)kilopoundpercubicfootQuantity.Value, KilopoundsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.KilopoundPerCubicFoot, kilopoundpercubicfootQuantity.Unit);
-
- var kilopoundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicInch);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, (double)kilopoundpercubicinchQuantity.Value, KilopoundsPerCubicInchTolerance);
- Assert.Equal(DensityUnit.KilopoundPerCubicInch, kilopoundpercubicinchQuantity.Unit);
-
- var microgramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerDeciliter);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)microgramperdeciliterQuantity.Value, MicrogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerDeciliter, microgramperdeciliterQuantity.Unit);
-
- var microgramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerLiter);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, (double)microgramperliterQuantity.Value, MicrogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerLiter, microgramperliterQuantity.Unit);
-
- var microgrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerMilliliter);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, (double)microgrampermilliliterQuantity.Value, MicrogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerMilliliter, microgrampermilliliterQuantity.Unit);
-
- var milligrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerCubicMeter);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, (double)milligrampercubicmeterQuantity.Value, MilligramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.MilligramPerCubicMeter, milligrampercubicmeterQuantity.Unit);
-
- var milligramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerDeciliter);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, (double)milligramperdeciliterQuantity.Value, MilligramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.MilligramPerDeciliter, milligramperdeciliterQuantity.Unit);
-
- var milligramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerLiter);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, (double)milligramperliterQuantity.Value, MilligramsPerLiterTolerance);
- Assert.Equal(DensityUnit.MilligramPerLiter, milligramperliterQuantity.Unit);
-
- var milligrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerMilliliter);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, (double)milligrampermilliliterQuantity.Value, MilligramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.MilligramPerMilliliter, milligrampermilliliterQuantity.Unit);
-
- var nanogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerDeciliter);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)nanogramperdeciliterQuantity.Value, NanogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.NanogramPerDeciliter, nanogramperdeciliterQuantity.Unit);
-
- var nanogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerLiter);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, (double)nanogramperliterQuantity.Value, NanogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.NanogramPerLiter, nanogramperliterQuantity.Unit);
-
- var nanogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerMilliliter);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, (double)nanogrampermilliliterQuantity.Value, NanogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.NanogramPerMilliliter, nanogrampermilliliterQuantity.Unit);
-
- var picogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerDeciliter);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)picogramperdeciliterQuantity.Value, PicogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.PicogramPerDeciliter, picogramperdeciliterQuantity.Unit);
-
- var picogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerLiter);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, (double)picogramperliterQuantity.Value, PicogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.PicogramPerLiter, picogramperliterQuantity.Unit);
-
- var picogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerMilliliter);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, (double)picogrampermilliliterQuantity.Value, PicogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.PicogramPerMilliliter, picogrampermilliliterQuantity.Unit);
-
- var poundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicFoot);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, (double)poundpercubicfootQuantity.Value, PoundsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.PoundPerCubicFoot, poundpercubicfootQuantity.Unit);
-
- var poundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicInch);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, (double)poundpercubicinchQuantity.Value, PoundsPerCubicInchTolerance);
- Assert.Equal(DensityUnit.PoundPerCubicInch, poundpercubicinchQuantity.Unit);
-
- var poundperimperialgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerImperialGallon);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, (double)poundperimperialgallonQuantity.Value, PoundsPerImperialGallonTolerance);
- Assert.Equal(DensityUnit.PoundPerImperialGallon, poundperimperialgallonQuantity.Unit);
-
- var poundperusgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerUSGallon);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, (double)poundperusgallonQuantity.Value, PoundsPerUSGallonTolerance);
- Assert.Equal(DensityUnit.PoundPerUSGallon, poundperusgallonQuantity.Unit);
-
- var slugpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.SlugPerCubicFoot);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, (double)slugpercubicfootQuantity.Value, SlugsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.SlugPerCubicFoot, slugpercubicfootQuantity.Unit);
-
- var tonnepercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicCentimeter);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, (double)tonnepercubiccentimeterQuantity.Value, TonnesPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicCentimeter, tonnepercubiccentimeterQuantity.Unit);
-
- var tonnepercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMeter);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, (double)tonnepercubicmeterQuantity.Value, TonnesPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicMeter, tonnepercubicmeterQuantity.Unit);
-
- var tonnepercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMillimeter);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, (double)tonnepercubicmillimeterQuantity.Value, TonnesPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicMillimeter, tonnepercubicmillimeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- AssertEx.EqualTolerance(1, Density.FromCentigramsPerDeciLiter(kilogrampercubicmeter.CentigramsPerDeciLiter).KilogramsPerCubicMeter, CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromDecigramsPerDeciLiter(kilogrampercubicmeter.DecigramsPerDeciLiter).KilogramsPerCubicMeter, DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerDeciLiter(kilogrampercubicmeter.GramsPerDeciLiter).KilogramsPerCubicMeter, GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.FromMicrogramsPerDeciLiter(kilogrampercubicmeter.MicrogramsPerDeciLiter).KilogramsPerCubicMeter, MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMilligramsPerDeciLiter(kilogrampercubicmeter.MilligramsPerDeciLiter).KilogramsPerCubicMeter, MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromNanogramsPerDeciLiter(kilogrampercubicmeter.NanogramsPerDeciLiter).KilogramsPerCubicMeter, NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromPicogramsPerDeciLiter(kilogrampercubicmeter.PicogramsPerDeciLiter).KilogramsPerCubicMeter, PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(1, Density.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(1, Density.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Density v = Density.FromKilogramsPerCubicMeter(1);
- AssertEx.EqualTolerance(-1, -v.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(3)-v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(10)/5).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, Density.FromKilogramsPerCubicMeter(10)/Density.FromKilogramsPerCubicMeter(5), KilogramsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Density oneKilogramPerCubicMeter = Density.FromKilogramsPerCubicMeter(1);
- Density twoKilogramsPerCubicMeter = Density.FromKilogramsPerCubicMeter(2);
-
- Assert.True(oneKilogramPerCubicMeter < twoKilogramsPerCubicMeter);
- Assert.True(oneKilogramPerCubicMeter <= twoKilogramsPerCubicMeter);
- Assert.True(twoKilogramsPerCubicMeter > oneKilogramPerCubicMeter);
- Assert.True(twoKilogramsPerCubicMeter >= oneKilogramPerCubicMeter);
-
- Assert.False(oneKilogramPerCubicMeter > twoKilogramsPerCubicMeter);
- Assert.False(oneKilogramPerCubicMeter >= twoKilogramsPerCubicMeter);
- Assert.False(twoKilogramsPerCubicMeter < oneKilogramPerCubicMeter);
- Assert.False(twoKilogramsPerCubicMeter <= oneKilogramPerCubicMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.Equal(0, kilogrampercubicmeter.CompareTo(kilogrampercubicmeter));
- Assert.True(kilogrampercubicmeter.CompareTo(Density.Zero) > 0);
- Assert.True(Density.Zero.CompareTo(kilogrampercubicmeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.Throws(() => kilogrampercubicmeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.Throws(() => kilogrampercubicmeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Density a = Density.FromKilogramsPerCubicMeter(1);
- Density b = Density.FromKilogramsPerCubicMeter(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()
- {
- Density v = Density.FromKilogramsPerCubicMeter(1);
- Assert.True(v.Equals(Density.FromKilogramsPerCubicMeter(1), Density.FromKilogramsPerCubicMeter(KilogramsPerCubicMeterTolerance)));
- Assert.False(v.Equals(Density.Zero, Density.FromKilogramsPerCubicMeter(KilogramsPerCubicMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.False(kilogrampercubicmeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.False(kilogrampercubicmeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(DensityUnit.Undefined, Density.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
deleted file mode 100644
index 0c107c622b..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
+++ /dev/null
@@ -1,307 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 Duration.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class DurationTestsBase
- {
- protected abstract double DaysInOneSecond { get; }
- protected abstract double HoursInOneSecond { get; }
- protected abstract double MicrosecondsInOneSecond { get; }
- protected abstract double MillisecondsInOneSecond { get; }
- protected abstract double MinutesInOneSecond { get; }
- protected abstract double MonthsInOneSecond { get; }
- protected abstract double Months30InOneSecond { get; }
- protected abstract double NanosecondsInOneSecond { get; }
- protected abstract double SecondsInOneSecond { get; }
- protected abstract double WeeksInOneSecond { get; }
- protected abstract double YearsInOneSecond { get; }
- protected abstract double Years365InOneSecond { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double DaysTolerance { get { return 1e-5; } }
- protected virtual double HoursTolerance { get { return 1e-5; } }
- protected virtual double MicrosecondsTolerance { get { return 1e-5; } }
- protected virtual double MillisecondsTolerance { get { return 1e-5; } }
- protected virtual double MinutesTolerance { get { return 1e-5; } }
- protected virtual double MonthsTolerance { get { return 1e-5; } }
- protected virtual double Months30Tolerance { get { return 1e-5; } }
- protected virtual double NanosecondsTolerance { get { return 1e-5; } }
- protected virtual double SecondsTolerance { get { return 1e-5; } }
- protected virtual double WeeksTolerance { get { return 1e-5; } }
- protected virtual double YearsTolerance { get { return 1e-5; } }
- protected virtual double Years365Tolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void SecondToDurationUnits()
- {
- Duration second = Duration.FromSeconds(1);
- AssertEx.EqualTolerance(DaysInOneSecond, second.Days, DaysTolerance);
- AssertEx.EqualTolerance(HoursInOneSecond, second.Hours, HoursTolerance);
- AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.Microseconds, MicrosecondsTolerance);
- AssertEx.EqualTolerance(MillisecondsInOneSecond, second.Milliseconds, MillisecondsTolerance);
- AssertEx.EqualTolerance(MinutesInOneSecond, second.Minutes, MinutesTolerance);
- AssertEx.EqualTolerance(MonthsInOneSecond, second.Months, MonthsTolerance);
- AssertEx.EqualTolerance(Months30InOneSecond, second.Months30, Months30Tolerance);
- AssertEx.EqualTolerance(NanosecondsInOneSecond, second.Nanoseconds, NanosecondsTolerance);
- AssertEx.EqualTolerance(SecondsInOneSecond, second.Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(WeeksInOneSecond, second.Weeks, WeeksTolerance);
- AssertEx.EqualTolerance(YearsInOneSecond, second.Years, YearsTolerance);
- AssertEx.EqualTolerance(Years365InOneSecond, second.Years365, Years365Tolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Day).Days, DaysTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Hour).Hours, HoursTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Microsecond).Microseconds, MicrosecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Millisecond).Milliseconds, MillisecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Minute).Minutes, MinutesTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Month).Months, MonthsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Month30).Months30, Months30Tolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Nanosecond).Nanoseconds, NanosecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Second).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Week).Weeks, WeeksTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Year).Years, YearsTolerance);
- AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Year365).Years365, Years365Tolerance);
- }
-
- [Fact]
- public void As()
- {
- var second = Duration.FromSeconds(1);
- AssertEx.EqualTolerance(DaysInOneSecond, second.As(DurationUnit.Day), DaysTolerance);
- AssertEx.EqualTolerance(HoursInOneSecond, second.As(DurationUnit.Hour), HoursTolerance);
- AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.As(DurationUnit.Microsecond), MicrosecondsTolerance);
- AssertEx.EqualTolerance(MillisecondsInOneSecond, second.As(DurationUnit.Millisecond), MillisecondsTolerance);
- AssertEx.EqualTolerance(MinutesInOneSecond, second.As(DurationUnit.Minute), MinutesTolerance);
- AssertEx.EqualTolerance(MonthsInOneSecond, second.As(DurationUnit.Month), MonthsTolerance);
- AssertEx.EqualTolerance(Months30InOneSecond, second.As(DurationUnit.Month30), Months30Tolerance);
- AssertEx.EqualTolerance(NanosecondsInOneSecond, second.As(DurationUnit.Nanosecond), NanosecondsTolerance);
- AssertEx.EqualTolerance(SecondsInOneSecond, second.As(DurationUnit.Second), SecondsTolerance);
- AssertEx.EqualTolerance(WeeksInOneSecond, second.As(DurationUnit.Week), WeeksTolerance);
- AssertEx.EqualTolerance(YearsInOneSecond, second.As(DurationUnit.Year), YearsTolerance);
- AssertEx.EqualTolerance(Years365InOneSecond, second.As(DurationUnit.Year365), Years365Tolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var second = Duration.FromSeconds(1);
-
- var dayQuantity = second.ToUnit(DurationUnit.Day);
- AssertEx.EqualTolerance(DaysInOneSecond, (double)dayQuantity.Value, DaysTolerance);
- Assert.Equal(DurationUnit.Day, dayQuantity.Unit);
-
- var hourQuantity = second.ToUnit(DurationUnit.Hour);
- AssertEx.EqualTolerance(HoursInOneSecond, (double)hourQuantity.Value, HoursTolerance);
- Assert.Equal(DurationUnit.Hour, hourQuantity.Unit);
-
- var microsecondQuantity = second.ToUnit(DurationUnit.Microsecond);
- AssertEx.EqualTolerance(MicrosecondsInOneSecond, (double)microsecondQuantity.Value, MicrosecondsTolerance);
- Assert.Equal(DurationUnit.Microsecond, microsecondQuantity.Unit);
-
- var millisecondQuantity = second.ToUnit(DurationUnit.Millisecond);
- AssertEx.EqualTolerance(MillisecondsInOneSecond, (double)millisecondQuantity.Value, MillisecondsTolerance);
- Assert.Equal(DurationUnit.Millisecond, millisecondQuantity.Unit);
-
- var minuteQuantity = second.ToUnit(DurationUnit.Minute);
- AssertEx.EqualTolerance(MinutesInOneSecond, (double)minuteQuantity.Value, MinutesTolerance);
- Assert.Equal(DurationUnit.Minute, minuteQuantity.Unit);
-
- var monthQuantity = second.ToUnit(DurationUnit.Month);
- AssertEx.EqualTolerance(MonthsInOneSecond, (double)monthQuantity.Value, MonthsTolerance);
- Assert.Equal(DurationUnit.Month, monthQuantity.Unit);
-
- var month30Quantity = second.ToUnit(DurationUnit.Month30);
- AssertEx.EqualTolerance(Months30InOneSecond, (double)month30Quantity.Value, Months30Tolerance);
- Assert.Equal(DurationUnit.Month30, month30Quantity.Unit);
-
- var nanosecondQuantity = second.ToUnit(DurationUnit.Nanosecond);
- AssertEx.EqualTolerance(NanosecondsInOneSecond, (double)nanosecondQuantity.Value, NanosecondsTolerance);
- Assert.Equal(DurationUnit.Nanosecond, nanosecondQuantity.Unit);
-
- var secondQuantity = second.ToUnit(DurationUnit.Second);
- AssertEx.EqualTolerance(SecondsInOneSecond, (double)secondQuantity.Value, SecondsTolerance);
- Assert.Equal(DurationUnit.Second, secondQuantity.Unit);
-
- var weekQuantity = second.ToUnit(DurationUnit.Week);
- AssertEx.EqualTolerance(WeeksInOneSecond, (double)weekQuantity.Value, WeeksTolerance);
- Assert.Equal(DurationUnit.Week, weekQuantity.Unit);
-
- var yearQuantity = second.ToUnit(DurationUnit.Year);
- AssertEx.EqualTolerance(YearsInOneSecond, (double)yearQuantity.Value, YearsTolerance);
- Assert.Equal(DurationUnit.Year, yearQuantity.Unit);
-
- var year365Quantity = second.ToUnit(DurationUnit.Year365);
- AssertEx.EqualTolerance(Years365InOneSecond, (double)year365Quantity.Value, Years365Tolerance);
- Assert.Equal(DurationUnit.Year365, year365Quantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Duration second = Duration.FromSeconds(1);
- AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance);
- AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance);
- AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance);
- AssertEx.EqualTolerance(1, Duration.FromMonths(second.Months).Seconds, MonthsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance);
- AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance);
- AssertEx.EqualTolerance(1, Duration.FromYears(second.Years).Seconds, YearsTolerance);
- AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Duration v = Duration.FromSeconds(1);
- AssertEx.EqualTolerance(-1, -v.Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(2, (Duration.FromSeconds(3)-v).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(2, (v + v).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(10, (v*10).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(10, (10*v).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(2, (Duration.FromSeconds(10)/5).Seconds, SecondsTolerance);
- AssertEx.EqualTolerance(2, Duration.FromSeconds(10)/Duration.FromSeconds(5), SecondsTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Duration oneSecond = Duration.FromSeconds(1);
- Duration twoSeconds = Duration.FromSeconds(2);
-
- Assert.True(oneSecond < twoSeconds);
- Assert.True(oneSecond <= twoSeconds);
- Assert.True(twoSeconds > oneSecond);
- Assert.True(twoSeconds >= oneSecond);
-
- Assert.False(oneSecond > twoSeconds);
- Assert.False(oneSecond >= twoSeconds);
- Assert.False(twoSeconds < oneSecond);
- Assert.False(twoSeconds <= oneSecond);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- Duration second = Duration.FromSeconds(1);
- Assert.Equal(0, second.CompareTo(second));
- Assert.True(second.CompareTo(Duration.Zero) > 0);
- Assert.True(Duration.Zero.CompareTo(second) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Duration second = Duration.FromSeconds(1);
- Assert.Throws(() => second.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Duration second = Duration.FromSeconds(1);
- Assert.Throws(() => second.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- Duration a = Duration.FromSeconds(1);
- Duration b = Duration.FromSeconds(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()
- {
- Duration v = Duration.FromSeconds(1);
- Assert.True(v.Equals(Duration.FromSeconds(1), Duration.FromSeconds(SecondsTolerance)));
- Assert.False(v.Equals(Duration.Zero, Duration.FromSeconds(SecondsTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Duration second = Duration.FromSeconds(1);
- Assert.False(second.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Duration second = Duration.FromSeconds(1);
- Assert.False(second.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
deleted file mode 100644
index fe80050f24..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 DynamicViscosity.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class DynamicViscosityTestsBase
- {
- protected abstract double CentipoiseInOneNewtonSecondPerMeterSquared { get; }
- protected abstract double MicropascalSecondsInOneNewtonSecondPerMeterSquared { get; }
- protected abstract double MillipascalSecondsInOneNewtonSecondPerMeterSquared { get; }
- protected abstract double NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared { get; }
- protected abstract double PascalSecondsInOneNewtonSecondPerMeterSquared { get; }
- protected abstract double PoiseInOneNewtonSecondPerMeterSquared { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentipoiseTolerance { get { return 1e-5; } }
- protected virtual double MicropascalSecondsTolerance { get { return 1e-5; } }
- protected virtual double MillipascalSecondsTolerance { get { return 1e-5; } }
- protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1e-5; } }
- protected virtual double PascalSecondsTolerance { get { return 1e-5; } }
- protected virtual double PoiseTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Centipoise, CentipoiseTolerance);
- AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MicropascalSeconds, MicropascalSecondsTolerance);
- AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MillipascalSeconds, MillipascalSecondsTolerance);
- AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.PascalSeconds, PascalSecondsTolerance);
- AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Poise, PoiseTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Centipoise).Centipoise, CentipoiseTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MicropascalSecond).MicropascalSeconds, MicropascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MillipascalSecond).MillipascalSeconds, MillipascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.PascalSecond).PascalSeconds, PascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Poise).Poise, PoiseTolerance);
- }
-
- [Fact]
- public void As()
- {
- var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Centipoise), CentipoiseTolerance);
- AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MicropascalSecond), MicropascalSecondsTolerance);
- AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MillipascalSecond), MillipascalSecondsTolerance);
- AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.NewtonSecondPerMeterSquared), NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.PascalSecond), PascalSecondsTolerance);
- AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Poise), PoiseTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
-
- var centipoiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Centipoise);
- AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, (double)centipoiseQuantity.Value, CentipoiseTolerance);
- Assert.Equal(DynamicViscosityUnit.Centipoise, centipoiseQuantity.Unit);
-
- var micropascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MicropascalSecond);
- AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, (double)micropascalsecondQuantity.Value, MicropascalSecondsTolerance);
- Assert.Equal(DynamicViscosityUnit.MicropascalSecond, micropascalsecondQuantity.Unit);
-
- var millipascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MillipascalSecond);
- AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, (double)millipascalsecondQuantity.Value, MillipascalSecondsTolerance);
- Assert.Equal(DynamicViscosityUnit.MillipascalSecond, millipascalsecondQuantity.Unit);
-
- var newtonsecondpermetersquaredQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.NewtonSecondPerMeterSquared);
- AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, (double)newtonsecondpermetersquaredQuantity.Value, NewtonSecondsPerMeterSquaredTolerance);
- Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, newtonsecondpermetersquaredQuantity.Unit);
-
- var pascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.PascalSecond);
- AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, (double)pascalsecondQuantity.Value, PascalSecondsTolerance);
- Assert.Equal(DynamicViscosityUnit.PascalSecond, pascalsecondQuantity.Unit);
-
- var poiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Poise);
- AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, (double)poiseQuantity.Value, PoiseTolerance);
- Assert.Equal(DynamicViscosityUnit.Poise, poiseQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromCentipoise(newtonsecondpermetersquared.Centipoise).NewtonSecondsPerMeterSquared, CentipoiseTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromMicropascalSeconds(newtonsecondpermetersquared.MicropascalSeconds).NewtonSecondsPerMeterSquared, MicropascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromMillipascalSeconds(newtonsecondpermetersquared.MillipascalSeconds).NewtonSecondsPerMeterSquared, MillipascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromNewtonSecondsPerMeterSquared(newtonsecondpermetersquared.NewtonSecondsPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromPascalSeconds(newtonsecondpermetersquared.PascalSeconds).NewtonSecondsPerMeterSquared, PascalSecondsTolerance);
- AssertEx.EqualTolerance(1, DynamicViscosity.FromPoise(newtonsecondpermetersquared.Poise).NewtonSecondsPerMeterSquared, PoiseTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- DynamicViscosity v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- AssertEx.EqualTolerance(-1, -v.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(3)-v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(2, (v + v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(10, (v*10).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(10, (10*v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/5).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance);
- AssertEx.EqualTolerance(2, DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/DynamicViscosity.FromNewtonSecondsPerMeterSquared(5), NewtonSecondsPerMeterSquaredTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- DynamicViscosity oneNewtonSecondPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- DynamicViscosity twoNewtonSecondsPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2);
-
- Assert.True(oneNewtonSecondPerMeterSquared < twoNewtonSecondsPerMeterSquared);
- Assert.True(oneNewtonSecondPerMeterSquared <= twoNewtonSecondsPerMeterSquared);
- Assert.True(twoNewtonSecondsPerMeterSquared > oneNewtonSecondPerMeterSquared);
- Assert.True(twoNewtonSecondsPerMeterSquared >= oneNewtonSecondPerMeterSquared);
-
- Assert.False(oneNewtonSecondPerMeterSquared > twoNewtonSecondsPerMeterSquared);
- Assert.False(oneNewtonSecondPerMeterSquared >= twoNewtonSecondsPerMeterSquared);
- Assert.False(twoNewtonSecondsPerMeterSquared < oneNewtonSecondPerMeterSquared);
- Assert.False(twoNewtonSecondsPerMeterSquared <= oneNewtonSecondPerMeterSquared);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.Equal(0, newtonsecondpermetersquared.CompareTo(newtonsecondpermetersquared));
- Assert.True(newtonsecondpermetersquared.CompareTo(DynamicViscosity.Zero) > 0);
- Assert.True(DynamicViscosity.Zero.CompareTo(newtonsecondpermetersquared) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.Throws(() => newtonsecondpermetersquared.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.Throws(() => newtonsecondpermetersquared.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- DynamicViscosity a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- DynamicViscosity b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(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()
- {
- DynamicViscosity v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.True(v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), DynamicViscosity.FromNewtonSecondsPerMeterSquared(NewtonSecondsPerMeterSquaredTolerance)));
- Assert.False(v.Equals(DynamicViscosity.Zero, DynamicViscosity.FromNewtonSecondsPerMeterSquared(NewtonSecondsPerMeterSquaredTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.False(newtonsecondpermetersquared.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
- Assert.False(newtonsecondpermetersquared.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
deleted file mode 100644
index 58097b5e01..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricAdmittance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricAdmittanceTestsBase
- {
- protected abstract double MicrosiemensInOneSiemens { get; }
- protected abstract double MillisiemensInOneSiemens { get; }
- protected abstract double NanosiemensInOneSiemens { get; }
- protected abstract double SiemensInOneSiemens { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double MicrosiemensTolerance { get { return 1e-5; } }
- protected virtual double MillisiemensTolerance { get { return 1e-5; } }
- protected virtual double NanosiemensTolerance { get { return 1e-5; } }
- protected virtual double SiemensTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void SiemensToElectricAdmittanceUnits()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.Nanosiemens, NanosiemensTolerance);
- AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Microsiemens).Microsiemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Millisiemens).Millisiemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Nanosiemens).Nanosiemens, NanosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Siemens).Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void As()
- {
- var siemens = ElectricAdmittance.FromSiemens(1);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Microsiemens), MicrosiemensTolerance);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Millisiemens), MillisiemensTolerance);
- AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Nanosiemens), NanosiemensTolerance);
- AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Siemens), SiemensTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var siemens = ElectricAdmittance.FromSiemens(1);
-
- var microsiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Microsiemens);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance);
- Assert.Equal(ElectricAdmittanceUnit.Microsiemens, microsiemensQuantity.Unit);
-
- var millisiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Millisiemens);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance);
- Assert.Equal(ElectricAdmittanceUnit.Millisiemens, millisiemensQuantity.Unit);
-
- var nanosiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Nanosiemens);
- AssertEx.EqualTolerance(NanosiemensInOneSiemens, (double)nanosiemensQuantity.Value, NanosiemensTolerance);
- Assert.Equal(ElectricAdmittanceUnit.Nanosiemens, nanosiemensQuantity.Unit);
-
- var siemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Siemens);
- AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance);
- Assert.Equal(ElectricAdmittanceUnit.Siemens, siemensQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- AssertEx.EqualTolerance(1, ElectricAdmittance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.FromNanosiemens(siemens.Nanosiemens).Siemens, NanosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricAdmittance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricAdmittance v = ElectricAdmittance.FromSiemens(1);
- AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(3)-v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(10)/5).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, ElectricAdmittance.FromSiemens(10)/ElectricAdmittance.FromSiemens(5), SiemensTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricAdmittance oneSiemens = ElectricAdmittance.FromSiemens(1);
- ElectricAdmittance twoSiemens = ElectricAdmittance.FromSiemens(2);
-
- Assert.True(oneSiemens < twoSiemens);
- Assert.True(oneSiemens <= twoSiemens);
- Assert.True(twoSiemens > oneSiemens);
- Assert.True(twoSiemens >= oneSiemens);
-
- Assert.False(oneSiemens > twoSiemens);
- Assert.False(oneSiemens >= twoSiemens);
- Assert.False(twoSiemens < oneSiemens);
- Assert.False(twoSiemens <= oneSiemens);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- Assert.Equal(0, siemens.CompareTo(siemens));
- Assert.True(siemens.CompareTo(ElectricAdmittance.Zero) > 0);
- Assert.True(ElectricAdmittance.Zero.CompareTo(siemens) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- Assert.Throws(() => siemens.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- Assert.Throws(() => siemens.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricAdmittance a = ElectricAdmittance.FromSiemens(1);
- ElectricAdmittance b = ElectricAdmittance.FromSiemens(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()
- {
- ElectricAdmittance v = ElectricAdmittance.FromSiemens(1);
- Assert.True(v.Equals(ElectricAdmittance.FromSiemens(1), ElectricAdmittance.FromSiemens(SiemensTolerance)));
- Assert.False(v.Equals(ElectricAdmittance.Zero, ElectricAdmittance.FromSiemens(SiemensTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- Assert.False(siemens.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1);
- Assert.False(siemens.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
deleted file mode 100644
index 21589616fb..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricChargeDensity.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricChargeDensityTestsBase
- {
- protected abstract double CoulombsPerCubicMeterInOneCoulombPerCubicMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CoulombsPerCubicMeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void CoulombPerCubicMeterToElectricChargeDensityUnits()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricChargeDensity.From(1, ElectricChargeDensityUnit.CoulombPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.As(ElectricChargeDensityUnit.CoulombPerCubicMeter), CoulombsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
-
- var coulombpercubicmeterQuantity = coulombpercubicmeter.ToUnit(ElectricChargeDensityUnit.CoulombPerCubicMeter);
- AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, (double)coulombpercubicmeterQuantity.Value, CoulombsPerCubicMeterTolerance);
- Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, coulombpercubicmeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- AssertEx.EqualTolerance(1, ElectricChargeDensity.FromCoulombsPerCubicMeter(coulombpercubicmeter.CoulombsPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricChargeDensity v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- AssertEx.EqualTolerance(-1, -v.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(3)-v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/5).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(2, ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/ElectricChargeDensity.FromCoulombsPerCubicMeter(5), CoulombsPerCubicMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricChargeDensity oneCoulombPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- ElectricChargeDensity twoCoulombsPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(2);
-
- Assert.True(oneCoulombPerCubicMeter < twoCoulombsPerCubicMeter);
- Assert.True(oneCoulombPerCubicMeter <= twoCoulombsPerCubicMeter);
- Assert.True(twoCoulombsPerCubicMeter > oneCoulombPerCubicMeter);
- Assert.True(twoCoulombsPerCubicMeter >= oneCoulombPerCubicMeter);
-
- Assert.False(oneCoulombPerCubicMeter > twoCoulombsPerCubicMeter);
- Assert.False(oneCoulombPerCubicMeter >= twoCoulombsPerCubicMeter);
- Assert.False(twoCoulombsPerCubicMeter < oneCoulombPerCubicMeter);
- Assert.False(twoCoulombsPerCubicMeter <= oneCoulombPerCubicMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.Equal(0, coulombpercubicmeter.CompareTo(coulombpercubicmeter));
- Assert.True(coulombpercubicmeter.CompareTo(ElectricChargeDensity.Zero) > 0);
- Assert.True(ElectricChargeDensity.Zero.CompareTo(coulombpercubicmeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.Throws(() => coulombpercubicmeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.Throws(() => coulombpercubicmeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricChargeDensity a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- ElectricChargeDensity b = ElectricChargeDensity.FromCoulombsPerCubicMeter(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()
- {
- ElectricChargeDensity v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.True(v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), ElectricChargeDensity.FromCoulombsPerCubicMeter(CoulombsPerCubicMeterTolerance)));
- Assert.False(v.Equals(ElectricChargeDensity.Zero, ElectricChargeDensity.FromCoulombsPerCubicMeter(CoulombsPerCubicMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.False(coulombpercubicmeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
- Assert.False(coulombpercubicmeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
deleted file mode 100644
index e867eb01ab..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricCharge.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricChargeTestsBase
- {
- protected abstract double CoulombsInOneCoulomb { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CoulombsTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void CoulombToElectricChargeUnits()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.Coulombs, CoulombsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.Coulomb).Coulombs, CoulombsTolerance);
- }
-
- [Fact]
- public void As()
- {
- var coulomb = ElectricCharge.FromCoulombs(1);
- AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var coulomb = ElectricCharge.FromCoulombs(1);
-
- var coulombQuantity = coulomb.ToUnit(ElectricChargeUnit.Coulomb);
- AssertEx.EqualTolerance(CoulombsInOneCoulomb, (double)coulombQuantity.Value, CoulombsTolerance);
- Assert.Equal(ElectricChargeUnit.Coulomb, coulombQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricCharge v = ElectricCharge.FromCoulombs(1);
- AssertEx.EqualTolerance(-1, -v.Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(3)-v).Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(2, (v + v).Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(10, (v*10).Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(10, (10*v).Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(10)/5).Coulombs, CoulombsTolerance);
- AssertEx.EqualTolerance(2, ElectricCharge.FromCoulombs(10)/ElectricCharge.FromCoulombs(5), CoulombsTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricCharge oneCoulomb = ElectricCharge.FromCoulombs(1);
- ElectricCharge twoCoulombs = ElectricCharge.FromCoulombs(2);
-
- Assert.True(oneCoulomb < twoCoulombs);
- Assert.True(oneCoulomb <= twoCoulombs);
- Assert.True(twoCoulombs > oneCoulomb);
- Assert.True(twoCoulombs >= oneCoulomb);
-
- Assert.False(oneCoulomb > twoCoulombs);
- Assert.False(oneCoulomb >= twoCoulombs);
- Assert.False(twoCoulombs < oneCoulomb);
- Assert.False(twoCoulombs <= oneCoulomb);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- Assert.Equal(0, coulomb.CompareTo(coulomb));
- Assert.True(coulomb.CompareTo(ElectricCharge.Zero) > 0);
- Assert.True(ElectricCharge.Zero.CompareTo(coulomb) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- Assert.Throws(() => coulomb.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- Assert.Throws(() => coulomb.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricCharge a = ElectricCharge.FromCoulombs(1);
- ElectricCharge b = ElectricCharge.FromCoulombs(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()
- {
- ElectricCharge v = ElectricCharge.FromCoulombs(1);
- Assert.True(v.Equals(ElectricCharge.FromCoulombs(1), ElectricCharge.FromCoulombs(CoulombsTolerance)));
- Assert.False(v.Equals(ElectricCharge.Zero, ElectricCharge.FromCoulombs(CoulombsTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- Assert.False(coulomb.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- Assert.False(coulomb.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
deleted file mode 100644
index e6e565c53f..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricConductance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricConductanceTestsBase
- {
- protected abstract double MicrosiemensInOneSiemens { get; }
- protected abstract double MillisiemensInOneSiemens { get; }
- protected abstract double SiemensInOneSiemens { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double MicrosiemensTolerance { get { return 1e-5; } }
- protected virtual double MillisiemensTolerance { get { return 1e-5; } }
- protected virtual double SiemensTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void SiemensToElectricConductanceUnits()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Microsiemens).Microsiemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Millisiemens).Millisiemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Siemens).Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void As()
- {
- var siemens = ElectricConductance.FromSiemens(1);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Microsiemens), MicrosiemensTolerance);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Millisiemens), MillisiemensTolerance);
- AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Siemens), SiemensTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var siemens = ElectricConductance.FromSiemens(1);
-
- var microsiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Microsiemens);
- AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance);
- Assert.Equal(ElectricConductanceUnit.Microsiemens, microsiemensQuantity.Unit);
-
- var millisiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Millisiemens);
- AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance);
- Assert.Equal(ElectricConductanceUnit.Millisiemens, millisiemensQuantity.Unit);
-
- var siemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Siemens);
- AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance);
- Assert.Equal(ElectricConductanceUnit.Siemens, siemensQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- AssertEx.EqualTolerance(1, ElectricConductance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricConductance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance);
- AssertEx.EqualTolerance(1, ElectricConductance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricConductance v = ElectricConductance.FromSiemens(1);
- AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(3)-v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(10)/5).Siemens, SiemensTolerance);
- AssertEx.EqualTolerance(2, ElectricConductance.FromSiemens(10)/ElectricConductance.FromSiemens(5), SiemensTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricConductance oneSiemens = ElectricConductance.FromSiemens(1);
- ElectricConductance twoSiemens = ElectricConductance.FromSiemens(2);
-
- Assert.True(oneSiemens < twoSiemens);
- Assert.True(oneSiemens <= twoSiemens);
- Assert.True(twoSiemens > oneSiemens);
- Assert.True(twoSiemens >= oneSiemens);
-
- Assert.False(oneSiemens > twoSiemens);
- Assert.False(oneSiemens >= twoSiemens);
- Assert.False(twoSiemens < oneSiemens);
- Assert.False(twoSiemens <= oneSiemens);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- Assert.Equal(0, siemens.CompareTo(siemens));
- Assert.True(siemens.CompareTo(ElectricConductance.Zero) > 0);
- Assert.True(ElectricConductance.Zero.CompareTo(siemens) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- Assert.Throws(() => siemens.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- Assert.Throws(() => siemens.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricConductance a = ElectricConductance.FromSiemens(1);
- ElectricConductance b = ElectricConductance.FromSiemens(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()
- {
- ElectricConductance v = ElectricConductance.FromSiemens(1);
- Assert.True(v.Equals(ElectricConductance.FromSiemens(1), ElectricConductance.FromSiemens(SiemensTolerance)));
- Assert.False(v.Equals(ElectricConductance.Zero, ElectricConductance.FromSiemens(SiemensTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- Assert.False(siemens.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricConductance siemens = ElectricConductance.FromSiemens(1);
- Assert.False(siemens.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
deleted file mode 100644
index afa9552ae4..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricConductivity.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricConductivityTestsBase
- {
- protected abstract double SiemensPerMeterInOneSiemensPerMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double SiemensPerMeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void SiemensPerMeterToElectricConductivityUnits()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.SiemensPerMeter, SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerMeter), SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
-
- var siemenspermeterQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerMeter);
- AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, (double)siemenspermeterQuantity.Value, SiemensPerMeterTolerance);
- Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, siemenspermeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerMeter(siemenspermeter.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricConductivity v = ElectricConductivity.FromSiemensPerMeter(1);
- AssertEx.EqualTolerance(-1, -v.SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(3)-v).SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(10)/5).SiemensPerMeter, SiemensPerMeterTolerance);
- AssertEx.EqualTolerance(2, ElectricConductivity.FromSiemensPerMeter(10)/ElectricConductivity.FromSiemensPerMeter(5), SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricConductivity oneSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(1);
- ElectricConductivity twoSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(2);
-
- Assert.True(oneSiemensPerMeter < twoSiemensPerMeter);
- Assert.True(oneSiemensPerMeter <= twoSiemensPerMeter);
- Assert.True(twoSiemensPerMeter > oneSiemensPerMeter);
- Assert.True(twoSiemensPerMeter >= oneSiemensPerMeter);
-
- Assert.False(oneSiemensPerMeter > twoSiemensPerMeter);
- Assert.False(oneSiemensPerMeter >= twoSiemensPerMeter);
- Assert.False(twoSiemensPerMeter < oneSiemensPerMeter);
- Assert.False(twoSiemensPerMeter <= oneSiemensPerMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.Equal(0, siemenspermeter.CompareTo(siemenspermeter));
- Assert.True(siemenspermeter.CompareTo(ElectricConductivity.Zero) > 0);
- Assert.True(ElectricConductivity.Zero.CompareTo(siemenspermeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.Throws(() => siemenspermeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.Throws(() => siemenspermeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricConductivity a = ElectricConductivity.FromSiemensPerMeter(1);
- ElectricConductivity b = ElectricConductivity.FromSiemensPerMeter(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()
- {
- ElectricConductivity v = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.True(v.Equals(ElectricConductivity.FromSiemensPerMeter(1), ElectricConductivity.FromSiemensPerMeter(SiemensPerMeterTolerance)));
- Assert.False(v.Equals(ElectricConductivity.Zero, ElectricConductivity.FromSiemensPerMeter(SiemensPerMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.False(siemenspermeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
- Assert.False(siemenspermeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
deleted file mode 100644
index 4f28d50282..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricCurrentDensity.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricCurrentDensityTestsBase
- {
- protected abstract double AmperesPerSquareMeterInOneAmperePerSquareMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double AmperesPerSquareMeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void AmperePerSquareMeterToElectricCurrentDensityUnits()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
-
- var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter);
- AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (double)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance);
- Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- AssertEx.EqualTolerance(-1, -v.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3)-v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricCurrentDensity oneAmperePerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2);
-
- Assert.True(oneAmperePerSquareMeter < twoAmperesPerSquareMeter);
- Assert.True(oneAmperePerSquareMeter <= twoAmperesPerSquareMeter);
- Assert.True(twoAmperesPerSquareMeter > oneAmperePerSquareMeter);
- Assert.True(twoAmperesPerSquareMeter >= oneAmperePerSquareMeter);
-
- Assert.False(oneAmperePerSquareMeter > twoAmperesPerSquareMeter);
- Assert.False(oneAmperePerSquareMeter >= twoAmperesPerSquareMeter);
- Assert.False(twoAmperesPerSquareMeter < oneAmperePerSquareMeter);
- Assert.False(twoAmperesPerSquareMeter <= oneAmperePerSquareMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.Equal(0, amperepersquaremeter.CompareTo(amperepersquaremeter));
- Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0);
- Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.Throws(() => amperepersquaremeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.Throws(() => amperepersquaremeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricCurrentDensity a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- ElectricCurrentDensity b = ElectricCurrentDensity.FromAmperesPerSquareMeter(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()
- {
- ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance)));
- Assert.False(v.Equals(ElectricCurrentDensity.Zero, ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.False(amperepersquaremeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
- Assert.False(amperepersquaremeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
deleted file mode 100644
index 066f847fa9..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricCurrentGradient.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricCurrentGradientTestsBase
- {
- protected abstract double AmperesPerSecondInOneAmperePerSecond { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double AmperesPerSecondTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void AmperePerSecondToElectricCurrentGradientUnits()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.AmperesPerSecond, AmperesPerSecondTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerSecond).AmperesPerSecond, AmperesPerSecondTolerance);
- }
-
- [Fact]
- public void As()
- {
- var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerSecond), AmperesPerSecondTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
-
- var amperepersecondQuantity = amperepersecond.ToUnit(ElectricCurrentGradientUnit.AmperePerSecond);
- AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, (double)amperepersecondQuantity.Value, AmperesPerSecondTolerance);
- Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, amperepersecondQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerSecond(amperepersecond.AmperesPerSecond).AmperesPerSecond, AmperesPerSecondTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1);
- AssertEx.EqualTolerance(-1, -v.AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(3)-v).AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(2, (v + v).AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(10, (v*10).AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(10, (10*v).AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(10)/5).AmperesPerSecond, AmperesPerSecondTolerance);
- AssertEx.EqualTolerance(2, ElectricCurrentGradient.FromAmperesPerSecond(10)/ElectricCurrentGradient.FromAmperesPerSecond(5), AmperesPerSecondTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricCurrentGradient oneAmperePerSecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- ElectricCurrentGradient twoAmperesPerSecond = ElectricCurrentGradient.FromAmperesPerSecond(2);
-
- Assert.True(oneAmperePerSecond < twoAmperesPerSecond);
- Assert.True(oneAmperePerSecond <= twoAmperesPerSecond);
- Assert.True(twoAmperesPerSecond > oneAmperePerSecond);
- Assert.True(twoAmperesPerSecond >= oneAmperePerSecond);
-
- Assert.False(oneAmperePerSecond > twoAmperesPerSecond);
- Assert.False(oneAmperePerSecond >= twoAmperesPerSecond);
- Assert.False(twoAmperesPerSecond < oneAmperePerSecond);
- Assert.False(twoAmperesPerSecond <= oneAmperePerSecond);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.Equal(0, amperepersecond.CompareTo(amperepersecond));
- Assert.True(amperepersecond.CompareTo(ElectricCurrentGradient.Zero) > 0);
- Assert.True(ElectricCurrentGradient.Zero.CompareTo(amperepersecond) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.Throws(() => amperepersecond.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.Throws(() => amperepersecond.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricCurrentGradient a = ElectricCurrentGradient.FromAmperesPerSecond(1);
- ElectricCurrentGradient b = ElectricCurrentGradient.FromAmperesPerSecond(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()
- {
- ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), ElectricCurrentGradient.FromAmperesPerSecond(AmperesPerSecondTolerance)));
- Assert.False(v.Equals(ElectricCurrentGradient.Zero, ElectricCurrentGradient.FromAmperesPerSecond(AmperesPerSecondTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.False(amperepersecond.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
- Assert.False(amperepersecond.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
deleted file mode 100644
index 44e66c1490..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricCurrent.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricCurrentTestsBase
- {
- protected abstract double AmperesInOneAmpere { get; }
- protected abstract double CentiamperesInOneAmpere { get; }
- protected abstract double KiloamperesInOneAmpere { get; }
- protected abstract double MegaamperesInOneAmpere { get; }
- protected abstract double MicroamperesInOneAmpere { get; }
- protected abstract double MilliamperesInOneAmpere { get; }
- protected abstract double NanoamperesInOneAmpere { get; }
- protected abstract double PicoamperesInOneAmpere { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double AmperesTolerance { get { return 1e-5; } }
- protected virtual double CentiamperesTolerance { get { return 1e-5; } }
- protected virtual double KiloamperesTolerance { get { return 1e-5; } }
- protected virtual double MegaamperesTolerance { get { return 1e-5; } }
- protected virtual double MicroamperesTolerance { get { return 1e-5; } }
- protected virtual double MilliamperesTolerance { get { return 1e-5; } }
- protected virtual double NanoamperesTolerance { get { return 1e-5; } }
- protected virtual double PicoamperesTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void AmpereToElectricCurrentUnits()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.Centiamperes, CentiamperesTolerance);
- AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.Kiloamperes, KiloamperesTolerance);
- AssertEx.EqualTolerance(MegaamperesInOneAmpere, ampere.Megaamperes, MegaamperesTolerance);
- AssertEx.EqualTolerance(MicroamperesInOneAmpere, ampere.Microamperes, MicroamperesTolerance);
- AssertEx.EqualTolerance(MilliamperesInOneAmpere, ampere.Milliamperes, MilliamperesTolerance);
- AssertEx.EqualTolerance(NanoamperesInOneAmpere, ampere.Nanoamperes, NanoamperesTolerance);
- AssertEx.EqualTolerance(PicoamperesInOneAmpere, ampere.Picoamperes, PicoamperesTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Ampere).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Centiampere).Centiamperes, CentiamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Kiloampere).Kiloamperes, KiloamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Megaampere).Megaamperes, MegaamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Microampere).Microamperes, MicroamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Milliampere).Milliamperes, MilliamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Nanoampere).Nanoamperes, NanoamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Picoampere).Picoamperes, PicoamperesTolerance);
- }
-
- [Fact]
- public void As()
- {
- var ampere = ElectricCurrent.FromAmperes(1);
- AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.As(ElectricCurrentUnit.Ampere), AmperesTolerance);
- AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Centiampere), CentiamperesTolerance);
- AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Kiloampere), KiloamperesTolerance);
- AssertEx.EqualTolerance(MegaamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Megaampere), MegaamperesTolerance);
- AssertEx.EqualTolerance(MicroamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Microampere), MicroamperesTolerance);
- AssertEx.EqualTolerance(MilliamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Milliampere), MilliamperesTolerance);
- AssertEx.EqualTolerance(NanoamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Nanoampere), NanoamperesTolerance);
- AssertEx.EqualTolerance(PicoamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Picoampere), PicoamperesTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var ampere = ElectricCurrent.FromAmperes(1);
-
- var ampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Ampere);
- AssertEx.EqualTolerance(AmperesInOneAmpere, (double)ampereQuantity.Value, AmperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Ampere, ampereQuantity.Unit);
-
- var centiampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Centiampere);
- AssertEx.EqualTolerance(CentiamperesInOneAmpere, (double)centiampereQuantity.Value, CentiamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Centiampere, centiampereQuantity.Unit);
-
- var kiloampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Kiloampere);
- AssertEx.EqualTolerance(KiloamperesInOneAmpere, (double)kiloampereQuantity.Value, KiloamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Kiloampere, kiloampereQuantity.Unit);
-
- var megaampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Megaampere);
- AssertEx.EqualTolerance(MegaamperesInOneAmpere, (double)megaampereQuantity.Value, MegaamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Megaampere, megaampereQuantity.Unit);
-
- var microampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Microampere);
- AssertEx.EqualTolerance(MicroamperesInOneAmpere, (double)microampereQuantity.Value, MicroamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Microampere, microampereQuantity.Unit);
-
- var milliampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Milliampere);
- AssertEx.EqualTolerance(MilliamperesInOneAmpere, (double)milliampereQuantity.Value, MilliamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Milliampere, milliampereQuantity.Unit);
-
- var nanoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Nanoampere);
- AssertEx.EqualTolerance(NanoamperesInOneAmpere, (double)nanoampereQuantity.Value, NanoamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Nanoampere, nanoampereQuantity.Unit);
-
- var picoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Picoampere);
- AssertEx.EqualTolerance(PicoamperesInOneAmpere, (double)picoampereQuantity.Value, PicoamperesTolerance);
- Assert.Equal(ElectricCurrentUnit.Picoampere, picoampereQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromCentiamperes(ampere.Centiamperes).Amperes, CentiamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance);
- AssertEx.EqualTolerance(1, ElectricCurrent.FromPicoamperes(ampere.Picoamperes).Amperes, PicoamperesTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricCurrent v = ElectricCurrent.FromAmperes(1);
- AssertEx.EqualTolerance(-1, -v.Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(3)-v).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(2, (v + v).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(10, (v*10).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(10, (10*v).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(10)/5).Amperes, AmperesTolerance);
- AssertEx.EqualTolerance(2, ElectricCurrent.FromAmperes(10)/ElectricCurrent.FromAmperes(5), AmperesTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricCurrent oneAmpere = ElectricCurrent.FromAmperes(1);
- ElectricCurrent twoAmperes = ElectricCurrent.FromAmperes(2);
-
- Assert.True(oneAmpere < twoAmperes);
- Assert.True(oneAmpere <= twoAmperes);
- Assert.True(twoAmperes > oneAmpere);
- Assert.True(twoAmperes >= oneAmpere);
-
- Assert.False(oneAmpere > twoAmperes);
- Assert.False(oneAmpere >= twoAmperes);
- Assert.False(twoAmperes < oneAmpere);
- Assert.False(twoAmperes <= oneAmpere);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- Assert.Equal(0, ampere.CompareTo(ampere));
- Assert.True(ampere.CompareTo(ElectricCurrent.Zero) > 0);
- Assert.True(ElectricCurrent.Zero.CompareTo(ampere) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- Assert.Throws(() => ampere.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- Assert.Throws(() => ampere.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricCurrent a = ElectricCurrent.FromAmperes(1);
- ElectricCurrent b = ElectricCurrent.FromAmperes(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()
- {
- ElectricCurrent v = ElectricCurrent.FromAmperes(1);
- Assert.True(v.Equals(ElectricCurrent.FromAmperes(1), ElectricCurrent.FromAmperes(AmperesTolerance)));
- Assert.False(v.Equals(ElectricCurrent.Zero, ElectricCurrent.FromAmperes(AmperesTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- Assert.False(ampere.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);
- Assert.False(ampere.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
deleted file mode 100644
index 559f971e51..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricField.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricFieldTestsBase
- {
- protected abstract double VoltsPerMeterInOneVoltPerMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double VoltsPerMeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void VoltPerMeterToElectricFieldUnits()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.VoltsPerMeter, VoltsPerMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricField.From(1, ElectricFieldUnit.VoltPerMeter).VoltsPerMeter, VoltsPerMeterTolerance);
- }
-
- [Fact]
- public void As()
- {
- var voltpermeter = ElectricField.FromVoltsPerMeter(1);
- AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.As(ElectricFieldUnit.VoltPerMeter), VoltsPerMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var voltpermeter = ElectricField.FromVoltsPerMeter(1);
-
- var voltpermeterQuantity = voltpermeter.ToUnit(ElectricFieldUnit.VoltPerMeter);
- AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, (double)voltpermeterQuantity.Value, VoltsPerMeterTolerance);
- Assert.Equal(ElectricFieldUnit.VoltPerMeter, voltpermeterQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- AssertEx.EqualTolerance(1, ElectricField.FromVoltsPerMeter(voltpermeter.VoltsPerMeter).VoltsPerMeter, VoltsPerMeterTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricField v = ElectricField.FromVoltsPerMeter(1);
- AssertEx.EqualTolerance(-1, -v.VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(3)-v).VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(2, (v + v).VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(10, (v*10).VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(10, (10*v).VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(10)/5).VoltsPerMeter, VoltsPerMeterTolerance);
- AssertEx.EqualTolerance(2, ElectricField.FromVoltsPerMeter(10)/ElectricField.FromVoltsPerMeter(5), VoltsPerMeterTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricField oneVoltPerMeter = ElectricField.FromVoltsPerMeter(1);
- ElectricField twoVoltsPerMeter = ElectricField.FromVoltsPerMeter(2);
-
- Assert.True(oneVoltPerMeter < twoVoltsPerMeter);
- Assert.True(oneVoltPerMeter <= twoVoltsPerMeter);
- Assert.True(twoVoltsPerMeter > oneVoltPerMeter);
- Assert.True(twoVoltsPerMeter >= oneVoltPerMeter);
-
- Assert.False(oneVoltPerMeter > twoVoltsPerMeter);
- Assert.False(oneVoltPerMeter >= twoVoltsPerMeter);
- Assert.False(twoVoltsPerMeter < oneVoltPerMeter);
- Assert.False(twoVoltsPerMeter <= oneVoltPerMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- Assert.Equal(0, voltpermeter.CompareTo(voltpermeter));
- Assert.True(voltpermeter.CompareTo(ElectricField.Zero) > 0);
- Assert.True(ElectricField.Zero.CompareTo(voltpermeter) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- Assert.Throws(() => voltpermeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- Assert.Throws(() => voltpermeter.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricField a = ElectricField.FromVoltsPerMeter(1);
- ElectricField b = ElectricField.FromVoltsPerMeter(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()
- {
- ElectricField v = ElectricField.FromVoltsPerMeter(1);
- Assert.True(v.Equals(ElectricField.FromVoltsPerMeter(1), ElectricField.FromVoltsPerMeter(VoltsPerMeterTolerance)));
- Assert.False(v.Equals(ElectricField.Zero, ElectricField.FromVoltsPerMeter(VoltsPerMeterTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- Assert.False(voltpermeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);
- Assert.False(voltpermeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
deleted file mode 100644
index 365c500dc2..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricInductance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricInductanceTestsBase
- {
- protected abstract double HenriesInOneHenry { get; }
- protected abstract double MicrohenriesInOneHenry { get; }
- protected abstract double MillihenriesInOneHenry { get; }
- protected abstract double NanohenriesInOneHenry { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double HenriesTolerance { get { return 1e-5; } }
- protected virtual double MicrohenriesTolerance { get { return 1e-5; } }
- protected virtual double MillihenriesTolerance { get { return 1e-5; } }
- protected virtual double NanohenriesTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void HenryToElectricInductanceUnits()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- AssertEx.EqualTolerance(HenriesInOneHenry, henry.Henries, HenriesTolerance);
- AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.Microhenries, MicrohenriesTolerance);
- AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.Millihenries, MillihenriesTolerance);
- AssertEx.EqualTolerance(NanohenriesInOneHenry, henry.Nanohenries, NanohenriesTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Henry).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Microhenry).Microhenries, MicrohenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Millihenry).Millihenries, MillihenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Nanohenry).Nanohenries, NanohenriesTolerance);
- }
-
- [Fact]
- public void As()
- {
- var henry = ElectricInductance.FromHenries(1);
- AssertEx.EqualTolerance(HenriesInOneHenry, henry.As(ElectricInductanceUnit.Henry), HenriesTolerance);
- AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.As(ElectricInductanceUnit.Microhenry), MicrohenriesTolerance);
- AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.As(ElectricInductanceUnit.Millihenry), MillihenriesTolerance);
- AssertEx.EqualTolerance(NanohenriesInOneHenry, henry.As(ElectricInductanceUnit.Nanohenry), NanohenriesTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var henry = ElectricInductance.FromHenries(1);
-
- var henryQuantity = henry.ToUnit(ElectricInductanceUnit.Henry);
- AssertEx.EqualTolerance(HenriesInOneHenry, (double)henryQuantity.Value, HenriesTolerance);
- Assert.Equal(ElectricInductanceUnit.Henry, henryQuantity.Unit);
-
- var microhenryQuantity = henry.ToUnit(ElectricInductanceUnit.Microhenry);
- AssertEx.EqualTolerance(MicrohenriesInOneHenry, (double)microhenryQuantity.Value, MicrohenriesTolerance);
- Assert.Equal(ElectricInductanceUnit.Microhenry, microhenryQuantity.Unit);
-
- var millihenryQuantity = henry.ToUnit(ElectricInductanceUnit.Millihenry);
- AssertEx.EqualTolerance(MillihenriesInOneHenry, (double)millihenryQuantity.Value, MillihenriesTolerance);
- Assert.Equal(ElectricInductanceUnit.Millihenry, millihenryQuantity.Unit);
-
- var nanohenryQuantity = henry.ToUnit(ElectricInductanceUnit.Nanohenry);
- AssertEx.EqualTolerance(NanohenriesInOneHenry, (double)nanohenryQuantity.Value, NanohenriesTolerance);
- Assert.Equal(ElectricInductanceUnit.Nanohenry, nanohenryQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- AssertEx.EqualTolerance(1, ElectricInductance.FromHenries(henry.Henries).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.FromMicrohenries(henry.Microhenries).Henries, MicrohenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.FromMillihenries(henry.Millihenries).Henries, MillihenriesTolerance);
- AssertEx.EqualTolerance(1, ElectricInductance.FromNanohenries(henry.Nanohenries).Henries, NanohenriesTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricInductance v = ElectricInductance.FromHenries(1);
- AssertEx.EqualTolerance(-1, -v.Henries, HenriesTolerance);
- AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(3)-v).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(2, (v + v).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(10, (v*10).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(10, (10*v).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(10)/5).Henries, HenriesTolerance);
- AssertEx.EqualTolerance(2, ElectricInductance.FromHenries(10)/ElectricInductance.FromHenries(5), HenriesTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricInductance oneHenry = ElectricInductance.FromHenries(1);
- ElectricInductance twoHenries = ElectricInductance.FromHenries(2);
-
- Assert.True(oneHenry < twoHenries);
- Assert.True(oneHenry <= twoHenries);
- Assert.True(twoHenries > oneHenry);
- Assert.True(twoHenries >= oneHenry);
-
- Assert.False(oneHenry > twoHenries);
- Assert.False(oneHenry >= twoHenries);
- Assert.False(twoHenries < oneHenry);
- Assert.False(twoHenries <= oneHenry);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- Assert.Equal(0, henry.CompareTo(henry));
- Assert.True(henry.CompareTo(ElectricInductance.Zero) > 0);
- Assert.True(ElectricInductance.Zero.CompareTo(henry) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- Assert.Throws(() => henry.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- Assert.Throws(() => henry.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricInductance a = ElectricInductance.FromHenries(1);
- ElectricInductance b = ElectricInductance.FromHenries(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()
- {
- ElectricInductance v = ElectricInductance.FromHenries(1);
- Assert.True(v.Equals(ElectricInductance.FromHenries(1), ElectricInductance.FromHenries(HenriesTolerance)));
- Assert.False(v.Equals(ElectricInductance.Zero, ElectricInductance.FromHenries(HenriesTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- Assert.False(henry.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- Assert.False(henry.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
deleted file mode 100644
index 382dca9c20..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricPotentialAc.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricPotentialAcTestsBase
- {
- protected abstract double KilovoltsAcInOneVoltAc { get; }
- protected abstract double MegavoltsAcInOneVoltAc { get; }
- protected abstract double MicrovoltsAcInOneVoltAc { get; }
- protected abstract double MillivoltsAcInOneVoltAc { get; }
- protected abstract double VoltsAcInOneVoltAc { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double KilovoltsAcTolerance { get { return 1e-5; } }
- protected virtual double MegavoltsAcTolerance { get { return 1e-5; } }
- protected virtual double MicrovoltsAcTolerance { get { return 1e-5; } }
- protected virtual double MillivoltsAcTolerance { get { return 1e-5; } }
- protected virtual double VoltsAcTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void VoltAcToElectricPotentialAcUnits()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.KilovoltsAc, KilovoltsAcTolerance);
- AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.MegavoltsAc, MegavoltsAcTolerance);
- AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.MicrovoltsAc, MicrovoltsAcTolerance);
- AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, voltac.MillivoltsAc, MillivoltsAcTolerance);
- AssertEx.EqualTolerance(VoltsAcInOneVoltAc, voltac.VoltsAc, VoltsAcTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.KilovoltAc).KilovoltsAc, KilovoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MegavoltAc).MegavoltsAc, MegavoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MicrovoltAc).MicrovoltsAc, MicrovoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MillivoltAc).MillivoltsAc, MillivoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.VoltAc).VoltsAc, VoltsAcTolerance);
- }
-
- [Fact]
- public void As()
- {
- var voltac = ElectricPotentialAc.FromVoltsAc(1);
- AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.KilovoltAc), KilovoltsAcTolerance);
- AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MegavoltAc), MegavoltsAcTolerance);
- AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MicrovoltAc), MicrovoltsAcTolerance);
- AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MillivoltAc), MillivoltsAcTolerance);
- AssertEx.EqualTolerance(VoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.VoltAc), VoltsAcTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var voltac = ElectricPotentialAc.FromVoltsAc(1);
-
- var kilovoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.KilovoltAc);
- AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, (double)kilovoltacQuantity.Value, KilovoltsAcTolerance);
- Assert.Equal(ElectricPotentialAcUnit.KilovoltAc, kilovoltacQuantity.Unit);
-
- var megavoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MegavoltAc);
- AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, (double)megavoltacQuantity.Value, MegavoltsAcTolerance);
- Assert.Equal(ElectricPotentialAcUnit.MegavoltAc, megavoltacQuantity.Unit);
-
- var microvoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MicrovoltAc);
- AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, (double)microvoltacQuantity.Value, MicrovoltsAcTolerance);
- Assert.Equal(ElectricPotentialAcUnit.MicrovoltAc, microvoltacQuantity.Unit);
-
- var millivoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MillivoltAc);
- AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, (double)millivoltacQuantity.Value, MillivoltsAcTolerance);
- Assert.Equal(ElectricPotentialAcUnit.MillivoltAc, millivoltacQuantity.Unit);
-
- var voltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.VoltAc);
- AssertEx.EqualTolerance(VoltsAcInOneVoltAc, (double)voltacQuantity.Value, VoltsAcTolerance);
- Assert.Equal(ElectricPotentialAcUnit.VoltAc, voltacQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.FromKilovoltsAc(voltac.KilovoltsAc).VoltsAc, KilovoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMegavoltsAc(voltac.MegavoltsAc).VoltsAc, MegavoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMicrovoltsAc(voltac.MicrovoltsAc).VoltsAc, MicrovoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMillivoltsAc(voltac.MillivoltsAc).VoltsAc, MillivoltsAcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialAc.FromVoltsAc(voltac.VoltsAc).VoltsAc, VoltsAcTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricPotentialAc v = ElectricPotentialAc.FromVoltsAc(1);
- AssertEx.EqualTolerance(-1, -v.VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(3)-v).VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(2, (v + v).VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(10, (v*10).VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(10, (10*v).VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(10)/5).VoltsAc, VoltsAcTolerance);
- AssertEx.EqualTolerance(2, ElectricPotentialAc.FromVoltsAc(10)/ElectricPotentialAc.FromVoltsAc(5), VoltsAcTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricPotentialAc oneVoltAc = ElectricPotentialAc.FromVoltsAc(1);
- ElectricPotentialAc twoVoltsAc = ElectricPotentialAc.FromVoltsAc(2);
-
- Assert.True(oneVoltAc < twoVoltsAc);
- Assert.True(oneVoltAc <= twoVoltsAc);
- Assert.True(twoVoltsAc > oneVoltAc);
- Assert.True(twoVoltsAc >= oneVoltAc);
-
- Assert.False(oneVoltAc > twoVoltsAc);
- Assert.False(oneVoltAc >= twoVoltsAc);
- Assert.False(twoVoltsAc < oneVoltAc);
- Assert.False(twoVoltsAc <= oneVoltAc);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- Assert.Equal(0, voltac.CompareTo(voltac));
- Assert.True(voltac.CompareTo(ElectricPotentialAc.Zero) > 0);
- Assert.True(ElectricPotentialAc.Zero.CompareTo(voltac) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- Assert.Throws(() => voltac.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- Assert.Throws(() => voltac.CompareTo(null));
- }
-
-
- [Fact]
- public void EqualityOperators()
- {
- ElectricPotentialAc a = ElectricPotentialAc.FromVoltsAc(1);
- ElectricPotentialAc b = ElectricPotentialAc.FromVoltsAc(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()
- {
- ElectricPotentialAc v = ElectricPotentialAc.FromVoltsAc(1);
- Assert.True(v.Equals(ElectricPotentialAc.FromVoltsAc(1), ElectricPotentialAc.FromVoltsAc(VoltsAcTolerance)));
- Assert.False(v.Equals(ElectricPotentialAc.Zero, ElectricPotentialAc.FromVoltsAc(VoltsAcTolerance)));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- Assert.False(voltac.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1);
- Assert.False(voltac.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units);
- }
-
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
deleted file mode 100644
index d87ca1945b..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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\MyQuantity.extra.cs files to add code to generated quantities.
-// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
-// Add UnitDefinitions\MyQuantity.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.Linq;
-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 ElectricPotentialDc.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class ElectricPotentialDcTestsBase
- {
- protected abstract double KilovoltsDcInOneVoltDc { get; }
- protected abstract double MegavoltsDcInOneVoltDc { get; }
- protected abstract double MicrovoltsDcInOneVoltDc { get; }
- protected abstract double MillivoltsDcInOneVoltDc { get; }
- protected abstract double VoltsDcInOneVoltDc { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double KilovoltsDcTolerance { get { return 1e-5; } }
- protected virtual double MegavoltsDcTolerance { get { return 1e-5; } }
- protected virtual double MicrovoltsDcTolerance { get { return 1e-5; } }
- protected virtual double MillivoltsDcTolerance { get { return 1e-5; } }
- protected virtual double VoltsDcTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void VoltDcToElectricPotentialDcUnits()
- {
- ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1);
- AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.KilovoltsDc, KilovoltsDcTolerance);
- AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.MegavoltsDc, MegavoltsDcTolerance);
- AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.MicrovoltsDc, MicrovoltsDcTolerance);
- AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, voltdc.MillivoltsDc, MillivoltsDcTolerance);
- AssertEx.EqualTolerance(VoltsDcInOneVoltDc, voltdc.VoltsDc, VoltsDcTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.KilovoltDc).KilovoltsDc, KilovoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MegavoltDc).MegavoltsDc, MegavoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MicrovoltDc).MicrovoltsDc, MicrovoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MillivoltDc).MillivoltsDc, MillivoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.VoltDc).VoltsDc, VoltsDcTolerance);
- }
-
- [Fact]
- public void As()
- {
- var voltdc = ElectricPotentialDc.FromVoltsDc(1);
- AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.KilovoltDc), KilovoltsDcTolerance);
- AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MegavoltDc), MegavoltsDcTolerance);
- AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MicrovoltDc), MicrovoltsDcTolerance);
- AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MillivoltDc), MillivoltsDcTolerance);
- AssertEx.EqualTolerance(VoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.VoltDc), VoltsDcTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var voltdc = ElectricPotentialDc.FromVoltsDc(1);
-
- var kilovoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.KilovoltDc);
- AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, (double)kilovoltdcQuantity.Value, KilovoltsDcTolerance);
- Assert.Equal(ElectricPotentialDcUnit.KilovoltDc, kilovoltdcQuantity.Unit);
-
- var megavoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MegavoltDc);
- AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, (double)megavoltdcQuantity.Value, MegavoltsDcTolerance);
- Assert.Equal(ElectricPotentialDcUnit.MegavoltDc, megavoltdcQuantity.Unit);
-
- var microvoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MicrovoltDc);
- AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, (double)microvoltdcQuantity.Value, MicrovoltsDcTolerance);
- Assert.Equal(ElectricPotentialDcUnit.MicrovoltDc, microvoltdcQuantity.Unit);
-
- var millivoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MillivoltDc);
- AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, (double)millivoltdcQuantity.Value, MillivoltsDcTolerance);
- Assert.Equal(ElectricPotentialDcUnit.MillivoltDc, millivoltdcQuantity.Unit);
-
- var voltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.VoltDc);
- AssertEx.EqualTolerance(VoltsDcInOneVoltDc, (double)voltdcQuantity.Value, VoltsDcTolerance);
- Assert.Equal(ElectricPotentialDcUnit.VoltDc, voltdcQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.FromKilovoltsDc(voltdc.KilovoltsDc).VoltsDc, KilovoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMegavoltsDc(voltdc.MegavoltsDc).VoltsDc, MegavoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMicrovoltsDc(voltdc.MicrovoltsDc).VoltsDc, MicrovoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMillivoltsDc(voltdc.MillivoltsDc).VoltsDc, MillivoltsDcTolerance);
- AssertEx.EqualTolerance(1, ElectricPotentialDc.FromVoltsDc(voltdc.VoltsDc).VoltsDc, VoltsDcTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- ElectricPotentialDc v = ElectricPotentialDc.FromVoltsDc(1);
- AssertEx.EqualTolerance(-1, -v.VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(3)-v).VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(2, (v + v).VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(10, (v*10).VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(10, (10*v).VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(10)/5).VoltsDc, VoltsDcTolerance);
- AssertEx.EqualTolerance(2, ElectricPotentialDc.FromVoltsDc(10)/ElectricPotentialDc.FromVoltsDc(5), VoltsDcTolerance);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- ElectricPotentialDc oneVoltDc = ElectricPotentialDc.FromVoltsDc(1);
- ElectricPotentialDc twoVoltsDc = ElectricPotentialDc.FromVoltsDc(2);
-
- Assert.True(oneVoltDc < twoVoltsDc);
- Assert.True(oneVoltDc <= twoVoltsDc);
- Assert.True(twoVoltsDc > oneVoltDc);
- Assert.True(twoVoltsDc >= oneVoltDc);
-
- Assert.False(oneVoltDc > twoVoltsDc);
- Assert.False(oneVoltDc >= twoVoltsDc);
- Assert.False(twoVoltsDc < oneVoltDc);
- Assert.False(twoVoltsDc <= oneVoltDc);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1);
- Assert.Equal(0, voltdc.CompareTo(voltdc));
- Assert.True(voltdc.CompareTo(ElectricPotentialDc.Zero) > 0);
- Assert.True(ElectricPotentialDc.Zero.CompareTo(voltdc) < 0);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1);
- Assert.Throws(() => voltdc.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1);
- Assert.Throws