如何使用 DayOfWeek 枚举来标记流程周期?
在 app.config 中,我提供了一个cycle字符串值:“Monday”、“Tuesday”、...、“Daily”。我想根据该值分配一个
枚举。仅使用 DayOfWeek
并不能让我将流程标记为日常工作。是否有可用的 .Net 类提供星期几作为标志?
与此同时,我设计了以下内容:
<Flags()> _
Public Enum enumExportCycle As Integer
Monday = DayOfWeek.Monday
Tuesday = DayOfWeek.Tuesday
Wednesday = DayOfWeek.Wednesday + 1
Thursday = DayOfWeek.Thursday + 4
Friday = DayOfWeek.Friday + 11
Saturday = DayOfWeek.Saturday + 26
Sunday = DayOfWeek.Sunday + 64
Daily = Monday Or Tuesday Or Wednesday Or Thursday Or Friday Or Saturday Or Sunday
End Enum
感觉有点hackish,我正在寻找更好的方法。
In app.config, I supply a cycle string value: "Monday", "Tuesday", ..., "Daily". From that value I wanted to assign a <Flags()>
enum. Simply using DayOfWeek
does not give me the ability to flag a process as a daily routine. Is there an available .Net class that does provide the day of week as a flag?
In the meantime, I devised the following:
<Flags()> _
Public Enum enumExportCycle As Integer
Monday = DayOfWeek.Monday
Tuesday = DayOfWeek.Tuesday
Wednesday = DayOfWeek.Wednesday + 1
Thursday = DayOfWeek.Thursday + 4
Friday = DayOfWeek.Friday + 11
Saturday = DayOfWeek.Saturday + 26
Sunday = DayOfWeek.Sunday + 64
Daily = Monday Or Tuesday Or Wednesday Or Thursday Or Friday Or Saturday Or Sunday
End Enum
It feels somewhat hackish and I am looking for a better way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 Windows Mobile 上 PocketOutlook 的 DaysOfWeek 枚举(用于设置重复次数)的链接:
http://msdn.microsoft.com/en-us /library/microsoft.windowsmobile.pocketoutlook.daysofweek.aspx
它定义了一个这样的枚举:
我会为 Daily 定义一个类似的枚举,并附加一个枚举(也许每个工作日和每个周末:
Here is a link to a DaysOfWeek enum (used for setting recurrences) for PocketOutlook on Windows Mobile:
http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.daysofweek.aspx
It defines an enum like this:
I would define a similar enum with an additional one for Daily (and maybe for every weekday and every weekend day:
这会起作用,对吧?
或
DayOfWeek 从 0(星期日)到 6(星期六)开始
this will work, right?
or this
since DayOfWeek start from 0 (Sunday) to 6 (Saturday)