/// <summary> /// Initializes a new instance of the <see cref="TimerStart"/> class. /// </summary> /// <param name="timerStartInfo">A <see cref="TimerStartInfo"/>.</param> private TimerStart(TimerStartInfo timerStartInfo) { if (timerStartInfo == null) { throw new ArgumentNullException("timerStartInfo"); } this.timerStartToken = timerStartInfo.TimerStartToken; }
/// <summary> /// Initializes a new instance of the <see cref="TimerStart"/> class. /// </summary> /// <param name="timerStartToken">A <see cref="TimerStartToken"/>.</param> private TimerStart(TimerStartToken timerStartToken) { if (timerStartToken == null) { throw new ArgumentNullException("timerStartToken"); } this.timerStartToken = timerStartToken; }
/// <summary> /// Parses a string into a <see cref="TimerStartToken"/>. /// </summary> /// <param name="str">A string representation of a <see cref="TimerStartToken"/>.</param> /// <param name="provider">An <see cref="IFormatProvider"/>.</param> /// <param name="timerStartToken">The <see cref="TimerStartToken"/> parsed from the string, or <c>null</c> /// if the string is not a supported representation of a <see cref="TimerStartToken"/>.</param> /// <returns><c>true</c> if the <see cref="TimerStartToken"/> was successfully parsed from <paramref /// name="str"/>, or <c>false</c> otherwise.</returns> public bool TryParse(string str, IFormatProvider provider, out TimerStartToken timerStartToken) { try { timerStartToken = this.Parse(str, provider); return(true); } catch { timerStartToken = null; return(false); } }
/// <summary> /// Parses a string into a <see cref="TimerStartToken"/>. /// </summary> /// <param name="str">A string representation of a <see cref="TimerStartToken"/>.</param> /// <param name="provider">An <see cref="IFormatProvider"/>.</param> /// <returns>The <see cref="TimerStartToken"/> parsed from the string.</returns> /// <exception cref="ArgumentNullException">If <paramref name="str"/> or <paramref name="provider"/> is /// <c>null</c>.</exception> /// <exception cref="FormatException">If <paramref name="str"/> is not a supported representation of a <see /// cref="TimerStartToken"/>.</exception> public TimerStartToken Parse(string str, IFormatProvider provider) { if (str == null) { throw new ArgumentNullException("str"); } TimerStartToken timerStartToken = this.ParseInternal(str, provider); if (!timerStartToken.IsValid) { throw new FormatException(); } return(timerStartToken); }
/// <summary> /// Asserts that a <see cref="TimerStartToken"/> is an instance of the <see cref="DateTimeToken"/> class and /// returns the value of its <see cref="DateTimeToken.TimeToken"/> property. /// </summary> /// <param name="actual">The actual <see cref="TimerStartToken"/>.</param> /// <returns>The value of the <see cref="DateTimeToken.TimeToken"/> property.</returns> private static TimeToken GetTimeToken(TimerStartToken actual) { Assert.AreEqual(typeof(DateTimeToken), actual.GetType()); return ((DateTimeToken)actual).TimeToken; }
/// <summary> /// Parses a string into a <see cref="TimerStartToken"/>. /// </summary> /// <param name="str">A string representation of a <see cref="TimerStartToken"/>.</param> /// <param name="provider">An <see cref="IFormatProvider"/>.</param> /// <param name="timerStartToken">The <see cref="TimerStartToken"/> parsed from the string, or <c>null</c> /// if the string is not a supported representation of a <see cref="TimerStartToken"/>.</param> /// <returns><c>true</c> if the <see cref="TimerStartToken"/> was successfully parsed from <paramref /// name="str"/>, or <c>false</c> otherwise.</returns> public bool TryParse(string str, IFormatProvider provider, out TimerStartToken timerStartToken) { try { timerStartToken = this.Parse(str, provider); return true; } catch { timerStartToken = null; return false; } }
/// <summary> /// Parses a string into a <see cref="TimerStartToken"/>. /// </summary> /// <remarks> /// This overload uses the <see cref="CultureInfo.CurrentCulture"/> as the <see cref="IFormatProvider"/>. /// </remarks> /// <param name="str">A string representation of a <see cref="TimerStartToken"/>.</param> /// <param name="timerStartToken">The <see cref="TimerStartToken"/> parsed from the string, or <c>null</c> /// if the string is not a supported representation of a <see cref="TimerStartToken"/>.</param> /// <returns><c>true</c> if the <see cref="TimerStartToken"/> was successfully parsed from <paramref /// name="str"/>, or <c>false</c> otherwise.</returns> public bool TryParse(string str, out TimerStartToken timerStartToken) { return this.TryParse(str, CultureInfo.CurrentCulture, out timerStartToken); }
/// <summary> /// Parses a string into a <see cref="TimerStartToken"/>. /// </summary> /// <remarks> /// This overload uses the <see cref="CultureInfo.CurrentCulture"/> as the <see cref="IFormatProvider"/>. /// </remarks> /// <param name="str">A string representation of a <see cref="TimerStartToken"/>.</param> /// <param name="timerStartToken">The <see cref="TimerStartToken"/> parsed from the string, or <c>null</c> /// if the string is not a supported representation of a <see cref="TimerStartToken"/>.</param> /// <returns><c>true</c> if the <see cref="TimerStartToken"/> was successfully parsed from <paramref /// name="str"/>, or <c>false</c> otherwise.</returns> public bool TryParse(string str, out TimerStartToken timerStartToken) { return(this.TryParse(str, CultureInfo.CurrentCulture, out timerStartToken)); }
/// <summary> /// Asserts that a <see cref="TimerStartToken"/> is an instance of the <see cref="TimeSpanToken"/> class and /// that its value is equal to the specified parameters. /// </summary> /// <param name="actual">The actual <see cref="TimerStartToken"/>.</param> /// <param name="expectedYears">The expected years.</param> /// <param name="expectedMonths">The expected months.</param> /// <param name="expectedWeeks">The expected weeks.</param> /// <param name="expectedDays">The expected days.</param> /// <param name="expectedHours">The expected hours.</param> /// <param name="expectedMinutes">The expected minutes.</param> /// <param name="expectedSeconds">The expected seconds.</param> private static void AssertAreEqual(TimerStartToken actual, double expectedYears = 0, double expectedMonths = 0, double expectedWeeks = 0, double expectedDays = 0, double expectedHours = 0, double expectedMinutes = 0, double expectedSeconds = 0) { Assert.IsNotNull(actual); Assert.AreEqual(typeof(TimeSpanToken), actual.GetType()); Assert.AreEqual(expectedYears, ((TimeSpanToken)actual).Years); Assert.AreEqual(expectedMonths, ((TimeSpanToken)actual).Months); Assert.AreEqual(expectedWeeks, ((TimeSpanToken)actual).Weeks); Assert.AreEqual(expectedDays, ((TimeSpanToken)actual).Days); Assert.AreEqual(expectedHours, ((TimeSpanToken)actual).Hours); Assert.AreEqual(expectedMinutes, ((TimeSpanToken)actual).Minutes); Assert.AreEqual(expectedSeconds, ((TimeSpanToken)actual).Seconds); }