示例#1
0
            /// <summary>
            /// Parses a <see cref="Match"/> into a <see cref="DateToken"/>.
            /// </summary>
            /// <param name="match">A <see cref="Match"/> representation of a <see cref="DateToken"/>.</param>
            /// <param name="provider">An <see cref="IFormatProvider"/>.</param>
            /// <returns>The <see cref="DateToken"/> parsed from the <see cref="Match"/>.</returns>
            /// <exception cref="ArgumentNullException">If <paramref name="match"/> or <paramref name="provider"/> is
            /// <c>null</c>.</exception>
            /// <exception cref="FormatException">If the <paramref name="match"/> is not a supported representation of
            /// a <see cref="DateToken"/>.</exception>
            protected override DateToken ParseInternal(Match match, IFormatProvider provider)
            {
                provider = Resources.ResourceManager.GetEffectiveProvider(provider);

                DayOfWeekDateToken dateToken = new DayOfWeekDateToken();

                // Parse day of week
                if (match.Groups["weekday"].Success)
                {
                    dateToken.DayOfWeek = DayOfWeekExtensions.ParseDayOfWeek(match.Groups["weekday"].Value, provider);
                }

                // Parse day of week relation
                if (match.Groups["afternext"].Success)
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.AfterNext;
                }
                else if (match.Groups["nextweek"].Success)
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.NextWeek;
                }
                else
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.Next;
                }

                return(dateToken);
            }
            /// <summary>
            /// Parses a <see cref="Match"/> into a <see cref="DateToken"/>.
            /// </summary>
            /// <param name="match">A <see cref="Match"/> representation of a <see cref="DateToken"/>.</param>
            /// <param name="provider">An <see cref="IFormatProvider"/>.</param>
            /// <returns>The <see cref="DateToken"/> parsed from the <see cref="Match"/>.</returns>
            /// <exception cref="ArgumentNullException">If <paramref name="match"/> or <paramref name="provider"/> is
            /// <c>null</c>.</exception>
            /// <exception cref="FormatException">If the <paramref name="match"/> is not a supported representation of
            /// a <see cref="DateToken"/>.</exception>
            protected override DateToken ParseInternal(Match match, IFormatProvider provider)
            {
                provider = Resources.ResourceManager.GetEffectiveProvider(provider);

                DayOfWeekDateToken dateToken = new DayOfWeekDateToken();

                // Parse day of week
                if (match.Groups["weekday"].Success)
                {
                    dateToken.DayOfWeek = DayOfWeekExtensions.ParseDayOfWeek(match.Groups["weekday"].Value, provider);
                }

                // Parse day of week relation
                if (match.Groups["afternext"].Success)
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.AfterNext;
                }
                else if (match.Groups["nextweek"].Success)
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.NextWeek;
                }
                else
                {
                    dateToken.DayOfWeekRelation = Parsing.DayOfWeekRelation.Next;
                }

                return dateToken;
            }