2021-08-11 17:22:30 +02:00
|
|
|
|
// 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;
|
2021-06-09 10:46:19 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UnitConversionResult
|
|
|
|
|
|
{
|
2022-04-19 12:20:12 +02:00
|
|
|
|
public static string Format { get; set; } = "g14";
|
|
|
|
|
|
|
2021-06-09 10:46:19 +01:00
|
|
|
|
public double ConvertedValue { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public string UnitName { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public QuantityType QuantityType { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public UnitConversionResult(double convertedValue, string unitName, QuantityType quantityType)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConvertedValue = convertedValue;
|
|
|
|
|
|
UnitName = unitName;
|
|
|
|
|
|
QuantityType = quantityType;
|
|
|
|
|
|
}
|
2022-04-19 12:20:12 +02:00
|
|
|
|
|
|
|
|
|
|
public string ToString(System.IFormatProvider provider = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (provider == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
provider = System.Globalization.CultureInfo.CurrentCulture;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ConvertedValue.ToString(Format, provider) + " " + UnitName;
|
|
|
|
|
|
}
|
2021-06-09 10:46:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|