Exemple #1
0
        /// <summary>
        /// Builds the description.
        /// </summary>
        /// <param name="ncrontab">The ncrontab.</param>
        /// <returns></returns>
        private static string BuildDescription(CrontabSchedule ncrontab)
        {
            if (ncrontab.ToString() == AnytimeSchedule.ToString())
            {
                return(AnyTimeDescription);
            }

            StringBuilder result = new StringBuilder();
            List <DescriptionDirective> directives = GetDirectives(ncrontab.ToString());

            ConsolidateDirectives(directives);

            // build the final description backwards
            for (int i = directives.Count - 1; i >= 0; i--)
            {
                bool skipNext = FieldLogicMap[directives[i].Field].BuildDescription(directives, result);

                if (!skipNext && i > 0)
                {
                    result.Append(", ");
                }

                if (skipNext)
                {
                    i--;
                }
            }

            return(CleanDescription(result));
        }
Exemple #2
0
        private static IPollingInterval MakeInterval(Type pollType, CrontabSchedule schedule)
        {
            var type             = typeof(PollingInterval <>);
            var makeGenericType  = type.MakeGenericType(pollType);
            var constructors     = makeGenericType.GetConstructors();
            var constructorInfos = constructors.First(c =>
                                                      c.GetParameters().SingleOrDefault()?.ParameterType == typeof(string));
            var cronNotationRaw = schedule.ToString();
            var interval        = constructorInfos.Invoke(new object[] { cronNotationRaw });

            return((IPollingInterval)interval);
        }
 /// <inheritdoc/>
 public override string ToString()
 {
     return(string.Format(CultureInfo.InvariantCulture, "Cron: '{0}'", _cronSchedule.ToString()));
 }