calendarservice.cs :  » Network-Clients » RemoteCalendars » Google » GData » Calendar » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » RemoteCalendars 
RemoteCalendars » Google » GData » Calendar » calendarservice.cs
/* Copyright (c) 2006 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/


using System;
using System.IO;
using System.Collections;
using System.Text;
using System.Net; 
using Google.GData.Client;
using Google.GData.Extensions;


namespace Google.GData.Calendar{

    /// <summary>
    /// The CalendarService class extends the basic Service abstraction
    /// to define a service that is preconfigured for access to the
    /// Google Calendar data API.
    /// </summary>
    public class CalendarService : Service
    {
        /// <summary>This service's User-Agent string</summary> 
        public const string GCalendarAgent = "GCalendar-CS/1.0.0";
        /// <summary>The Calendar service's name</summary> 
        public const string GCalendarService = "cl";

        /// <summary>
        ///  default constructor
        /// </summary>
        /// <param name="applicationName">the applicationname</param>
        public CalendarService(string applicationName) : base(GCalendarService, applicationName, GCalendarAgent)
        {
            this.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEventEntry);
            this.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewEventExtensionElement);

            // You can set factory.methodOverride = true if you are behind a 
            // proxy that filters out HTTP methods such as PUT and DELETE.
            GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)this.RequestFactory;
            factory.MethodOverride = true;
        }

        /// <summary>
        ///  overwritten Query method
        /// </summary>
        /// <param name="feedQuery">The FeedQuery touse</param>
        /// <returns>the retrieved EventFeed</returns>
        public new EventFeed Query(FeedQuery feedQuery)
        {
            Stream feedStream = Query(feedQuery.Uri);
            EventFeed feed = new EventFeed(feedQuery.Uri, this);
            feed.Parse(feedStream, AlternativeFormat.Atom);
            feedStream.Close(); 
            return feed;
        }

        //////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Event handler. Called when a new event entry is parsed.
        /// </summary>
        /// <param name="sender">the object that's sending the event</param>
        /// <param name="e">FeedParserEventArguments, holds the feedentry</param>
        /// <returns> </returns>
        //////////////////////////////////////////////////////////////////////
        protected void OnParsedNewEventEntry(object sender, FeedParserEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (e.CreatingEntry == true)
            {
                Tracing.TraceMsg("\t top level event dispatcher - new Event Entry");
                e.Entry = new EventEntry();
            }
        }

        //////////////////////////////////////////////////////////////////////
        /// <summary>Event handler. Called for an event extension element.
        /// </summary>
        /// <param name="sender">the object that's sending the event</param>
        /// <param name="e">FeedParserEventArguments, holds the feedentry</param> 
        /// <returns> </returns>
        //////////////////////////////////////////////////////////////////////
        protected void OnNewEventExtensionElement(object sender, ExtensionElementEventArgs e)
        {

            Tracing.TraceCall("received new event extension element notification");
            Tracing.Assert(e != null, "e should not be null");
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            Tracing.TraceMsg("\t top level event = new extension");

            if (String.Compare(e.ExtensionElement.NamespaceURI, BaseNameTable.gNamespace, true) == 0)
            {
                // found G namespace
                Tracing.TraceMsg("\t top level event = new Event extension");
                e.DiscardEntry = true;
                AtomFeedParser parser = sender as AtomFeedParser; 


                if (e.Base.XmlName == AtomParserNameTable.XmlFeedElement)
                {
                    EventFeed eventFeed = e.Base as EventFeed;
                    if (eventFeed != null)
                    {
                        eventFeed.parseEvent(e.ExtensionElement, parser);
                    }
                }
                else if (e.Base.XmlName == AtomParserNameTable.XmlAtomEntryElement)
                {
                    EventEntry eventEntry = e.Base as EventEntry;
                    if (eventEntry != null)
                    {
                        eventEntry.parseEvent(e.ExtensionElement, parser);
                    }
                }
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.