Example #1
0
        /// <inheritdoc />
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var text = value as string;

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

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

            return(base.ConvertFrom(context, culture, value));
        }
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.AreaDensityUnit"/> object.
 /// </summary>
 /// <param name="other">An instance of <see cref="Gu.Units.AreaDensityUnit"/> object to compare with this instance.</param>
 /// <returns>
 /// true if <paramref name="other"/> represents the same AreaDensityUnit as this instance; otherwise, false.
 /// </returns>
 public bool Equals(AreaDensityUnit other)
 {
     return(this.symbol == other.symbol);
 }
 /// <summary>
 /// Creates an instance of <see cref="Gu.Units.AreaDensityUnit"/> from its string representation
 /// </summary>
 /// <param name="text">The string representation of the <see cref="Gu.Units.AreaDensityUnit"/></param>
 /// <param name="result">The parsed <see cref="AreaDensityUnit"/></param>
 /// <returns>True if an instance of <see cref="AreaDensityUnit"/> could be parsed from <paramref name="text"/></returns>
 public static bool TryParse(string text, out AreaDensityUnit result)
 {
     return(UnitParser <AreaDensityUnit> .TryParse(text, out result));
 }