37 lines
884 B
C#
37 lines
884 B
C#
namespace CommonMessurementUnits
|
|
{
|
|
using CommonMessurementUnits.JsonConverters;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
[JsonConverter(typeof(VolumeConverter))]
|
|
public class Volume : Unit
|
|
{
|
|
public double Mililiter
|
|
{
|
|
get => this.Liter * MlInL;
|
|
set => this.Liter = value / MlInL;
|
|
}
|
|
|
|
public double Liter
|
|
{
|
|
get => this.value * LInm3;
|
|
set => this.value = value / LInm3;
|
|
}
|
|
|
|
public double CubicMeter
|
|
{
|
|
get => this.value * this.Factor;
|
|
set => this.value = value / this.Factor;
|
|
}
|
|
|
|
public int 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 };
|
|
}
|
|
}
|