Expl.Itinerary.ListSchedule.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            // If schedule precedence is > this schedule, add parens
             // If lvalue is same type as this schedule, no parens are needed.
             // e.g. "(A, B), C" equates to "A, B, C"
             // e.g. "A, (B, C)" equates to "A, B, C"
             StringBuilder sb = new StringBuilder();
             sb.Append(Schedules.Select<ISchedule, string>(Schedule =>
            Schedule.OperatorPrecedence > this.OperatorPrecedence
            ? "(" + Schedule.ToString() + ")"
            : Schedule.ToString()
             ).JoinStrings(", "));
             return sb.ToString();
        }

Usage Example

Example #1
0
        static void Main(string[] args)
        {
            // Create schedule programmatically.
             ISchedule schedule1 = new IntervalSchedule(TimeSpan.FromSeconds(11), TimeSpan.Zero, DateTime.MinValue);
             ISchedule schedule2 = new IntervalSchedule(TimeSpan.FromMinutes(1), TimeSpan.Zero, DateTime.MinValue.AddSeconds(1));
             ISchedule schedule3 = new CronSchedule("*/5", "*", "*", "*", "*", TimeSpan.Zero);
             ISchedule combinedSchedule = new ListSchedule(new[] { schedule1, schedule2, schedule3 });

             // Print schedule TDL.
             Console.WriteLine("Forecasting events from expression:\n{0}", combinedSchedule.ToString());

             // Forecast timed events for the next hour.
             IEnumerable<TimedEvent> events = combinedSchedule.GetRange(DateTime.Now, DateTime.Now.AddHours(1));

             int eventCount = events.Count();
             Console.WriteLine("Found {0:d} events.", eventCount);

             // Print to screen.
             foreach (TimedEvent e in events) {
            Console.WriteLine("Event time: {0:G}", e.StartTime);
             }
        }