<div dir="ltr">Hello Andreas,<div><br></div><div>Could you send pull request instead of inline patch ?</div><div><br></div><div>Thanks</div><div>Marek<br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
    
    
    
    
    
    
    
    
    
    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.<br>
    <br>
    The patch:<br>
    <br>
    diff --git
    a/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs
    b/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs<br>
    index d3c16f4..4c413a8 100644<br>
    --- a/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs<br>
    +++ b/mcs/class/System.Core/System/TimeZoneInfo.AdjustmentRule.cs<br>
    @@ -74,6 +74,17 @@ namespace System<br>
                     return new AdjustmentRule (dateStart, dateEnd,
    daylightDelta, daylightTransitionStart, daylightTransitionEnd);<br>
                 }<br>
     <br>
    +            private AdjustmentRule (SerializationInfo info,
    StreamingContext context)<br>
    +            {<br>
    +                if (info == null)<br>
    +                    throw new ArgumentNullException ("info");<br>
    +                dateStart = (DateTime) info.GetValue ("DateStart",
    typeof (DateTime));<br>
    +                dateEnd = (DateTime) info.GetValue ("DateEnd",
    typeof (DateTime));<br>
    +                daylightDelta = (TimeSpan) info.GetValue
    ("DaylightDelta", typeof (TimeSpan));<br>
    +                daylightTransitionStart =
    (TimeZoneInfo.TransitionTime) info.GetValue
    ("DaylightTransitionStart", typeof (TimeZoneInfo.TransitionTime));<br>
    +                daylightTransitionEnd =
    (TimeZoneInfo.TransitionTime) info.GetValue
    ("DaylightTransitionEnd", typeof (TimeZoneInfo.TransitionTime));<br>
    +            }<br>
    +<br>
                 private AdjustmentRule (<br>
                     DateTime dateStart,<br>
                     DateTime dateEnd,<br>
    @@ -130,7 +141,13 @@ namespace System<br>
                 public void GetObjectData (SerializationInfo info,
    StreamingContext context)<br>
     #endif<br>
                 {<br>
    -                throw new NotImplementedException ();<br>
    +                if (info == null)<br>
    +                    throw new ArgumentNullException ("info");<br>
    +                info.AddValue ("DateStart", DateStart);<br>
    +                info.AddValue ("DateEnd", DateEnd);<br>
    +                info.AddValue ("DaylightDelta", DaylightDelta);<br>
    +                info.AddValue ("DaylightTransitionStart",
    DaylightTransitionStart);<br>
    +                info.AddValue ("DaylightTransitionEnd",
    DaylightTransitionEnd);<br>
                 }<br>
     #if NET_4_0<br>
                 void IDeserializationCallback.OnDeserialization (object
    sender)<br>
    @@ -138,7 +155,38 @@ namespace System<br>
                 public void OnDeserialization (object sender)<br>
     #endif<br>
                 {<br>
    -                throw new NotImplementedException ();<br>
    +                try {<br>
    +                    TimeZoneInfo.AdjustmentRule.Validate
    (dateStart, dateEnd, daylightDelta, <br>
    +                                                         
    daylightTransitionStart, daylightTransitionEnd);<br>
    +                } catch (ArgumentException ex) {<br>
    +                    throw new SerializationException ("invalid
    serialization data", (Exception) ex);<br>
    +                }<br>
    +            }<br>
    +<br>
    +            private static void Validate (<br>
    +                DateTime dateStart,<br>
    +                DateTime dateEnd,<br>
    +                TimeSpan daylightDelta,<br>
    +                TransitionTime daylightTransitionStart,<br>
    +                TransitionTime daylightTransitionEnd)<br>
    +            {<br>
    +                if (dateStart.Kind != DateTimeKind.Unspecified ||
    dateEnd.Kind != DateTimeKind.Unspecified)<br>
    +                    throw new ArgumentException ("the Kind property
    of dateStart or dateEnd parameter does not equal
    DateTimeKind.Unspecified");<br>
    +<br>
    +                if (daylightTransitionStart ==
    daylightTransitionEnd)<br>
    +                    throw new ArgumentException
    ("daylightTransitionStart parameter cannot equal
    daylightTransitionEnd parameter");<br>
    +<br>
    +                if (dateStart.Ticks % TimeSpan.TicksPerDay != 0 ||
    dateEnd.Ticks % TimeSpan.TicksPerDay != 0)<br>
    +                    throw new ArgumentException ("dateStart or
    dateEnd parameter includes a time of day value");<br>
    +<br>
    +                if (dateEnd < dateStart)<br>
    +                    throw new ArgumentOutOfRangeException ("dateEnd
    is earlier than dateStart");<br>
    +<br>
    +                if (daylightDelta > new TimeSpan (14, 0, 0) ||
    daylightDelta < new TimeSpan (-14, 0, 0))<br>
    +                    throw new ArgumentOutOfRangeException
    ("daylightDelta is less than -14 or greater than 14 hours");<br>
    +<br>
    +                if (daylightDelta.Ticks % TimeSpan.TicksPerSecond
    != 0)<br>
    +                    throw new ArgumentOutOfRangeException
    ("daylightDelta parameter does not represent a whole number of
    seconds");<br>
                 }<br>
             }<br>
         }<br>
    diff --git
    a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs
    b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs<br>
    index a914ed1..0a72ce2 100644<br>
    --- a/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs<br>
    +++ b/mcs/class/System.Core/System/TimeZoneInfo.TransitionTime.cs<br>
    @@ -108,6 +108,26 @@ namespace System<br>
                     return new TransitionTime (timeOfDay, month, week,
    dayOfWeek);<br>
                 }<br>
     <br>
    +            private TransitionTime (SerializationInfo info,
    StreamingContext context)<br>
    +            {<br>
    +                if (info == null)<br>
    +                    throw new ArgumentNullException ("info");<br>
    +                timeOfDay = (DateTime) info.GetValue ("TimeOfDay",
    typeof (DateTime));<br>
    +                month = (byte) info.GetValue ("Month", typeof
    (byte));<br>
    +                week = (byte) info.GetValue ("Week", typeof
    (byte));<br>
    +                day = (byte) info.GetValue ("Day", typeof (byte));<br>
    +                dayOfWeek = (DayOfWeek) info.GetValue ("DayOfWeek",
    typeof (DayOfWeek));<br>
    +                isFixedDateRule = (bool) info.GetValue
    ("IsFixedDateRule", typeof (bool));<br>
    +<br>
    +                if (isFixedDateRule)<br>
    +                {<br>
    +                    week = -1;<br>
    +                    dayOfWeek = (DayOfWeek) (-1);<br>
    +                }<br>
    +                if (!isFixedDateRule)            <br>
    +                    day = -1;<br>
    +            }<br>
    +<br>
                 private TransitionTime (<br>
                     DateTime timeOfDay,<br>
                     int month,<br>
    @@ -190,9 +210,25 @@ namespace System<br>
                 public void GetObjectData (SerializationInfo info,
    StreamingContext context)<br>
     #endif<br>
                 {<br>
    -                throw new NotImplementedException ();<br>
    -            }<br>
    -    <br>
    +                if (info == null)<br>
    +                    throw new ArgumentNullException ("info");<br>
    +                info.AddValue ("TimeOfDay", TimeOfDay);<br>
    +                info.AddValue ("Month",
    System.Convert.ToByte(Month));<br>
    +                if (week > -1)<br>
    +                    info.AddValue ("Week",
    System.Convert.ToByte(week));<br>
    +                else <br>
    +                    info.AddValue ("Week", (byte) 1);<br>
    +                if (day > -1)<br>
    +                    info.AddValue ("Day",
    System.Convert.ToByte(day));<br>
    +                else<br>
    +                    info.AddValue ("Day", (byte) 1);<br>
    +                if (dayOfWeek !=  ((System.DayOfWeek) (-1)))<br>
    +                    info.AddValue ("DayOfWeek", dayOfWeek);<br>
    +                else<br>
    +                    info.AddValue ("DayOfWeek", DayOfWeek.Sunday);<br>
    +                info.AddValue ("IsFixedDateRule", IsFixedDateRule);<br>
    +            }    <br>
    +<br>
                 public override bool Equals (object obj)<br>
                 {<br>
                     if (obj is TransitionTime)<br>
    @@ -216,7 +252,50 @@ namespace System<br>
                 public void OnDeserialization (object sender)<br>
     #endif<br>
                 {<br>
    -                throw new NotImplementedException ();<br>
    +                try {<br>
    +                    TimeZoneInfo.TransitionTime.Validate
    (timeOfDay, month, week, day, dayOfWeek, isFixedDateRule);<br>
    +                } catch (ArgumentException ex) {<br>
    +                    throw new SerializationException ("invalid
    serialization data", (Exception) ex);<br>
    +                }<br>
    +            }<br>
    +<br>
    +            private static void Validate (DateTime timeOfDay, int
    month,int week, int day, DayOfWeek dayOfWeek, bool isFixedDateRule)<br>
    +            {<br>
    +                if (timeOfDay.Year != 1 || timeOfDay.Month != 1 ||
    timeOfDay.Day != 1)<br>
    +                    throw new ArgumentException ("timeOfDay
    parameter has a non-default date component");<br>
    +<br>
    +                if (timeOfDay.Kind != DateTimeKind.Unspecified)<br>
    +                    throw new ArgumentException ("timeOfDay
    parameter Kind's property is not DateTimeKind.Unspecified");<br>
    +<br>
    +                if (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond
    != 0)<br>
    +                    throw new ArgumentException ("timeOfDay
    parameter does not represent a whole number of milliseconds");<br>
    +<br>
    +                if (day < 1 || day > 31)<br>
    +                {<br>
    +                    if (!(!isFixedDateRule && day == -1))<br>
    +                        throw new ArgumentOutOfRangeException ("day
    parameter is less than 1 or greater than 31");<br>
    +                }<br>
    +<br>
    +                if (week < 1 || week > 5)<br>
    +                {<br>
    +                    if (!(isFixedDateRule && week == -1))<br>
    +                        throw new ArgumentOutOfRangeException
    ("week parameter is less than 1 or greater than 5");<br>
    +                }<br>
    +<br>
    +                if (month < 1 || month > 12)<br>
    +                    throw new ArgumentOutOfRangeException ("month
    parameter is less than 1 or greater than 12");<br>
    +<br>
    +                if (dayOfWeek != DayOfWeek.Sunday &&<br>
    +                        dayOfWeek != DayOfWeek.Monday &&<br>
    +                        dayOfWeek != DayOfWeek.Tuesday &&<br>
    +                        dayOfWeek != DayOfWeek.Wednesday &&<br>
    +                        dayOfWeek != DayOfWeek.Thursday &&<br>
    +                        dayOfWeek != DayOfWeek.Friday &&<br>
    +                        dayOfWeek != DayOfWeek.Saturday)<br>
    +                {<br>
    +                    if (!(isFixedDateRule && dayOfWeek ==
    (DayOfWeek) (-1)))<br>
    +                        throw new ArgumentOutOfRangeException
    ("dayOfWeek parameter is not a member od DayOfWeek enumeration");<br>
    +                }<br>
                 }<br>
             }<br>
         }<br>
    diff --git a/mcs/class/System.Core/System/TimeZoneInfo.cs
    b/mcs/class/System.Core/System/TimeZoneInfo.cs<br>
    index ee440a4..dd3c656 100644<br>
    --- a/mcs/class/System.Core/System/TimeZoneInfo.cs<br>
    +++ b/mcs/class/System.Core/System/TimeZoneInfo.cs<br>
    @@ -598,11 +531,19 @@ namespace System<br>
             public void GetObjectData (SerializationInfo info,
    StreamingContext context)<br>
     #endif<br>
             {<br>
    -            throw new NotImplementedException ();<br>
    +            if (info == null)<br>
    +                throw new ArgumentNullException ("info");<br>
    +            info.AddValue ("Id", id);<br>
    +            info.AddValue ("DisplayName", displayName);<br>
    +            info.AddValue ("StandardName", standardDisplayName);<br>
    +            info.AddValue ("DaylightName", daylightDisplayName);<br>
    +            info.AddValue ("BaseUtcOffset", baseUtcOffset);<br>
    +            info.AddValue ("AdjustmentRules", adjustmentRules);<br>
    +            info.AddValue ("SupportsDaylightSavingTime",
    SupportsDaylightSavingTime);<br>
             }<br>
     <br>
             //FIXME: change this to a generic Dictionary and allow
    caching for FindSystemTimeZoneById<br>
    @@ -786,9 +725,56 @@ namespace System<br>
             public void OnDeserialization (object sender)<br>
     #endif<br>
             {<br>
    -            throw new NotImplementedException ();<br>
    +                try {<br>
    +                    TimeZoneInfo.Validate (id, baseUtcOffset,
    adjustmentRules);<br>
    +                } catch (ArgumentException ex) {<br>
    +                    throw new SerializationException ("invalid
    serialization data", (Exception) ex);<br>
    +                }<br>
             }<br>
    -        <br>
    +<br>
    +        private static void Validate (string id, TimeSpan
    baseUtcOffset, AdjustmentRule [] adjustmentRules)<br>
    +        {<br>
    +            if (id == null)<br>
    +                throw new ArgumentNullException ("id");<br>
    +<br>
    +            if (id == String.Empty)<br>
    +                throw new ArgumentException ("id parameter is an
    empty string");<br>
    +<br>
    +            if (baseUtcOffset.Ticks % TimeSpan.TicksPerMinute != 0)<br>
    +                throw new ArgumentException ("baseUtcOffset
    parameter does not represent a whole number of minutes");<br>
    +<br>
    +            if (baseUtcOffset > new TimeSpan (14, 0, 0) ||
    baseUtcOffset < new TimeSpan (-14, 0, 0))<br>
    +                throw new ArgumentOutOfRangeException
    ("baseUtcOffset parameter is greater than 14 hours or less than -14
    hours");<br>
    +<br>
    +#if STRICT<br>
    +            if (id.Length > 32)<br>
    +                throw new ArgumentException ("id parameter
    shouldn't be longer than 32 characters");<br>
    +#endif<br>
    +<br>
    +            if (adjustmentRules != null &&
    adjustmentRules.Length != 0) {<br>
    +                AdjustmentRule prev = null;<br>
    +                foreach (AdjustmentRule current in adjustmentRules)
    {<br>
    +                    if (current == null)<br>
    +                        throw new InvalidTimeZoneException ("one or
    more elements in adjustmentRules are null");<br>
    +<br>
    +                    if ((baseUtcOffset + current.DaylightDelta <
    new TimeSpan (-14, 0, 0)) ||<br>
    +                            (baseUtcOffset + current.DaylightDelta
    > new TimeSpan (14, 0, 0)))<br>
    +                        throw new InvalidTimeZoneException ("Sum of
    baseUtcOffset and DaylightDelta of one or more object in
    adjustmentRules array is greater than 14 or less than -14 hours;");<br>
    +<br>
    +                    if (prev != null && prev.DateStart >
    current.DateStart)<br>
    +                        throw new InvalidTimeZoneException
    ("adjustment rules specified in adjustmentRules parameter are not in
    chronological order");<br>
    +                    <br>
    +                    if (prev != null && prev.DateEnd >
    current.DateStart)<br>
    +                        throw new InvalidTimeZoneException ("some
    adjustment rules in the adjustmentRules parameter overlap");<br>
    +<br>
    +                    if (prev != null && prev.DateEnd ==
    current.DateStart)<br>
    +                        throw new InvalidTimeZoneException ("a date
    can have multiple adjustment rules applied to it");<br>
    +<br>
    +                    prev = current;<br>
    +                }<br>
    +            }<br>
    +        }<br>
    +<br>
             public string ToSerializedString ()<br>
             {<br>
                 throw new NotImplementedException ();<br>
    @@ -850,10 +832,24 @@ namespace System<br>
                 this.adjustmentRules = adjustmentRules;<br>
             }<br>
     <br>
    +        private TimeZoneInfo (SerializationInfo info,
    StreamingContext context)<br>
    +        {<br>
    +            if (info == null)<br>
    +                throw new ArgumentNullException ("info");<br>
    +            id = (string) info.GetValue ("Id", typeof (string));<br>
    +            displayName = (string) info.GetValue ("DisplayName",
    typeof (string));<br>
    +            standardDisplayName = (string) info.GetValue
    ("StandardName", typeof (string));<br>
    +            daylightDisplayName = (string) info.GetValue
    ("DaylightName", typeof (string));<br>
    +            baseUtcOffset = (TimeSpan) info.GetValue
    ("BaseUtcOffset", typeof (TimeSpan));<br>
    +            adjustmentRules = (TimeZoneInfo.AdjustmentRule [])
    info.GetValue ("AdjustmentRules", typeof
    (TimeZoneInfo.AdjustmentRule []));<br>
    +            supportsDaylightSavingTime = (bool) info.GetValue
    ("SupportsDaylightSavingTime", typeof (bool));<br>
    +        }<br>
    +<br>
             private AdjustmentRule GetApplicableRule (DateTime
    dateTime)<br>
             {<br>
                 //Transitions are always in standard time<br>
    diff --git
    a/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs
b/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs<br>
    index 6fd2412..e20c37d 100644<br>
    ---
    "a/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs"<br>
    +++
    "b/mcs/class/System.Core/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs"<br>
    @@ -1,4 +1,6 @@<br>
     using System;<br>
    +using System.IO;<br>
    +using System.Runtime.Serialization.Formatters;<br>
     using NUnit.Framework;<br>
     <br>
     #if NET_2_0<br>
    @@ -89,7 +91,33 @@ public void DeltaNotInSeconds ()<br>
                     TimeZoneInfo.TransitionTime daylightTransitionEnd =
    TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime
    (1,1,1,2,0,0), 10, 11);<br>
                     TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
    (dateStart, dateEnd, new TimeSpan (55), daylightTransitionStart,
    daylightTransitionEnd);<br>
                 }<br>
    -        }    <br>
    +        }<br>
    +    <br>
    +       [TestFixture]<br>
    +        public class SerializationTests<br>
    +        {<br>
    +            TimeZoneInfo.AdjustmentRule rule;<br>
    +<br>
    +            [SetUp]<br>
    +            public void CreateRule () <br>
    +            {<br>
    +                TimeZoneInfo.TransitionTime start =
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
    (1,1,1,1,0,0), 3, 5, DayOfWeek.Sunday);<br>
    +                TimeZoneInfo.TransitionTime end =
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
    (1,1,1,2,0,0), 10, 5, DayOfWeek.Sunday);<br>
    +                rule =
    TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
    (DateTime.MinValue.Date, DateTime.MaxValue.Date, new TimeSpan
    (1,0,0), start, end);<br>
    +            }<br>
    +<br>
    +            [Test]<br>
    +            public void Serialization_Deserialization ()<br>
    +            {<br>
    +                MemoryStream stream = new MemoryStream ();<br>
    +                BinaryFormatter formatter = new BinaryFormatter ();<br>
    +                formatter.Serialize (stream, rule);<br>
    +                stream.Position = 0;<br>
    +                TimeZoneInfo.AdjustmentRule deserialized =
    (TimeZoneInfo.AdjustmentRule) formatter.Deserialize (stream);<br>
    +                stream.Close ();<br>
    +                stream.Dispose ();<br>
    +                Assert.AreEqual (rule, deserialized);<br>
    +            }<br>
    +        }<br>
         }    <br>
     }<br>
    #endif<br>
    diff --git
    a/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs
b/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs<br>
    index 8dd8263..2fd2e70 100644<br>
    ---
    "a/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs"<br>
    +++
    "b/mcs/class/System.Core/Test/System/TimeZoneInfo.TransitionTimeTest.cs"<br>
    @@ -1,5 +1,7 @@<br>
     <br>
     using System;<br>
    +using System.IO;<br>
    +using System.Runtime.Serialization.Formatters;<br>
     using NUnit.Framework;<br>
     <br>
     #if NET_2_0<br>
    @@ -107,6 +109,46 @@ public void EqualsObject ()<br>
                     Assert.IsFalse (tt1.Equals (tt2), "2!=1");<br>
                 }<br>
             }<br>
    +<br>
    +       [TestFixture]<br>
    +        public class SerializationTests<br>
    +        {<br>
    +            TimeZoneInfo.TransitionTime floatingDateRule;<br>
    +            TimeZoneInfo.TransitionTime fixedDateRule;<br>
    +<br>
    +            [SetUp]<br>
    +            public void CreateDateRules ()<br>
    +            {<br>
    +                floatingDateRule =
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1,
    1, 1, 1, 0, 0), 3, 5, DayOfWeek.Sunday);<br>
    +                fixedDateRule =
    TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1,
    1, 1, 0, 0), 3, 12);<br>
    +            }<br>
    +<br>
    +            [Test]<br>
    +            public void Serialize_Deserialize_FloatingDateRule ()<br>
    +            {<br>
    +                MemoryStream stream = new MemoryStream ();<br>
    +                BinaryFormatter formatter = new BinaryFormatter ();<br>
    +                formatter.Serialize (stream, floatingDateRule);<br>
    +                stream.Position = 0;<br>
    +                TimeZoneInfo.TransitionTime deserialized =
    (TimeZoneInfo.TransitionTime) formatter.Deserialize (stream);<br>
    +                stream.Close ();<br>
    +                stream.Dispose ();<br>
    +                Assert.AreEqual (floatingDateRule, deserialized);<br>
    +            }<br>
    +<br>
    +            [Test]<br>
    +            public void Serialize_Deserialize_FixedDateRule ()<br>
    +            {<br>
    +                MemoryStream stream = new MemoryStream ();<br>
    +                BinaryFormatter formatter = new BinaryFormatter ();<br>
    +                formatter.Serialize (stream, fixedDateRule);<br>
    +                stream.Position = 0;<br>
    +                TimeZoneInfo.TransitionTime deserialized =
    (TimeZoneInfo.TransitionTime) formatter.Deserialize (stream);<br>
    +                stream.Close ();<br>
    +                stream.Dispose ();<br>
    +                Assert.AreEqual (fixedDateRule, deserialized);<br>
    +            }<br>
    +        }<br>
         }<br>
     }<br>
     #endif<br>
    diff --git a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs
    b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs<br>
    index 06de33e..f678acf 100644<br>
    --- "a/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs"<br>
    +++ "b/mcs/class/System.Core/Test/System/TimeZoneInfoTest.cs"<br>
    @@ -28,6 +28,8 @@<br>
     <br>
     using System;<br>
     using System.Collections;<br>
    +using System.IO;<br>
    +using System.Runtime.Serialization.Formatters;<br>
     <br>
     using NUnit.Framework;<br>
     #if NET_2_0<br>
    @@ -657,6 +659,34 @@ public class HasSameRulesTests<br>
                     Assert.IsTrue (utc.HasSameRules (custom));<br>
                 }<br>
             }<br>
    +<br>
    +       [TestFixture]<br>
    +        public class SerializationTests<br>
    +        {<br>
    +            TimeZoneInfo london;<br>
    +        <br>
    +            [SetUp]<br>
    +            public void CreateTimeZones ()<br>
    +            {<br>
    +                TimeZoneInfo.TransitionTime start =
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
    (1,1,1,1,0,0), 3, 5, DayOfWeek.Sunday);<br>
    +                TimeZoneInfo.TransitionTime end =
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime
    (1,1,1,2,0,0), 10, 5, DayOfWeek.Sunday);<br>
    +                TimeZoneInfo.AdjustmentRule rule =
    TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule
    (DateTime.MinValue.Date, DateTime.MaxValue.Date, new TimeSpan
    (1,0,0), start, end);<br>
    +                london = TimeZoneInfo.CreateCustomTimeZone
    ("Europe/London", new TimeSpan (0), "Europe/London", "British
    Standard Time", "British Summer Time", new
    TimeZoneInfo.AdjustmentRule [] {rule});<br>
    +            }<br>
    +<br>
    +            [Test]<br>
    +            public void Serialization_Deserialization ()<br>
    +            {<br>
    +                MemoryStream stream = new MemoryStream ();<br>
    +                BinaryFormatter formatter = new BinaryFormatter ();<br>
    +                formatter.Serialize (stream, london);<br>
    +                stream.Position = 0;<br>
    +                TimeZoneInfo deserialized = (TimeZoneInfo)
    formatter.Deserialize (stream);<br>
    +                stream.Close ();<br>
    +                stream.Dispose ();<br>
    +                Assert.AreEqual (london, deserialized);<br>
    +            }<br>
    +        }<br>
         }<br>
     }<br>
     #endif<br>
    <br>
  </div>

<br>_______________________________________________<br>
Mono-devel-list mailing list<br>
<a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
<br></blockquote></div><br></div></div></div>