Exemplo n.º 1
0
        /// <summary>
        /// Gets the display unit for the specified type.
        /// </summary>
        /// <typeparam name="T">
        /// The unit type.
        /// </typeparam>
        /// <param name="unitProvider">
        /// The unit provider.
        /// </param>
        /// <param name="unit">
        /// The unit.
        /// </param>
        /// <param name="unitSymbol">
        /// The unit symbol.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/> .
        /// </returns>
        public static bool TryGetDisplayUnit <T>(this IUnitProvider unitProvider, out T unit, out string unitSymbol)
        {
            IQuantity quantity;

            if (!unitProvider.TryGetDisplayUnit(typeof(T), out quantity, out unitSymbol))
            {
                unit = default(T);
                return(false);
            }

            unit = (T)quantity;
            return(true);
        }