laatzen/Common/CommonMessurementUnits/Volume.cs
2023-09-14 13:04:12 +02:00

37 lines
909 B
C#

using System;
using Newtonsoft.Json;
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
{
[JsonConverter(typeof(VolumeConverter))]
public class Volume : Unit
{
public Double Mililiter
{
get => Liter * MlInL;
set => Liter = value / MlInL;
}
public Double Liter
{
get => value * LInm3;
set => this.value = value / LInm3;
}
public Double CubicMeter
{
get => value * Factor;
set => this.value = value / Factor;
}
public Int32 Factor { get; set; } = 1000;
public static implicit operator Volume(Double x)
=> new Volume { value = x };
public static implicit operator Volume(Double? x)
=> new Volume { value = x ?? 0 };
}
}