Esempio n. 1
0
 public VolumeMetric(QuantityDna dna, double value)
     : base(dna, value)
 {
     if (dna.UnitType != (ushort)VolumeUnit.Metric)
     {
         throw new ArgumentException($"Invalid DNA. Expected unit type {VolumeUnit.Metric}");
     }
 }
Esempio n. 2
0
 public LengthUsCustomary(QuantityDna dna, double value)
     : base(dna, value)
 {
     if (dna.UnitType != (ushort)LengthUnit.UsCustomary)
     {
         throw new ArgumentException($"Invalid DNA. Expected unit type {LengthUnit.UsCustomary}");
     }
 }
Esempio n. 3
0
 protected Length(QuantityDna dna, double value)
     : base(dna, value)
 {
     if (Dna.QuantityType != QuantityType.Length)
     {
         throw new ArgumentException($"Invalid DNA. Expected quantity type {QuantityType.Length}");
     }
 }
Esempio n. 4
0
 public LengthImperial(QuantityDna dna, double value)
     : base(dna, value)
 {
     if (dna.UnitType != (ushort)LengthUnit.Imperial)
     {
         throw new ArgumentException($"Invalid DNA. Expected unit type {LengthUnit.Imperial}");
     }
 }
Esempio n. 5
0
 public Volume(QuantityDna dna, double value)
     : base(dna, value)
 {
     if (Dna.QuantityType != QuantityType.Volume)
     {
         throw new ArgumentException($"Invalid DNA. Expected quantity type {QuantityType.Volume}");
     }
 }
Esempio n. 6
0
        public static Quantity FromDna(QuantityDna dna, double value)
        {
            switch (dna.QuantityType)
            {
            case QuantityType.Length:
                return(LengthFromDna(dna, value));

            case QuantityType.Area:
            case QuantityType.Volume:
            case QuantityType.Temperature:
            case QuantityType.Unspecified:
            default:
                throw new ArgumentException($"Cannot create quantity from type {dna.QuantityType}");
            }
        }
Esempio n. 7
0
        public static Quantity LengthFromDna(QuantityDna dna, double value)
        {
            switch (dna.UnitType)
            {
            case (ushort)Length.LengthUnit.Metric:
                return(new LengthMetric(dna, value));

            case (ushort)Length.LengthUnit.Imperial:
                return(new LengthImperial(dna, value));

            case (ushort)Length.LengthUnit.UsCustomary:
                return(new LengthUsCustomary(dna, value));

            default:
                throw new ArgumentException($"Cannot create length from unit type {dna.UnitType}");
            }
        }
Esempio n. 8
0
 protected Quantity(QuantityDna dna, double value)
 {
     Dna   = dna;
     Value = value;
 }