Ejemplo n.º 1
0
        /// <summary>
        /// Converts the term to an <see cref="Single"/>.
        /// </summary>
        /// <param name="term">The term to convert.</param>
        /// <returns>The resulting value.</returns>
        /// <exception cref="InvalidCastException">
        /// The term could not be converted.
        /// </exception>
        public static Single ToSingle(this ITerm term)
        {
            #region Contract
            if (term == null)
            {
                throw new ArgumentNullException(nameof(term));
            }
            #endregion

            var result = term.AsSingle();
            if (result == null)
            {
                throw new InvalidCastException($"Can't cast term {term} to Single.");
            }
            return((Single)result);
        }