public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var text = value as string;

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

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

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