2010-01-20 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Wed, 20 Jan 2010 17:48:49 +0000 (17:48 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 20 Jan 2010 17:48:49 +0000 (17:48 -0000)
* ObjectStateFormatter.cs: implemented support for IndexedString
on top of the existing StringFormatter.

* IndexedString.cs: implemented

svn path=/trunk/mcs/; revision=149919

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/IndexedString.cs
mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs

index 76fd19e6b35b20c1224c9e47e26dc74873409971..cb8821b2d9baff0356cc641a7a409b068eb9ad3a 100644 (file)
@@ -1,3 +1,10 @@
+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
index 24441fee8ef1eb6c50aff901f92230ba10375959..da40d236cae2f6668cedd9cc29fec353318bbdfa 100644 (file)
@@ -29,6 +29,8 @@
 //
 
 #if NET_2_0
+using System;
+
 namespace System.Web.UI
 {
        [SerializableAttribute]
@@ -36,10 +38,16 @@ namespace System.Web.UI
        {
                public IndexedString (string s)
                {
-                       throw new NotImplementedException ();
+                       if (String.IsNullOrEmpty (s))
+                               throw new ArgumentNullException ("s");
+                       
+                       Value = s;
                }
                
-               public string Value { get { throw new NotImplementedException (); } }
+               public string Value {
+                       get;
+                       private set;
+               }
        }
 }
 #endif
index 9b130e05285f56f3494504f7878e3daca106b568..dad5412b1c66a1e3b9deede5da90a4177b98131a 100644 (file)
@@ -6,7 +6,7 @@
 //     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)
 //
 
 //
@@ -254,7 +254,7 @@ namespace System.Web.UI {
 
 #region Object Readers/Writers
                
-               class WriterContext
+               sealed class WriterContext
                {
                        Hashtable cache;
                        short nextKey = 0;
@@ -286,7 +286,7 @@ namespace System.Web.UI {
                        }
                }
                
-               class ReaderContext
+               sealed class ReaderContext
                {
                        ArrayList cache;
                        
@@ -331,7 +331,7 @@ namespace System.Web.UI {
                                new ObjectArrayFormatter ().Register ();
                                new UnitFormatter ().Register ();
                                new FontUnitFormatter ().Register ();
-                               
+                               new IndexedStringFormatter ().Register ();
                                new ColorFormatter ().Register ();
 
                                enumFormatter = new EnumFormatter ();
@@ -532,6 +532,36 @@ namespace System.Web.UI {
                                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
                {