/// <devdoc>
        /// <para>Converts the given object to a <see cref='Gu.Units.VolumetricFlowUnit'/>
        /// object.</para>
        /// </devdoc>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var text = value as string;

            if (text != null)
            {
                VolumetricFlowUnit result;
                if (VolumetricFlowUnit.TryParse(text, out result))
                {
                    return(result);
                }

                var message = $"Could not convert the string '{text}' to an instance of VolumetricFlowUnit)";
                throw new NotSupportedException(message);
            }

            return(base.ConvertFrom(context, culture, value));
        }
 public bool Equals(VolumetricFlowUnit other)
 {
     return(this.symbol == other.symbol);
 }
 public static bool TryParse(string text, out VolumetricFlowUnit result)
 {
     return(UnitParser <VolumetricFlowUnit> .TryParse(text, out result));
 }
예제 #4
0
 /// <summary>
 /// Creates a new instance of <see cref="T:Gu.Units.VolumetricFlow"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="unit"></param>
 public static VolumetricFlow From(double value, VolumetricFlowUnit unit)
 {
     return(new VolumetricFlow(unit.ToSiUnit(value)));
 }
예제 #5
0
        public string ToString(string format, IFormatProvider formatProvider, VolumetricFlowUnit unit)
        {
            var quantity = unit.FromSiUnit(this.cubicMetresPerSecond);

            return(string.Format("{0}{1}", quantity.ToString(format, formatProvider), unit.Symbol));
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of <see cref="T:Gu.Units.VolumetricFlow"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="unit"><see cref="T:Gu.Units.CubicMetresPerSecond"/>.</param>
 public VolumetricFlow(double value, VolumetricFlowUnit unit)
 {
     this.cubicMetresPerSecond = unit.ToSiUnit(value);
 }