本文整理汇总了C#中CalendarService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.Get方法的具体用法?C# CalendarService.Get怎么用?C# CalendarService.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CalendarService
的用法示例。
在下文中一共展示了CalendarService.Get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
// This handler is called whenever a file ending
// in .sample is requested. A file with that extension
// does not need to exist.
// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("google_calendar");
string key = Request.Url.Segments[Request.Url.Segments.Length - 1].Split(Char.Parse("."))[0];
if (!Urls.ContainsKey(key))
return;
var url = Urls[key];
try
{
var calendar = myService.Get(url);
var entries = from entry in calendar.Feed.Entries
select entry as EventEntry;
Response.Clear();
Response.ContentType = "text/xml";
XDocument document;
if (entries.Count() == 0)
{
document = new XDocument(
new XDeclaration("1.0", "utf-8", null),
new XElement("rss",
new XElement("channel",
new XElement("title", String.Format("Lone Star High School - {0} Calendar", key.ToUpper())),
new XElement("link", url),
new XElement("description", "Real RSS version of a Google Calendar feed as they obviously don't know how to build one"),
new XAttribute("version", "2.0"))));
}
else
{
document = new XDocument(
new XDeclaration("1.0", "utf-8", null),
new XElement("rss",
new XElement("channel",
new XElement("title", String.Format("Lone Star High School - {0} Calendar", key.ToUpper())),
new XElement("link", url),
new XElement("description", "Real RSS version of a Google Calendar feed as they obviously don't know how to build one"),
from entry in entries
where entry.Times.Count > 0
orderby entry.Times[0].StartTime
select new XElement("item",
new XElement("title", entry.Title.Text),
new XElement("description", entry.Content.Content),
new XElement("pubDate", entry.Times[0].StartTime.ToString("ddd, dd MMM yyyy H:mm:ss K")),
new XElement("link", entry.Links[0].HRef.Content)
),
new XAttribute("version", "2.0"))));
}
document.Save(Response.Output);
}
catch { }
}