Scalar value with unit string.
Наследование: YAMP.ScalarValue
Пример #1
0
        public static UnitValue Convert(UnitValue fromValue, String targetUnit)
        {
            var cu = new CombinedUnit(fromValue.Unit);
            var conversions = cu.ConvertTo(targetUnit);
            var re = fromValue.Re;

            foreach (var conversation in conversions)
            {
                re = conversation(re);
            }

            return new UnitValue(cu.Factor * re, cu.Unit);
        }
Пример #2
0
 public UnitValue Function(UnitValue value, StringValue to)
 {
     return(Convert(value, to.Value));
 }
Пример #3
0
 /// <summary>
 /// Creates a new unit value.
 /// </summary>
 /// <param name="value">The unit to copy.</param>
 public UnitValue(UnitValue value)
     : this(value.Re, value.Unit)
 {
 }
Пример #4
0
        /// <summary>
        /// Transforms a binary representation into a new instance.
        /// </summary>
        /// <param name="content">The binary data.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(Byte[] content)
        {
            var unit = new UnitValue();
            unit.Re = BitConverter.ToDouble(content, 0);
            unit.Im = BitConverter.ToDouble(content, 8);
            var str = new char[BitConverter.ToInt32(content, 16)];

            for (var i = 0; i < str.Length; i++)
            {
                str[i] = BitConverter.ToChar(content, 20 + 2 * i);
            }

            unit._unit = new String(str);
            return unit;
        }
Пример #5
0
 public UnitValue Function(UnitValue value, StringValue to)
 {
     return Convert(value, to.Value);
 }