Author: fmantek
Date: Wed Sep 19 23:06:07 2007
New Revision: 260
Modified:
trunk/clients/cs/src/core/service.cs
trunk/clients/cs/src/extensions/simpleelement.cs
trunk/clients/cs/src/gcalendar/calendarentry.cs
trunk/clients/cs/src/gcalendar/eventfeed.cs
Log:
More simplification for the Calendar (courtesy of Jeff Fisher)
Modified: trunk/clients/cs/src/core/service.cs
==============================================================================
--- trunk/clients/cs/src/core/service.cs (original)
+++ trunk/clients/cs/src/core/service.cs Wed Sep 19 23:06:07 2007
@@ -213,7 +213,17 @@
this.Credentials = new GDataCredentials(username, password);
}
-
+ /// <summary>
+ /// Returns a single Atom entry based upon its unique URI.
+ /// </summary>
+ /// <param name="entryUri">The URI of the Atom entry.</param>
+ /// <returns>AtomEntry representing the entry.</returns>
+ public AtomEntry Get(string entryUri)
+ {
+ FeedQuery query = new FeedQuery(entryUri);
+ AtomFeed resultFeed = Query(query);
+ return resultFeed.Entries[0];
+ }
@@ -499,8 +509,10 @@
/// double buffering/copying of the bytes
/// </summary>
/// <param name="targetUri"></param>
- /// <param name="payload"></param>
/// <param name="type"></param>
- /// <returns>Stream</returns>
+ /// <param name="payload"></param>
+ /// <param name="type"></param>
+ /// <returns>Stream</returns>
+
public Stream StringSend(Uri targetUri, String payload,
GDataRequestType type)
{
Tracing.Assert(targetUri != null, "targetUri should not be null");
@@ -541,7 +553,8 @@
/// <param name="type"></param>
/// <param name="contentType">the contenttype to use in the request,
if NULL is passed, factory default is used</param>
/// <param name="slugHeader">the slugHeader to use in the request, if
NULL is passed, factory default is used</param>
- /// <returns>Stream</returns>
+ /// <returns>Stream</returns>
+
public Stream StreamSend(Uri targetUri,
Stream inputStream,
GDataRequestType type,
Modified: trunk/clients/cs/src/extensions/simpleelement.cs
==============================================================================
--- trunk/clients/cs/src/extensions/simpleelement.cs (original)
+++ trunk/clients/cs/src/extensions/simpleelement.cs Wed Sep 19 23:06:07 2007
@@ -138,12 +138,17 @@
// memberwise close is fine here, as everything is identical
beside the value
e = this.MemberwiseClone() as SimpleElement;
e.InitInstance(this);
- e.Value = node.InnerText;
-
- if (node.Attributes != null)
+
+ if (node != null)
{
- e.ProcessAttributes(node);
+ e.Value = node.InnerText;
+
+ if (node.Attributes != null)
+ {
+ e.ProcessAttributes(node);
+ }
}
+
return e;
}
@@ -178,7 +183,7 @@
/// <param name="prefix">the xml prefix</param>
/// <param name="ns">the xml namespace</param>
protected SimpleAttribute(string name, string prefix, string ns)
- :base(name, prefix,ns)
+ :base(name, prefix, ns)
{
this.Attributes.Add(BaseNameTable.XmlValue, null);
}
@@ -199,12 +204,18 @@
}
//////////////////////////////////////////////////////////////////////
- /// <summary>read only accessor</summary>
+ /// <summary>Accessor for "value" attribute.</summary>
/// <returns> </returns>
//////////////////////////////////////////////////////////////////////
public override string Value
{
- get {return this.Attributes[BaseNameTable.XmlValue] as string;}
+ get {
+ return this.Attributes[BaseNameTable.XmlValue] as string;
+ }
+ set
+ {
+ this.Attributes[BaseNameTable.XmlValue] = value;
+ }
}
// end of accessor public string Value
}
Modified: trunk/clients/cs/src/gcalendar/calendarentry.cs
==============================================================================
--- trunk/clients/cs/src/gcalendar/calendarentry.cs (original)
+++ trunk/clients/cs/src/gcalendar/calendarentry.cs Wed Sep 19 23:06:07 2007
@@ -49,10 +49,10 @@
/// Basic method for retrieving Calendar extension elements.
/// </summary>
/// <param name="extension">The name of the extension element to look
for</param>
- /// <returns>SimpleElement, or NULL if the extension was not
found</returns>
- public SimpleElement getCalendarExtension(string extension)
+ /// <returns>SimpleAttribute, or NULL if the extension was not
found</returns>
+ public SimpleAttribute getCalendarExtension(string extension)
{
- return FindExtension(extension, GDataParserNameTable.NSGCal) as
SimpleElement;
+ return FindExtension(extension, GDataParserNameTable.NSGCal) as
SimpleAttribute;
}
/// <summary>
@@ -62,10 +62,10 @@
/// <returns>value as string, or NULL if the extension was not
found</returns>
public string getCalendarExtensionValue(string extension)
{
- SimpleElement e = getCalendarExtension(extension);
+ SimpleAttribute e = getCalendarExtension(extension);
if (e != null)
{
- return (string) e.Attributes["value"];
+ return (string) e.Value;
}
return null;
}
@@ -76,7 +76,7 @@
/// </summary>
/// <param name="extension">the name of the extension to look
for</param>
/// <param name="newValue">the new value for this extension
element</param>
- /// <returns>SimpleElement, either a brand new one, or the one
+ /// <returns>SimpleAttribute, either a brand new one, or the one
/// returned by the service</returns>
public SimpleElement setCalendarExtension(string extension, string
newValue)
{
@@ -85,20 +85,14 @@
throw new System.ArgumentNullException("extension");
}
- SimpleElement ele = getCalendarExtension(extension);
+ SimpleAttribute ele = getCalendarExtension(extension);
if (ele == null)
{
- ele = CreateExtension(extension, GDataParserNameTable.NSGCal)
as SimpleElement;
+ ele = CreateExtension(extension, GDataParserNameTable.NSGCal)
as SimpleAttribute;
this.ExtensionElements.Add(ele);
}
- if (ele.Attributes.ContainsKey("value"))
- {
- ele.Attributes["value"] = newValue;
- }
- else
- {
- ele.Attributes.Add("value", newValue);
- }
+
+ ele.Value = newValue;
return ele;
}
@@ -159,78 +153,110 @@
return
getCalendarExtensionValue(GDataParserNameTable.XmlAccessLevelElement);
}
}
+
+ /// <summary>
+ /// This field controls the time zone of the calendar.
+ /// </summary>
+ public string TimeZone
+ {
+ get
+ {
+ return
getCalendarExtensionValue(GDataParserNameTable.XmlTimeZoneElement);
+ }
+ set
+ {
+ setCalendarExtension(GDataParserNameTable.XmlTimeZoneElement,
value);
+ }
+ }
+
+ /// <summary>
+ /// This field controls the location of the calendar.
+ /// </summary>
+ public Where Location
+ {
+ get
+ {
+ return FindExtension(GDataParserNameTable.XmlWhereElement,
+ GDataParserNameTable.NSGCal) as Where;
+ }
+ set
+ {
+ ReplaceExtension(GDataParserNameTable.XmlWhereElement,
+ GDataParserNameTable.NSGCal, value);
+ }
+ }
}
/// <summary>
/// Color schema describing a gCal:color
/// </summary>
- public class GCalColor : SimpleElement
+ public class GCalColor : SimpleAttribute
{
public GCalColor()
- : base("color", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlColorElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal)
{
- this.Attributes.Add("value", null);
}
public GCalColor(string initValue)
- : base("color", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlColorElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal, initValue)
{
- this.Attributes.Add("value", initValue);
}
}
/// <summary>
/// Color schema describing a gCal:hidden
/// </summary>
- public class GCalHidden : SimpleElement
+ public class GCalHidden : SimpleAttribute
{
public GCalHidden()
- : base("hidden", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlHiddenElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal)
{
- this.Attributes.Add("value", null);
}
public GCalHidden(string initValue)
- : base("hidden", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlHiddenElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal, initValue)
{
- this.Attributes.Add("value", initValue);
}
}
/// <summary>
/// Color schema describing a gCal:selected
/// </summary>
- public class GCalSelected : SimpleElement
+ public class GCalSelected : SimpleAttribute
{
public GCalSelected()
- : base("selected", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlSelectedElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal)
{
- this.Attributes.Add("value", null);
}
public GCalSelected(string initValue)
- : base("selected", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlSelectedElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal, initValue)
{
- this.Attributes.Add("value", initValue);
}
}
/// <summary>
/// Color schema describing a gCal:accesslevel
/// </summary>
- public class GCalAccessLevel : SimpleElement
+ public class GCalAccessLevel : SimpleAttribute
{
public GCalAccessLevel()
- : base("accesslevel", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlAccessLevelElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal)
{
- this.Attributes.Add("value", null);
}
public GCalAccessLevel(string initValue)
- : base("accesslevel", GDataParserNameTable.gCalPrefix,
GDataParserNameTable.NSGCal)
+ : base(GDataParserNameTable.XmlAccessLevelElement,
GDataParserNameTable.gCalPrefix,
+ GDataParserNameTable.NSGCal, initValue)
{
- this.Attributes.Add("value", initValue);
}
}
}
Modified: trunk/clients/cs/src/gcalendar/eventfeed.cs
==============================================================================
--- trunk/clients/cs/src/gcalendar/eventfeed.cs (original)
+++ trunk/clients/cs/src/gcalendar/eventfeed.cs Wed Sep 19 23:06:07 2007
@@ -37,24 +37,13 @@
}
/// <summary>
- /// defaull constructor with an initial value for the attribute
+ /// default constructor with an initial value for the attribute
/// </summary>
/// <param name="initValue"></param>
public TimeZone(string initValue)
: base(GDataParserNameTable.XmlTimeZoneElement,
GDataParserNameTable.gCalPrefix, GDataParserNameTable.NSGCal, initValue)
{
}
-
- //////////////////////////////////////////////////////////////////////
- /// <summary>saves the current object into the stream. TimeZone,
- /// though does not get saved</summary>
- /// <param name="writer">xmlWriter to write into</param>
- //////////////////////////////////////////////////////////////////////
- public override void Save(XmlWriter writer)
- {
- Tracing.TraceMsg("Save called on TimeZone... skipping it");
- return;
- }
}
@@ -65,8 +54,6 @@
//////////////////////////////////////////////////////////////////////
public class EventFeed : AbstractFeed
{
-
- private TimeZone timezone;
/// <summary>
/// default constructor
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---