Windows Phone 7 - iCal 生成器 - C#

发布于 2024-11-26 05:43:06 字数 201 浏览 0 评论 0原文

我需要根据从设备获取的约会生成 iCal 字符串。 Windows Phone 7 上是否有支持从约会生成 iCal 的库?

我尝试了 DDay.iCal,但它不适用于 Windows Phone 7。

I need to generate iCal string from appointments fetched from device. Is there any library that is supported on Windows Phone 7 to generate iCal from appointments?

I tried DDay.iCal, but it does not work with Windows Phone 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别把无礼当个性 2024-12-03 05:43:06

我没有遇到过专门针对 Windows Phone 7 的库,但编写自己的类来生成 iCal 文件应该不会太困难,因为毕竟 iCal 只是文本。 RFC 内容相当密集,但使用了一些在线参考喜欢这个并查看一些示例 iCal 文件应该足以开始。以 wikipedia 中的 iCal 文件为例:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:[email protected]
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

因此请注意,您开始和结束 VCALENDAR,以及其中的 VEVENT,其中包含一些必填字段(如 UID)。唯一需要注意的是,规范要求将超过 75 个八位字节的行进行分解,因此您可以使用 此堆栈溢出中的方法对于长文本字段的问题:

Private Function RFC2445TextField(ByVal LongText As String) As String

     LongText = LongText.Replace("\", "\\")
     LongText = LongText.Replace(";", "\;")
     LongText = LongText.Replace(",", "\,")


     Dim sBuilder As New StringBuilder
     Dim charArray() As Char = LongText.ToCharArray

     For i = 1 To charArray.Length
         sBuilder.Append(charArray(i - 1))
         If i Mod 74 = 0 Then sBuilder.Append(vbCrLf & " ")
     Next

     Return sBuilder.ToString

 End Function

该函数基本上转义所有必需的转义字符,并每 74 个字符插入一个换行符/空格。

祝你好运,玩得开心! :)

There isn't a library specific for Windows Phone 7 I've come across, but it shouldn't be too difficult to write your own classes to generate iCal files, since iCal is just text, after all. The RFC is quite a dense read, but using some online references like this one and looking at some example iCal files should be enough to get started. Take this example iCal file from wikipedia, for example:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:[email protected]
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

So note you BEGIN and END a VCALENDAR, and a VEVENT within them, which has some required fields (like the UID). The only thing to note is that the specification requires lines longer than 75 octets to be broken up, so you can use this method from this stack overflow question for fields with long text:

Private Function RFC2445TextField(ByVal LongText As String) As String

     LongText = LongText.Replace("\", "\\")
     LongText = LongText.Replace(";", "\;")
     LongText = LongText.Replace(",", "\,")


     Dim sBuilder As New StringBuilder
     Dim charArray() As Char = LongText.ToCharArray

     For i = 1 To charArray.Length
         sBuilder.Append(charArray(i - 1))
         If i Mod 74 = 0 Then sBuilder.Append(vbCrLf & " ")
     Next

     Return sBuilder.ToString

 End Function

The function basically escapes all required escape characters, and inserts a linefeed/space every 74 characters.

Good luck, have fun! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文