当前位置: 首页>>代码示例>>C#>>正文


C# CalendarService.Get方法代码示例

本文整理汇总了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 { }
    }
开发者ID:ChrisKoenig,项目名称:LSHS,代码行数:62,代码来源:CalendarFeedHandler.cs


注:本文中的CalendarService.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。