private static void AddToCache(int key, Timezone timezone)
 {
     if (timezone == null)
         throw new ArgumentException("timezone cannot be null.");
     _lock.EnterWriteLock();
     try
     {
         _cache[key] = timezone;
     }
     finally
     {
         _lock.ExitWriteLock();
     }
 }
 private static bool TryGetFromCache(int key, out Timezone timezone)
 {
     timezone = null;
     _lock.EnterReadLock();
     try
     {
         if (_cache.TryGetValue(key, out timezone) == true)
             return true;
         else
             return false;
     }
     finally
     {
         _lock.ExitReadLock();
     }
 }
        public static Timezone Create(int hours, uint mins)
        {
            if (hours > 19)
                throw new Exception("Hours cannot be greater than +/- 19.");
            if (mins != 0 && mins != 30 && mins != 45)
                throw new Exception("Minute values can only be 0, 30 or 45.");

            Timezone zone = null;
            // Offset the -19 to always return a positive number
            int key = (20 + hours) * 60 + (int)mins;
            if (TryGetFromCache(key, out zone) == false)
            {
                zone = new Timezone(hours, mins);
                AddToCache(key, zone);
            }
            return zone;
        }
 public static bool TryParse(string timezone, out Timezone zone)
 {
     zone = null;
     try
     {
         // Format +530 or -530
         var match = Pattern.Match(timezone);
         if (match.Success == false)
             return false;
         var hour = int.Parse(match.Groups["hour"].Value);
         var min = uint.Parse(match.Groups["min"].Value);
         zone = Timezone.Create(hour, min);
         return true;
     }
     catch
     {
         zone = null;
         return false;
     }
 }
 private static void AddToCache(int key, Timezone timezone)
 {
     if (timezone == null)
         throw new ArgumentException("timezone cannot be null.");
     lock (_syncRoot)
     {
         _cache[key] = timezone;
     }
 }
 private static bool TryGetFromCache(int key, out Timezone timezone)
 {
     timezone = null;
     lock (_syncRoot)
     {
         if (_cache.TryGetValue(key, out timezone) == true)
             return true;
         else
             return false;
     }
     
 }