+2010-01-20 Marek Habersack <mhabersack@novell.com>
+
+ * ObjectStateFormatter.cs: implemented support for IndexedString
+ on top of the existing StringFormatter.
+
+ * IndexedString.cs: implemented
+
2009-12-22 Marek Habersack <mhabersack@novell.com>
* Page.cs: form javascript declaration block is rendered only if
// Gonzalo Paniagua (gonzalo@ximian.com)
//
// (C) 2003 Ben Maurer
-// (c) Copyright 2004-2008 Novell, Inc. (http://www.novell.com)
+// (c) Copyright 2004-2010 Novell, Inc. (http://www.novell.com)
//
//
#region Object Readers/Writers
- class WriterContext
+ sealed class WriterContext
{
Hashtable cache;
short nextKey = 0;
}
}
- class ReaderContext
+ sealed class ReaderContext
{
ArrayList cache;
new ObjectArrayFormatter ().Register ();
new UnitFormatter ().Register ();
new FontUnitFormatter ().Register ();
-
+ new IndexedStringFormatter ().Register ();
new ColorFormatter ().Register ();
enumFormatter = new EnumFormatter ();
get { return 2; }
}
}
+
+ class IndexedStringFormatter : StringFormatter
+ {
+ protected override void Write (BinaryWriter w, object o, WriterContext ctx)
+ {
+ IndexedString s = o as IndexedString;
+
+ if (s == null)
+ throw new InvalidOperationException ("object is not of the IndexedString type");
+
+ base.Write (w, s.Value, ctx);
+ }
+
+ protected override object Read (byte token, BinaryReader r, ReaderContext ctx)
+ {
+ string s = base.Read (token, r, ctx) as string;
+ if (String.IsNullOrEmpty (s))
+ throw new InvalidOperationException ("string must not be null or empty.");
+
+ return new IndexedString (s);
+ }
+
+ protected override Type Type {
+ get { return typeof (IndexedString); }
+ }
+
+ protected override int NumberOfIds {
+ get { return 2; }
+ }
+ }
class Int64Formatter : ObjectFormatter
{