mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
* Upgrade UnitsNet package to a version that supports plural * Add support for plurals Fix metre conversion Add and update unit tests
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using UnitsNet;
|
|
|
|
namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|
{
|
|
public class UnitConversionResult
|
|
{
|
|
public static string Format { get; set; } = "g14";
|
|
|
|
public double ConvertedValue { get; }
|
|
|
|
public string UnitName { get; }
|
|
|
|
public QuantityInfo QuantityInfo { get; }
|
|
|
|
public UnitConversionResult(double convertedValue, string unitName, QuantityInfo quantityInfo)
|
|
{
|
|
ConvertedValue = convertedValue;
|
|
UnitName = unitName;
|
|
QuantityInfo = quantityInfo;
|
|
}
|
|
|
|
public string ToString(System.IFormatProvider provider = null)
|
|
{
|
|
if (provider == null)
|
|
{
|
|
provider = System.Globalization.CultureInfo.CurrentCulture;
|
|
}
|
|
|
|
return ConvertedValue.ToString(Format, provider) + " " + UnitName;
|
|
}
|
|
}
|
|
}
|