Permalink
Browse files

we now handle collections with more than 10 entries. also doesn't ser…

…ialise statics

git-svn-id: http://extreme.googlecode.com/svn/trunk@46 c6ad49c3-dc33-0410-8d8f-25f6e8382c60
  • Loading branch information...
srshti
srshti committed Apr 15, 2008
1 parent 870eda9 commit fdd8ad3210d9af8c5959c07b01c6f5e5008c5fe0
@@ -3,5 +3,7 @@
namespace xstream {
public class ConversionException : Exception {
public ConversionException(string message) : base(message) {}
+
+ public ConversionException(string message, Exception innerException) : base(message, innerException) {}
}
}
@@ -6,11 +6,17 @@ namespace xstream {
public class MiscellaneousTest : ConverterTestCase {
[Test]
public void DoesntSerialiseConstants() {
- Assert.AreEqual(false, xstream.ToXml(new ObjectWithConstant()).Contains(ObjectWithConstant.constant));
+ Assert.AreEqual(false, xstream.ToXml(new ObjectWithConstantAndStatic()).Contains(ObjectWithConstantAndStatic.constant));
}
- private class ObjectWithConstant {
+ [Test]
+ public void DoesntSerialiseStatics() {
+ Assert.AreEqual(false, xstream.ToXml(new ObjectWithConstantAndStatic()).Contains(ObjectWithConstantAndStatic.stat));
+ }
+
+ private class ObjectWithConstantAndStatic {
public const string constant = "Some stupid constant";
+ public static readonly string stat = "Some stupid static";
}
}
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Reflection;
using xstream.Converters;
@@ -62,7 +63,12 @@ public class UnmarshallingContext {
}
public void StackObject(object value) {
- alreadyDeserialised.Add(reader.CurrentPath, value);
+ try {
+ alreadyDeserialised.Add(reader.CurrentPath, value);
+ }
+ catch (ArgumentException e) {
+ throw new ConversionException("Couldn't add " + reader.CurrentPath, e);
+ }
}
public object Find() {
@@ -71,4 +77,4 @@ public class UnmarshallingContext {
return null;
}
}
-}
+}
@@ -19,7 +19,7 @@ internal class XmlStack {
public void Push(string node) {
if (justPopped.Equals(node)) node = node + "[1]";
- Match match = Regex.Match(justPopped, node + @"\[(\d)\]");
+ Match match = Regex.Match(justPopped, node + @"\[(\d+)\]");
if (match.Success) node = node + "[" + (int.Parse(match.Result("$1")) + 1) + "]";
nodes.Push(node);
}

0 comments on commit fdd8ad3

Please sign in to comment.