Beispiel #1
0
        /// <summary>
        /// Override of the <see cref="InpOption{T}.ParseRow(IInpTableRow)"/> method
        /// that will convert the value from the row into an int.
        /// </summary>
        /// <param name="row">The row that will be parsed</param>
        /// <returns>Returns: an <see cref="int"/> that is parsed from the second element in the row</returns>
        protected internal override int ParseRow(IInpTableRow row)
        {
            _ = row ?? throw new ArgumentNullException(nameof(row));

            if (int.TryParse(row[1], out var value))
            {
                return(value);
            }
            else
            {
                throw InpParseException.CreateWithStandardMessage(typeof(InpIntOption));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Parse the <see cref="IInpTableRow"/> to the <see cref="Value"/>
        /// for the <see cref="TimeSpan"/> type
        /// </summary>
        /// <param name="row">The row that will be parsed</param>
        /// <returns>Returns: The parsed value</returns>
        internal protected override TimeSpan ParseRow(IInpTableRow row)
        {
            // Check for null
            _ = row ?? throw new ArgumentNullException(nameof(row));

            // Try and parse the row as a time span
            if (TimeSpan.TryParse(row[1], out var value))
            {
                return(value);
            }
            // If it fails then throw an exception
            else
            {
                throw InpParseException.CreateWithStandardMessage(typeof(InpTimeSpanOption));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Protected internal override of the <see cref="InpOption{T}.ParseRow(IInpTableRow)"/> Method
        ///  that parses a <see cref="double"/>
        /// </summary>
        /// <param name="row">The row that will be parsed</param>
        /// <returns>Returns: a <see cref="double"/> that is parsed from the row</returns>
        protected internal override double ParseRow(IInpTableRow row)
        {
            // Check for null
            _ = row ?? throw new ArgumentNullException(nameof(row));

            // Try to parse the row
            if (double.TryParse(row[1], out var value))
            {
                // If it succeeds then assign the value of the parsing
                return(value);
            }
            // If it is not successful throw an new exception
            else
            {
                throw InpParseException.CreateWithStandardMessage(typeof(InpDoubleOption));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Parse the <see cref="IInpTableRow"/> that is passed and return it.
 /// </summary>
 /// <param name="row">The row that will be parsed an returned</param>
 /// <exception cref="ArgumentNullException">
 /// Will Throw if <paramref name="row"/> is <see cref="null"/>
 /// </exception>
 /// <exception cref="InpParseException">
 /// Will Throw if <see cref="DateTime.TryParse(ReadOnlySpan{char}, out DateTime)"/> fails
 /// </exception>
 /// <returns>Returns: The <see cref="DateTime"/> that is parsed from the row</returns>
 protected internal override DateTime ParseRow(IInpTableRow row)
 => row == null ? throw new ArgumentNullException(nameof(row)) :
       DateTime.TryParse(row[1], out var result) ? result :
       throw InpParseException.CreateWithStandardMessage(typeof(InpDateTimeOption));