Author: fmantek
Date: Thu Sep 20 02:50:00 2007
New Revision: 263

Modified:
   trunk/clients/cs/RELEASE_NOTES.HTML
   trunk/clients/cs/src/core/atombase.cs
   trunk/clients/cs/src/core/atomfeed.cs
   trunk/clients/cs/src/core/atomfeedentry.cs
   trunk/clients/cs/src/core/atomfeedparser.cs
   trunk/clients/cs/src/gcalendar/evententry.cs

Log:
Added the ability to create custom AtomBase subclassed objects to 
        custom feeds/entries. Look at CreateAtomSubElement() in AtomBase. This
        is used to create custom clases like WebContentLink in the derived 
        services

Modified: trunk/clients/cs/RELEASE_NOTES.HTML
==============================================================================
--- trunk/clients/cs/RELEASE_NOTES.HTML (original)
+++ trunk/clients/cs/RELEASE_NOTES.HTML Thu Sep 20 02:50:00 2007
@@ -111,6 +111,12 @@
         are represented as "True"/"False" in .NET, and xsd requires 
         "true"/"false" this helper takes care of that conversion.
         </li>
+    <li>Added the ability to create custom AtomBase subclassed objects to 
+        custom feeds/entries. Look at CreateAtomSubElement() in AtomBase. This
+        is used to create custom clases like WebContentLink in the derived 
+        services</li>
+
+
 </ul>
 
 <h2>1.0.9.9</h2>

Modified: trunk/clients/cs/src/core/atombase.cs
==============================================================================
--- trunk/clients/cs/src/core/atombase.cs       (original)
+++ trunk/clients/cs/src/core/atombase.cs       Thu Sep 20 02:50:00 2007
@@ -485,13 +485,28 @@
         /// <param name="localName">the local name to find</param>
         /// <param name="ns">the namespace to match, if null, ns is 
ignored</param>
         /// <param name="obj">the new element to put in</param>
-        public void ReplaceExtension(string localName, string ns, Object obj)
+        public void ReplaceExtension
+            (string localName, string ns, Object obj)
         {
             DeleteExtensions(localName, ns);
             this.ExtensionElements.Add(obj);
         }
 
 
+        /// <summary>
+        /// this is the subclassing method for AtomBase derived 
+        /// classes to overload what childelements should be created
+        /// needed to create CustomLink type objects, like WebContentLink etc
+        /// </summary>
+        /// <param name="reader">The XmlReader that tells us what we are 
working with</param>
+        /// <param name="parser">the parser is primarily used for nametable 
comparisons</param>
+        /// <returns>AtomBase</returns>
+        public virtual AtomBase CreateAtomSubElement(XmlReader reader, 
AtomFeedParser parser)
+
+        {
+            throw new NotImplementedException("AtomBase CreateChild should 
NEVER be called" + reader.LocalName);
+            return null;
+        }
 
     
         //////////////////////////////////////////////////////////////////////

Modified: trunk/clients/cs/src/core/atomfeed.cs
==============================================================================
--- trunk/clients/cs/src/core/atomfeed.cs       (original)
+++ trunk/clients/cs/src/core/atomfeed.cs       Thu Sep 20 02:50:00 2007
@@ -190,6 +190,24 @@
         
/////////////////////////////////////////////////////////////////////////////
 
 
+         /// <summary>
+        /// this is the subclassing method for AtomBase derived 
+        /// classes to overload what childelements should be created
+        /// needed to create CustomLink type objects, like WebContentLink etc
+        /// </summary>
+        /// <param name="reader">The XmlReader that tells us what we are 
working with</param>
+        /// <param name="parser">the parser is primarily used for nametable 
comparisons</param>
+        /// <returns>AtomBase</returns>
+        public override AtomBase CreateAtomSubElement(XmlReader reader, 
AtomFeedParser parser)
+        {
+            Object localname = reader.LocalName;
+
+            if ((localname.Equals(parser.Nametable.Link)))
+            {
+                return new AtomLink();
+            } 
+            return base.CreateAtomSubElement(reader, parser);
+        }
 
         //////////////////////////////////////////////////////////////////////
         /// <summary>tries to determine if the two feeds derive from the same 
source</summary> 

Modified: trunk/clients/cs/src/core/atomfeedentry.cs
==============================================================================
--- trunk/clients/cs/src/core/atomfeedentry.cs  (original)
+++ trunk/clients/cs/src/core/atomfeedentry.cs  Thu Sep 20 02:50:00 2007
@@ -813,6 +813,31 @@
 
         #endregion
 
+
+        /// <summary>
+        /// this is the subclassing method for AtomBase derived 
+        /// classes to overload what childelements should be created
+        /// needed to create CustomLink type objects, like WebContentLink etc
+        /// </summary>
+        /// <param name="reader">The XmlReader that tells us what we are 
working with</param>
+        /// <param name="parser">the parser is primarily used for nametable 
comparisons</param>
+        /// <returns>AtomBase</returns>
+        public override AtomBase CreateAtomSubElement(XmlReader reader, 
AtomFeedParser parser)
+        {
+            Object localname = reader.LocalName;
+
+            if ((localname.Equals(parser.Nametable.Link)))
+            {
+                return new AtomLink();
+            } else if (localname.Equals(parser.Nametable.Source))
+            {
+                return new AtomSource();
+            }
+            return base.CreateAtomSubElement(reader, parser);
+            
+        }
+
+
         #region overloaded for property changes, xml:base
         //////////////////////////////////////////////////////////////////////
         /// <summary>just go down the child collections</summary> 

Modified: trunk/clients/cs/src/core/atomfeedparser.cs
==============================================================================
--- trunk/clients/cs/src/core/atomfeedparser.cs (original)
+++ trunk/clients/cs/src/core/atomfeedparser.cs Thu Sep 20 02:50:00 2007
@@ -64,6 +64,10 @@
         }
         
/////////////////////////////////////////////////////////////////////////////
 
+        public AtomParserNameTable Nametable
+        {
+            get { return this.nameTable; }
+        }
 
         //////////////////////////////////////////////////////////////////////
         /// <summary>starts the parsing process</summary> 
@@ -203,7 +207,7 @@
                     {
                         // create the link
                         fSkip = false; 
-                        source.Links.Add(ParseLink(reader)); 
+                        source.Links.Add(ParseLink(reader, source)); 
                     }
                     else if (localname.Equals(this.nameTable.Id))
                     {
@@ -576,7 +580,7 @@
         /// <param name="reader">correctly positioned xmlreader</param>
         /// <returns> the created AtomLink object</returns>
         //////////////////////////////////////////////////////////////////////
-        protected AtomLink ParseLink(XmlReader reader)
+        protected AtomLink ParseLink(XmlReader reader, AtomBase parent)
         {
             Tracing.Assert(reader != null, "reader should not be null");
             if (reader == null)
@@ -584,12 +588,11 @@
                 throw new ArgumentNullException("reader"); 
             }
 
-
             Tracing.TraceCall();
-            AtomLink link = null;
+
+            AtomLink link = parent.CreateAtomSubElement(reader, this) as 
AtomLink;
             object localname = null;
 
-            link = new AtomLink();
             if (reader.HasAttributes)
             {
                 while (reader.MoveToNextAttribute())
@@ -678,7 +681,7 @@
                     else if (localname.Equals(this.nameTable.Link))
                     {
                         fSkip = false; 
-                        entry.Links.Add(ParseLink(reader)); 
+                        entry.Links.Add(ParseLink(reader, entry)); 
                     }
                     else if (localname.Equals(this.nameTable.Updated))
                     {
@@ -715,7 +718,7 @@
                     }
                     else if (localname.Equals(this.nameTable.Source))
                     {
-                        entry.Source = new AtomSource();
+                        entry.Source = entry.CreateAtomSubElement(reader, 
this) as AtomSource;
                         ParseSource(reader, entry.Source);
                     }
                     else if (localname.Equals(this.nameTable.Title))

Modified: trunk/clients/cs/src/gcalendar/evententry.cs
==============================================================================
--- trunk/clients/cs/src/gcalendar/evententry.cs        (original)
+++ trunk/clients/cs/src/gcalendar/evententry.cs        Thu Sep 20 02:50:00 2007
@@ -728,6 +728,27 @@
 
 #endregion
 
+        /// <summary>
+        /// this is the subclassing method for AtomBase derived 
+        /// classes to overload what childelements should be created
+        /// needed to create CustomLink type objects, like WebContentLink etc
+        /// </summary>
+        /// <param name="reader">The XmlReader that tells us what we are 
working with</param>
+        /// <param name="parser">the parser is primarily used for nametable 
comparisons</param>
+        /// <returns>AtomBase</returns>
+        public override AtomBase CreateAtomSubElement(XmlReader reader, 
AtomFeedParser parser)
+        {
+            Object localname = reader.LocalName;
+
+            if ((localname.Equals(parser.Nametable.Link)))
+            {
+                // here you could check if you want to create a webcontent and 
return 
+                // an atomLink subclass.
+                return new AtomLink();
+            }
+            return base.CreateAtomSubElement(reader, parser);
+            
+        }
      
 
 #region Event Parser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to