diff options
author | Marek Habersack <grendel@twistedcode.net> | 2010-01-20 20:48:49 +0300 |
---|---|---|
committer | Marek Habersack <grendel@twistedcode.net> | 2010-01-20 20:48:49 +0300 |
commit | 4083fbfc3f53d15baba995bf80739596645dc05c (patch) | |
tree | 12fe25633bb08662730507f4b7ee285998c6f048 /mcs | |
parent | aa6b3d979e54f4f4ab30430a2ddd6c41605d115c (diff) |
2010-01-20 Marek Habersack <mhabersack@novell.com>
* ObjectStateFormatter.cs: implemented support for IndexedString
on top of the existing StringFormatter.
* IndexedString.cs: implemented
svn path=/trunk/mcs/; revision=149919
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/System.Web/System.Web.UI/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.Web/System.Web.UI/IndexedString.cs | 12 | ||||
-rw-r--r-- | mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs | 38 |
3 files changed, 51 insertions, 6 deletions
diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 76fd19e6b35..cb8821b2d9b 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -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 diff --git a/mcs/class/System.Web/System.Web.UI/IndexedString.cs b/mcs/class/System.Web/System.Web.UI/IndexedString.cs index 24441fee8ef..da40d236cae 100644 --- a/mcs/class/System.Web/System.Web.UI/IndexedString.cs +++ b/mcs/class/System.Web/System.Web.UI/IndexedString.cs @@ -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 diff --git a/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs b/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs index 9b130e05285..dad5412b1c6 100644 --- a/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs +++ b/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs @@ -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 { |