本文整理汇总了C#中ISchedule.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# ISchedule.Accept方法的具体用法?C# ISchedule.Accept怎么用?C# ISchedule.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISchedule
的用法示例。
在下文中一共展示了ISchedule.Accept方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdvancedPrint
private IScheduleVisitor AdvancedPrint(ISchedule schedule)
{
// Now try using our custom formatter to generate the description using the Description property.
// Using our custom formatter will now produce different text saying "Fortnightly" instead of
// the standard "Every 2 weeks"
var formatter = new CustomFormatter(DateTime.Now);
// there are three options when using the formatter:
// 1) handle the description changed event, which will be fired each time a schedule
// accepts the formatter (good for looping over lists of schedules), or
// 2) if it's only called for one schedule, use formatter.Description after it's been
// accepted as this property will have the last Description generated, or
// 3) call formatter.Format() if you know the type of your schedule object.
formatter.DescriptionChanged += (sender, args) =>
{
Console.WriteLine(args.Text);
};
// visiting the schedule with the formatter will fire the DescriptionChanged event,
// causing the text output to be printed to the console.
schedule.Accept(formatter);
// we'll reuse this formatter
return formatter;
}