Beispiel #1
0
        /// <summary>
        /// Get a <see cref="double"/> from the user
        /// </summary>
        /// <param name="helper">The console to use</param>
        /// <returns>The <see cref="double"/> entered by the user</returns>
        /// <exception cref="ArgumentNullException"><paramref name="helper"/> is <see langword="null"/></exception>
        /// <exception cref="IOException">An I/O error occured</exception>
        /// <exception cref="ObjectDisposedException"><see cref="TextIoHelper.Output"/> or <see cref="TextIoHelper.Input"/> is closed</exception>
        /// <exception cref="OutOfMemoryException">There is insufficient memory to allocate a buffer for the line read from <see cref="TextIoHelper.Input"/></exception>
        /// <exception cref="ArgumentOutOfRangeException">The number of characters in the next line is greater than <see cref="int.MaxValue"/></exception>
        /// <exception cref="EndOfStreamException">Reached the end of <see cref="TextIoHelper.Input"/></exception>
        public static double GetDouble(this ConsoleHelper helper)
        {
            TryParseDelegateExtensions.TryParse <string, double> act = double.TryParse;

            return(Get(helper, act.ToTryResult("Please enter a valid number")));
        }
Beispiel #2
0
        /// <summary>
        /// Gets a <see cref="long"/> from the user
        /// </summary>
        /// <param name="helper">The console to use</param>
        /// <returns>The <see cref="long"/> entered by the user</returns>
        /// <exception cref="ArgumentNullException"><paramref name="helper"/> is <see langword="null"/></exception>
        /// <exception cref="IOException">An I/O error occured</exception>
        /// <exception cref="ObjectDisposedException"><see cref="TextIoHelper.Output"/> or <see cref="TextIoHelper.Input"/> is closed</exception>
        /// <exception cref="OutOfMemoryException">There is insufficient memory to allocate a buffer for the line read from <see cref="TextIoHelper.Input"/></exception>
        /// <exception cref="ArgumentOutOfRangeException">The number of characters in the next line is greater than <see cref="int.MaxValue"/></exception>
        /// <exception cref="EndOfStreamException">Reached the end of <see cref="TextIoHelper.Input"/></exception>
        public static long GetLong(this ConsoleHelper helper)
        {
            TryParseDelegateExtensions.TryParse <string, long> act = long.TryParse;

            return(Get(helper, act.ToTryResult("Please enter a valid integer")));
        }
Beispiel #3
0
        /// <summary>
        /// Get a <see cref="decimal"/> from the user
        /// </summary>
        /// <param name="helper">The console to use</param>
        /// <returns>The <see cref="decimal"/> entered by the user</returns>
        /// <exception cref="ArgumentNullException"><paramref name="helper"/> is <see langword="null"/></exception>
        /// <exception cref="IOException">An I/O error occured</exception>
        /// <exception cref="ObjectDisposedException"><see cref="TextIoHelper.Output"/> or <see cref="TextIoHelper.Input"/> is closed</exception>
        /// <exception cref="OutOfMemoryException">There is insufficient memory to allocate a buffer for the line read from <see cref="TextIoHelper.Input"/></exception>
        /// <exception cref="ArgumentOutOfRangeException">The number of characters in the next line is greater than <see cref="int.MaxValue"/></exception>
        /// <exception cref="EndOfStreamException">Reached the end of <see cref="TextIoHelper.Input"/></exception>
        public static decimal GetDecimal(this ConsoleHelper helper)
        {
            TryParseDelegateExtensions.TryParse <string, decimal> act = decimal.TryParse;

            return(Get(helper, act.ToTryResult("Please enter a valid number")));
        }
Beispiel #4
0
        /// <summary>
        /// Gets an <see cref="int"/> from the user
        /// </summary>
        /// <param name="helper">The console to use</param>
        /// <returns>The <see cref="int"/> entered by the user</returns>
        /// <exception cref="ArgumentNullException"><paramref name="helper"/> is <see langword="null"/></exception>
        /// <exception cref="IOException">An I/O error occured</exception>
        /// <exception cref="ObjectDisposedException"><see cref="TextIoHelper.Output"/> or <see cref="TextIoHelper.Input"/> is closed</exception>
        /// <exception cref="OutOfMemoryException">There is insufficient memory to allocate a buffer for the line read from <see cref="TextIoHelper.Input"/></exception>
        /// <exception cref="ArgumentOutOfRangeException">The number of characters in the next line is greater than <see cref="int.MaxValue"/></exception>
        /// <exception cref="EndOfStreamException">Reached the end of <see cref="TextIoHelper.Input"/></exception>
        public static int GetInt(this ConsoleHelper helper)
        {
            TryParseDelegateExtensions.TryParse <string, int> act = int.TryParse;

            return(Get(helper, act.ToTryResult("Please enter a valid integer")));
        }