From 9f5a93710442a52f628eb5846e90067f77db2ce7 Mon Sep 17 00:00:00 2001 From: jbevain Date: Mon, 21 Jun 2010 10:03:44 +0000 Subject: [PATCH] 2010-06-21 Jb Evain * TimeZoneInfo.cs: fix the moonlight and monotouch build. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@159234 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- class/System.Core/System/ChangeLog | 4 +++ class/System.Core/System/TimeZoneInfo.cs | 43 +++++++++++++++++++------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/class/System.Core/System/ChangeLog b/class/System.Core/System/ChangeLog index 05a5a9b62e..ecef9787c7 100644 --- a/class/System.Core/System/ChangeLog +++ b/class/System.Core/System/ChangeLog @@ -1,3 +1,7 @@ +2010-06-21 Jb Evain + + * TimeZoneInfo.cs: fix the moonlight and monotouch build. + 2010-06-18 Vincent Povirk * TimeZoneInfo.cs: Applied patch from Vincent Povirk that adds diff --git a/class/System.Core/System/TimeZoneInfo.cs b/class/System.Core/System/TimeZoneInfo.cs index 253222d902..ce8c22a83a 100644 --- a/class/System.Core/System/TimeZoneInfo.cs +++ b/class/System.Core/System/TimeZoneInfo.cs @@ -135,6 +135,7 @@ namespace System #endif private AdjustmentRule [] adjustmentRules; +#if !NET_2_1 static RegistryKey timeZoneKey = null; static bool timeZoneKeySet = false; static RegistryKey TimeZoneKey { @@ -151,6 +152,7 @@ namespace System return timeZoneKey; } } +#endif public static void ClearCachedData () { @@ -309,6 +311,7 @@ namespace System //FIXME: this method should check for cached values in systemTimeZones if (id == null) throw new ArgumentNullException ("id"); +#if !NET_2_1 if (TimeZoneKey != null) { RegistryKey key = TimeZoneKey.OpenSubKey (id, false); @@ -316,6 +319,7 @@ namespace System throw new TimeZoneNotFoundException (); return FromRegistryKey(id, key); } +#endif #if LIBC string filepath = Path.Combine (TimeZoneDirectory, id); return FindSystemTimeZoneByFileName (id, filepath); @@ -348,6 +352,7 @@ namespace System } #endif +#if !NET_2_1 private static TimeZoneInfo FromRegistryKey (string id, RegistryKey key) { byte [] reg_tzi = (byte []) key.GetValue ("TZI"); @@ -451,6 +456,7 @@ namespace System start_date, end_date, daylight_delta, start_transition_time, end_transition_time)); } +#endif public static TimeZoneInfo FromSerializedString (string source) { @@ -505,35 +511,36 @@ namespace System { if (systemTimeZones == null) { systemTimeZones = new List (); +#if !NET_2_1 if (TimeZoneKey != null) { foreach (string id in TimeZoneKey.GetSubKeyNames ()) { try { systemTimeZones.Add (FindSystemTimeZoneById (id)); } catch {} } + + return new ReadOnlyCollection (systemTimeZones); } +#endif #if LIBC - else { - string[] continents = new string [] {"Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Brazil", "Canada", "Chile", "Europe", "Indian", "Mexico", "Mideast", "Pacific", "US"}; - foreach (string continent in continents) { - try { - foreach (string zonepath in Directory.GetFiles (Path.Combine (TimeZoneDirectory, continent))) { - try { - string id = String.Format ("{0}/{1}", continent, Path.GetFileName (zonepath)); - systemTimeZones.Add (FindSystemTimeZoneById (id)); - } catch (ArgumentNullException) { - } catch (TimeZoneNotFoundException) { - } catch (InvalidTimeZoneException) { - } catch (Exception) { - throw; - } + string[] continents = new string [] {"Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Brazil", "Canada", "Chile", "Europe", "Indian", "Mexico", "Mideast", "Pacific", "US"}; + foreach (string continent in continents) { + try { + foreach (string zonepath in Directory.GetFiles (Path.Combine (TimeZoneDirectory, continent))) { + try { + string id = String.Format ("{0}/{1}", continent, Path.GetFileName (zonepath)); + systemTimeZones.Add (FindSystemTimeZoneById (id)); + } catch (ArgumentNullException) { + } catch (TimeZoneNotFoundException) { + } catch (InvalidTimeZoneException) { + } catch (Exception) { + throw; } - } catch {} - } + } + } catch {} } #else - else - throw new NotImplementedException ("This method is not implemented for this platform"); + throw new NotImplementedException ("This method is not implemented for this platform"); #endif } return new ReadOnlyCollection (systemTimeZones); -- 2.11.4.GIT