37 lines
909 B
C#
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 };
|
|
}
|
|
}
|