Scalar value with unit string.
Inheritance: 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);
 }