/// <summary> /// Gets the unit that matches the specified name. /// </summary> /// <typeparam name="T"> /// The unit type. /// </typeparam> /// <param name="unitProvider"> /// The unit provider. /// </param> /// <param name="symbol"> /// The unit symbol. /// </param> /// <param name="unit"> /// The unit. /// </param> /// <returns> /// <c>true</c> if the unit name was found, <c>false</c> otherwise /// </returns> public static bool TryGetUnit <T>(this IUnitProvider unitProvider, string symbol, out T unit) where T : IQuantity <T> { if (unitProvider.TryGetUnit(typeof(T), symbol, out var u)) { unit = (T)u; return(true); } unit = default(T); return(false); }