本文整理汇总了C#中Interval.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Interval.Select方法的具体用法?C# Interval.Select怎么用?C# Interval.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interval
的用法示例。
在下文中一共展示了Interval.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCode
/// <summary>
/// Generates a code containing all intervals in a list of intervals of DateTimes.
/// </summary>
/// <param name="allIntervals"> The intervals to generate code for. </param>
/// <param name="varName"> The variable name to use. </param>
/// <returns> Returns the generated code for the data. </returns>
public static string GenerateCode(Interval<DateTime>[] allIntervals, string varName)
{
var dateToStr = (Func<DateTime, string>)(d => d == default(DateTime) ? "default(DateTime)" : d.ToString("'new DateTime('yyyy', 'MM', 'dd', 'HH', 'mm', 'ss')'"));
var str = string.Format(
@"
#region {0} = ...
// the following snapshot was generated from a good result using the method GenerateCode(""{0}"")
var {0} = new []
{{",
varName) + string.Join(
@",
",
allIntervals.Select(
i => string.Format(
@"
// {5}
new Interval<DateTime>({0}, PointState.{1}, {2}, PointState.{3}, isPositive: {4})",
dateToStr(i.Start),
i.StartState,
dateToStr(i.End),
i.EndState,
i.IsPositive ? "true" : "false",
i))) + @"
};
#endregion
";
return str;
}