mail-archives/mono-devel-list/2013-June/040537.html

639 строки
25 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [Mono-dev] Serialization TimeZoneInfo class
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-devel-list%40lists.ximian.com?Subject=Re%3A%20%5BMono-dev%5D%20%20Serialization%20TimeZoneInfo%20class&In-Reply-To=%3C51BEBFC2.60608%40etit.tu-chemnitz.de%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="040546.html">
<LINK REL="Next" HREF="040538.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-dev] Serialization TimeZoneInfo class</H1>
<B>Andreas Auerswald</B>
<A HREF="mailto:mono-devel-list%40lists.ximian.com?Subject=Re%3A%20%5BMono-dev%5D%20%20Serialization%20TimeZoneInfo%20class&In-Reply-To=%3C51BEBFC2.60608%40etit.tu-chemnitz.de%3E"
TITLE="[Mono-dev] Serialization TimeZoneInfo class">andreas.auerswald at etit.tu-chemnitz.de
</A><BR>
<I>Mon Jun 17 07:50:26 UTC 2013</I>
<P><UL>
<LI>Previous message: <A HREF="040546.html">[Mono-dev] How to skip building .net 2.0/3.x and build only 4.x?
</A></li>
<LI>Next message: <A HREF="040538.html">[Mono-dev] Serialization TimeZoneInfo class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#40537">[ date ]</a>
<a href="thread.html#40537">[ thread ]</a>
<a href="subject.html#40537">[ subject ]</a>
<a href="author.html#40537">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Hi,
I have implemented the serialization of the TimeZoneInfo class. It is
compatible to the serialization in .Net so cross serialization shouldn't
be a problem. I hope it will be included in the next releases of Mono.
The patch:
diff --git a/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs
b/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs
index d3c16f4..4c413a8 100644
--- a/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs
+++ b/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs
@@ -74,6 +74,17 @@ namespace System
return new AdjustmentRule (dateStart, dateEnd,
daylightDelta, daylightTransitionStart, daylightTransitionEnd);
}
+ private AdjustmentRule (SerializationInfo info,
StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ dateStart = (DateTime) info.GetValue (&quot;DateStart&quot;,
typeof (DateTime));
+ dateEnd = (DateTime) info.GetValue (&quot;DateEnd&quot;, typeof
(DateTime));
+ daylightDelta = (TimeSpan) info.GetValue
(&quot;DaylightDelta&quot;, typeof (TimeSpan));
+ daylightTransitionStart = (TimeZoneInfo.TransitionTime)
info.GetValue (&quot;DaylightTransitionStart&quot;, typeof
(TimeZoneInfo.TransitionTime));
+ daylightTransitionEnd = (TimeZoneInfo.TransitionTime)
info.GetValue (&quot;DaylightTransitionEnd&quot;, typeof
(TimeZoneInfo.TransitionTime));
+ }
+
private AdjustmentRule (
DateTime dateStart,
DateTime dateEnd,
@@ -130,7 +141,13 @@ namespace System
public void GetObjectData (SerializationInfo info,
StreamingContext context)
#endif
{
- throw new NotImplementedException ();
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ info.AddValue (&quot;DateStart&quot;, DateStart);
+ info.AddValue (&quot;DateEnd&quot;, DateEnd);
+ info.AddValue (&quot;DaylightDelta&quot;, DaylightDelta);
+ info.AddValue (&quot;DaylightTransitionStart&quot;,
DaylightTransitionStart);
+ info.AddValue (&quot;DaylightTransitionEnd&quot;,
DaylightTransitionEnd);
}
#if NET_4_0
void IDeserializationCallback.OnDeserialization (object
sender)
@@ -138,7 +155,38 @@ namespace System
public void OnDeserialization (object sender)
#endif
{
- throw new NotImplementedException ();
+ try {
+ TimeZoneInfo.AdjustmentRule.Validate (dateStart,
dateEnd, daylightDelta,
+ daylightTransitionStart, daylightTransitionEnd);
+ } catch (ArgumentException ex) {
+ throw new SerializationException (&quot;invalid
serialization data&quot;, (Exception) ex);
+ }
+ }
+
+ private static void Validate (
+ DateTime dateStart,
+ DateTime dateEnd,
+ TimeSpan daylightDelta,
+ TransitionTime daylightTransitionStart,
+ TransitionTime daylightTransitionEnd)
+ {
+ if (dateStart.Kind != DateTimeKind.Unspecified ||
dateEnd.Kind != DateTimeKind.Unspecified)
+ throw new ArgumentException (&quot;the Kind property of
dateStart or dateEnd parameter does not equal DateTimeKind.Unspecified&quot;);
+
+ if (daylightTransitionStart == daylightTransitionEnd)
+ throw new ArgumentException
(&quot;daylightTransitionStart parameter cannot equal daylightTransitionEnd
parameter&quot;);
+
+ if (dateStart.Ticks % TimeSpan.TicksPerDay != 0 ||
dateEnd.Ticks % TimeSpan.TicksPerDay != 0)
+ throw new ArgumentException (&quot;dateStart or dateEnd
parameter includes a time of day value&quot;);
+
+ if (dateEnd &lt; dateStart)
+ throw new ArgumentOutOfRangeException (&quot;dateEnd is
earlier than dateStart&quot;);
+
+ if (daylightDelta &gt; new TimeSpan (14, 0, 0) ||
daylightDelta &lt; new TimeSpan (-14, 0, 0))
+ throw new ArgumentOutOfRangeException
(&quot;daylightDelta is less than -14 or greater than 14 hours&quot;);
+
+ if (daylightDelta.Ticks % TimeSpan.TicksPerSecond != 0)
+ throw new ArgumentOutOfRangeException
(&quot;daylightDelta parameter does not represent a whole number of seconds&quot;);
}
}
}
diff --git a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs
b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs
index a914ed1..0a72ce2 100644
--- a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs
+++ b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs
@@ -108,6 +108,26 @@ namespace System
return new TransitionTime (timeOfDay, month, week,
dayOfWeek);
}
+ private TransitionTime (SerializationInfo info,
StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ timeOfDay = (DateTime) info.GetValue (&quot;TimeOfDay&quot;,
typeof (DateTime));
+ month = (byte) info.GetValue (&quot;Month&quot;, typeof (byte));
+ week = (byte) info.GetValue (&quot;Week&quot;, typeof (byte));
+ day = (byte) info.GetValue (&quot;Day&quot;, typeof (byte));
+ dayOfWeek = (DayOfWeek) info.GetValue (&quot;DayOfWeek&quot;,
typeof (DayOfWeek));
+ isFixedDateRule = (bool) info.GetValue
(&quot;IsFixedDateRule&quot;, typeof (bool));
+
+ if (isFixedDateRule)
+ {
+ week = -1;
+ dayOfWeek = (DayOfWeek) (-1);
+ }
+ if (!isFixedDateRule)
+ day = -1;
+ }
+
private TransitionTime (
DateTime timeOfDay,
int month,
@@ -190,9 +210,25 @@ namespace System
public void GetObjectData (SerializationInfo info,
StreamingContext context)
#endif
{
- throw new NotImplementedException ();
- }
-
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ info.AddValue (&quot;TimeOfDay&quot;, TimeOfDay);
+ info.AddValue (&quot;Month&quot;, System.Convert.ToByte(Month));
+ if (week &gt; -1)
+ info.AddValue (&quot;Week&quot;, System.Convert.ToByte(week));
+ else
+ info.AddValue (&quot;Week&quot;, (byte) 1);
+ if (day &gt; -1)
+ info.AddValue (&quot;Day&quot;, System.Convert.ToByte(day));
+ else
+ info.AddValue (&quot;Day&quot;, (byte) 1);
+ if (dayOfWeek != ((System.DayOfWeek) (-1)))
+ info.AddValue (&quot;DayOfWeek&quot;, dayOfWeek);
+ else
+ info.AddValue (&quot;DayOfWeek&quot;, DayOfWeek.Sunday);
+ info.AddValue (&quot;IsFixedDateRule&quot;, IsFixedDateRule);
+ }
+
public override bool Equals (object obj)
{
if (obj is TransitionTime)
@@ -216,7 +252,50 @@ namespace System
public void OnDeserialization (object sender)
#endif
{
- throw new NotImplementedException ();
+ try {
+ TimeZoneInfo.TransitionTime.Validate (timeOfDay,
month, week, day, dayOfWeek, isFixedDateRule);
+ } catch (ArgumentException ex) {
+ throw new SerializationException (&quot;invalid
serialization data&quot;, (Exception) ex);
+ }
+ }
+
+ private static void Validate (DateTime timeOfDay, int
month,int week, int day, DayOfWeek dayOfWeek, bool isFixedDateRule)
+ {
+ if (timeOfDay.Year != 1 || timeOfDay.Month != 1 ||
timeOfDay.Day != 1)
+ throw new ArgumentException (&quot;timeOfDay parameter
has a non-default date component&quot;);
+
+ if (timeOfDay.Kind != DateTimeKind.Unspecified)
+ throw new ArgumentException (&quot;timeOfDay parameter
Kind's property is not DateTimeKind.Unspecified&quot;);
+
+ if (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond != 0)
+ throw new ArgumentException (&quot;timeOfDay parameter
does not represent a whole number of milliseconds&quot;);
+
+ if (day &lt; 1 || day &gt; 31)
+ {
+ if (!(!isFixedDateRule &amp;&amp; day == -1))
+ throw new ArgumentOutOfRangeException (&quot;day
parameter is less than 1 or greater than 31&quot;);
+ }
+
+ if (week &lt; 1 || week &gt; 5)
+ {
+ if (!(isFixedDateRule &amp;&amp; week == -1))
+ throw new ArgumentOutOfRangeException (&quot;week
parameter is less than 1 or greater than 5&quot;);
+ }
+
+ if (month &lt; 1 || month &gt; 12)
+ throw new ArgumentOutOfRangeException (&quot;month
parameter is less than 1 or greater than 12&quot;);
+
+ if (dayOfWeek != DayOfWeek.Sunday &amp;&amp;
+ dayOfWeek != DayOfWeek.Monday &amp;&amp;
+ dayOfWeek != DayOfWeek.Tuesday &amp;&amp;
+ dayOfWeek != DayOfWeek.Wednesday &amp;&amp;
+ dayOfWeek != DayOfWeek.Thursday &amp;&amp;
+ dayOfWeek != DayOfWeek.Friday &amp;&amp;
+ dayOfWeek != DayOfWeek.Saturday)
+ {
+ if (!(isFixedDateRule &amp;&amp; dayOfWeek == (DayOfWeek)
(-1)))
+ throw new ArgumentOutOfRangeException
(&quot;dayOfWeek parameter is not a member od DayOfWeek enumeration&quot;);
+ }
}
}
}
diff --git a/mcs/class/System.Core/System/TimeZoneInfo.cs
b/mcs/class/System.Core/System/TimeZoneInfo.cs
index ee440a4..dd3c656 100644
--- a/mcs/class/System.Core/System/TimeZoneInfo.cs
+++ b/mcs/class/System.Core/System/TimeZoneInfo.cs
@@ -598,11 +531,19 @@ namespace System
public void GetObjectData (SerializationInfo info,
StreamingContext context)
#endif
{
- throw new NotImplementedException ();
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ info.AddValue (&quot;Id&quot;, id);
+ info.AddValue (&quot;DisplayName&quot;, displayName);
+ info.AddValue (&quot;StandardName&quot;, standardDisplayName);
+ info.AddValue (&quot;DaylightName&quot;, daylightDisplayName);
+ info.AddValue (&quot;BaseUtcOffset&quot;, baseUtcOffset);
+ info.AddValue (&quot;AdjustmentRules&quot;, adjustmentRules);
+ info.AddValue (&quot;SupportsDaylightSavingTime&quot;,
SupportsDaylightSavingTime);
}
//FIXME: change this to a generic Dictionary and allow caching
for FindSystemTimeZoneById
@@ -786,9 +725,56 @@ namespace System
public void OnDeserialization (object sender)
#endif
{
- throw new NotImplementedException ();
+ try {
+ TimeZoneInfo.Validate (id, baseUtcOffset,
adjustmentRules);
+ } catch (ArgumentException ex) {
+ throw new SerializationException (&quot;invalid
serialization data&quot;, (Exception) ex);
+ }
}
-
+
+ private static void Validate (string id, TimeSpan
baseUtcOffset, AdjustmentRule [] adjustmentRules)
+ {
+ if (id == null)
+ throw new ArgumentNullException (&quot;id&quot;);
+
+ if (id == String.Empty)
+ throw new ArgumentException (&quot;id parameter is an empty
string&quot;);
+
+ if (baseUtcOffset.Ticks % TimeSpan.TicksPerMinute != 0)
+ throw new ArgumentException (&quot;baseUtcOffset parameter
does not represent a whole number of minutes&quot;);
+
+ if (baseUtcOffset &gt; new TimeSpan (14, 0, 0) ||
baseUtcOffset &lt; new TimeSpan (-14, 0, 0))
+ throw new ArgumentOutOfRangeException (&quot;baseUtcOffset
parameter is greater than 14 hours or less than -14 hours&quot;);
+
+#if STRICT
+ if (id.Length &gt; 32)
+ throw new ArgumentException (&quot;id parameter shouldn't be
longer than 32 characters&quot;);
+#endif
+
+ if (adjustmentRules != null &amp;&amp; adjustmentRules.Length != 0) {
+ AdjustmentRule prev = null;
+ foreach (AdjustmentRule current in adjustmentRules) {
+ if (current == null)
+ throw new InvalidTimeZoneException (&quot;one or
more elements in adjustmentRules are null&quot;);
+
+ if ((baseUtcOffset + current.DaylightDelta &lt; new
TimeSpan (-14, 0, 0)) ||
+ (baseUtcOffset + current.DaylightDelta &gt;
new TimeSpan (14, 0, 0)))
+ throw new InvalidTimeZoneException (&quot;Sum of
baseUtcOffset and DaylightDelta of one or more object in adjustmentRules
array is greater than 14 or less than -14 hours;&quot;);
+
+ if (prev != null &amp;&amp; prev.DateStart &gt; current.DateStart)
+ throw new InvalidTimeZoneException (&quot;adjustment
rules specified in adjustmentRules parameter are not in chronological
order&quot;);
+
+ if (prev != null &amp;&amp; prev.DateEnd &gt; current.DateStart)
+ throw new InvalidTimeZoneException (&quot;some
adjustment rules in the adjustmentRules parameter overlap&quot;);
+
+ if (prev != null &amp;&amp; prev.DateEnd == current.DateStart)
+ throw new InvalidTimeZoneException (&quot;a date can
have multiple adjustment rules applied to it&quot;);
+
+ prev = current;
+ }
+ }
+ }
+
public string ToSerializedString ()
{
throw new NotImplementedException ();
@@ -850,10 +832,24 @@ namespace System
this.adjustmentRules = adjustmentRules;
}
+ private TimeZoneInfo (SerializationInfo info, StreamingContext
context)
+ {
+ if (info == null)
+ throw new ArgumentNullException (&quot;info&quot;);
+ id = (string) info.GetValue (&quot;Id&quot;, typeof (string));
+ displayName = (string) info.GetValue (&quot;DisplayName&quot;, typeof
(string));
+ standardDisplayName = (string) info.GetValue
(&quot;StandardName&quot;, typeof (string));
+ daylightDisplayName = (string) info.GetValue
(&quot;DaylightName&quot;, typeof (string));
+ baseUtcOffset = (TimeSpan) info.GetValue (&quot;BaseUtcOffset&quot;,
typeof (TimeSpan));
+ adjustmentRules = (TimeZoneInfo.AdjustmentRule [])
info.GetValue (&quot;AdjustmentRules&quot;, typeof (TimeZoneInfo.AdjustmentRule []));
+ supportsDaylightSavingTime = (bool) info.GetValue
(&quot;SupportsDaylightSavingTime&quot;, typeof (bool));
+ }
+
private AdjustmentRule GetApplicableRule (DateTime dateTime)
{
//Transitions are always in standard time
diff --git
a/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs
b/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs
index 6fd2412..e20c37d 100644
--- &quot;a/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs&quot;
+++ &quot;b/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs&quot;
@@ -1,4 +1,6 @@
using System;
+using System.IO;
+using System.Runtime.Serialization.Formatters;
using NUnit.Framework;
#if NET_2_0
@@ -89,7 +91,33 @@ public void DeltaNotInSeconds ()
TimeZoneInfo.TransitionTime daylightTransitionEnd =
TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime
(1,1,1,2,0,0), 10, 11);
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
(dateStart, dateEnd, new TimeSpan (55), daylightTransitionStart,
daylightTransitionEnd);
}
- }
+ }
+
+ [TestFixture]
+ public class SerializationTests
+ {
+ TimeZoneInfo.AdjustmentRule rule;
+
+ [SetUp]
+ public void CreateRule ()
+ {
+ TimeZoneInfo.TransitionTime start =
TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
(1,1,1,1,0,0), 3, 5, DayOfWeek.Sunday);
+ TimeZoneInfo.TransitionTime end =
TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
(1,1,1,2,0,0), 10, 5, DayOfWeek.Sunday);
+ rule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
(DateTime.MinValue.Date, DateTime.MaxValue.Date, new TimeSpan (1,0,0),
start, end);
+ }
+
+ [Test]
+ public void Serialization_Deserialization ()
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryFormatter formatter = new BinaryFormatter ();
+ formatter.Serialize (stream, rule);
+ stream.Position = 0;
+ TimeZoneInfo.AdjustmentRule deserialized =
(TimeZoneInfo.AdjustmentRule) formatter.Deserialize (stream);
+ stream.Close ();
+ stream.Dispose ();
+ Assert.AreEqual (rule, deserialized);
+ }
+ }
}
}
#endif
diff --git
a/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs
b/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs
index 8dd8263..2fd2e70 100644
--- &quot;a/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs&quot;
+++ &quot;b/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs&quot;
@@ -1,5 +1,7 @@
using System;
+using System.IO;
+using System.Runtime.Serialization.Formatters;
using NUnit.Framework;
#if NET_2_0
@@ -107,6 +109,46 @@ public void EqualsObject ()
Assert.IsFalse (tt1.Equals (tt2), &quot;2!=1&quot;);
}
}
+
+ [TestFixture]
+ public class SerializationTests
+ {
+ TimeZoneInfo.TransitionTime floatingDateRule;
+ TimeZoneInfo.TransitionTime fixedDateRule;
+
+ [SetUp]
+ public void CreateDateRules ()
+ {
+ floatingDateRule =
TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1,
1, 0, 0), 3, 5, DayOfWeek.Sunday);
+ fixedDateRule =
TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 1,
0, 0), 3, 12);
+ }
+
+ [Test]
+ public void Serialize_Deserialize_FloatingDateRule ()
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryFormatter formatter = new BinaryFormatter ();
+ formatter.Serialize (stream, floatingDateRule);
+ stream.Position = 0;
+ TimeZoneInfo.TransitionTime deserialized =
(TimeZoneInfo.TransitionTime) formatter.Deserialize (stream);
+ stream.Close ();
+ stream.Dispose ();
+ Assert.AreEqual (floatingDateRule, deserialized);
+ }
+
+ [Test]
+ public void Serialize_Deserialize_FixedDateRule ()
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryFormatter formatter = new BinaryFormatter ();
+ formatter.Serialize (stream, fixedDateRule);
+ stream.Position = 0;
+ TimeZoneInfo.TransitionTime deserialized =
(TimeZoneInfo.TransitionTime) formatter.Deserialize (stream);
+ stream.Close ();
+ stream.Dispose ();
+ Assert.AreEqual (fixedDateRule, deserialized);
+ }
+ }
}
}
#endif
diff --git a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs
b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs
index 06de33e..f678acf 100644
--- &quot;a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs&quot;
+++ &quot;b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs&quot;
@@ -28,6 +28,8 @@
using System;
using System.Collections;
+using System.IO;
+using System.Runtime.Serialization.Formatters;
using NUnit.Framework;
#if NET_2_0
@@ -657,6 +659,34 @@ public class HasSameRulesTests
Assert.IsTrue (utc.HasSameRules (custom));
}
}
+
+ [TestFixture]
+ public class SerializationTests
+ {
+ TimeZoneInfo london;
+
+ [SetUp]
+ public void CreateTimeZones ()
+ {
+ TimeZoneInfo.TransitionTime start =
TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
(1,1,1,1,0,0), 3, 5, DayOfWeek.Sunday);
+ TimeZoneInfo.TransitionTime end =
TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
(1,1,1,2,0,0), 10, 5, DayOfWeek.Sunday);
+ TimeZoneInfo.AdjustmentRule rule =
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
(DateTime.MinValue.Date, DateTime.MaxValue.Date, new TimeSpan (1,0,0),
start, end);
+ london = TimeZoneInfo.CreateCustomTimeZone
(&quot;Europe/London&quot;, new TimeSpan (0), &quot;Europe/London&quot;, &quot;British Standard
Time&quot;, &quot;British Summer Time&quot;, new TimeZoneInfo.AdjustmentRule [] {rule});
+ }
+
+ [Test]
+ public void Serialization_Deserialization ()
+ {
+ MemoryStream stream = new MemoryStream ();
+ BinaryFormatter formatter = new BinaryFormatter ();
+ formatter.Serialize (stream, london);
+ stream.Position = 0;
+ TimeZoneInfo deserialized = (TimeZoneInfo)
formatter.Deserialize (stream);
+ stream.Close ();
+ stream.Dispose ();
+ Assert.AreEqual (london, deserialized);
+ }
+ }
}
}
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: &lt;<A HREF="http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130617/3573f627/attachment-0001.html">http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130617/3573f627/attachment-0001.html</A>&gt;
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="040546.html">[Mono-dev] How to skip building .net 2.0/3.x and build only 4.x?
</A></li>
<LI>Next message: <A HREF="040538.html">[Mono-dev] Serialization TimeZoneInfo class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#40537">[ date ]</a>
<a href="thread.html#40537">[ thread ]</a>
<a href="subject.html#40537">[ subject ]</a>
<a href="author.html#40537">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list">More information about the Mono-devel-list
mailing list</a><br>
</body></html>