[PATCH] XML serialization support for CluePacket, Clue



The attached patch adds XML serialization support for the CluePacket and
Clue classes.  This allows a backend to capture Clues in a form that can
be replayed later.

We could also use deserialization to load the clue objects in
Server::HandleBuffer instead of the current XPath implementation, though
I don't see any compelling reason to do so at this point.

Peter
Index: Clue.cs
===================================================================
RCS file: /cvs/gnome/dashboard/engine/Clue.cs,v
retrieving revision 1.15
diff -u -r1.15 Clue.cs
--- Clue.cs	16 Feb 2004 20:12:13 -0000	1.15
+++ Clue.cs	20 Feb 2004 01:42:36 -0000
@@ -10,31 +10,42 @@
 
 using System;
 using System.Collections;
+using System.Xml.Serialization;
 
 namespace Dashboard {
 
 	public class Clue : ICloneable {
 
 		// See doc/cluetypes.txt
+		[XmlAttribute("Type")]
 		public readonly string Type;
 
 		// The text of the clue
+		[XmlText()]
 		public readonly string Text;
 
 		// The relevance of the clue to what the user's doing (1-10)
+		[XmlAttribute("Relevance")]
 		public readonly int Relevance;
 
 		// True if from a frontend CP, not true if from a cluechain
+		[XmlIgnore()]
 		public bool Toplevel = false;
 
 		// If cluechained from a match, contains the match
 		// that triggered this clue
+		[XmlIgnore()]
 		public Match TriggeringMatch;
 
 		// If cluechained directly from clues, contains the
 		// clues that triggered this one
+		[XmlIgnore()]
 		public ArrayList TriggeringClues = null;
 
+		public Clue ()
+		{
+		}
+
 		public Clue (string type, string text, int relevance, params Clue[] triggering_clues)
 		{
 			this.Type           = type;
Index: CluePacket.cs
===================================================================
RCS file: /cvs/gnome/dashboard/engine/CluePacket.cs,v
retrieving revision 1.19
diff -u -r1.19 CluePacket.cs
--- CluePacket.cs	16 Feb 2004 18:53:50 -0000	1.19
+++ CluePacket.cs	20 Feb 2004 01:42:36 -0000
@@ -11,6 +11,7 @@
 
 using System;
 using System.Collections;
+using System.Xml.Serialization;
 
 namespace Dashboard {
 	public delegate void CluePacketNotifyDelegate (CluePacket m);
@@ -30,8 +31,14 @@
 		// The Xid generatign this cluepacket
 		public readonly int Xid;
 
+		[XmlElement(ElementName="Clue",
+			    Type=typeof(Clue))]
 		public ArrayList Clues = new ArrayList ();
 
+		public CluePacket ()
+		{
+		}
+
 		public CluePacket (CluePacket parent) 
 			: this (parent.Frontend, parent.Context, parent.Focused, parent.Xid)
 	        {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]