using System;
using System.Diagnostics.Contracts;
using System.Text;
- using System.Threading;
using System.Collections;
using System.Globalization;
using System.Runtime.CompilerServices;
{
// The per-year information is cached in in this instance value. As a result it can
// be cleaned up by CultureInfo.ClearCachedData, which will clear the instance of this object
- private Hashtable m_CachedDaylightChanges = new Hashtable();
+ private readonly Hashtable m_CachedDaylightChanges = new Hashtable();
// Standard offset in ticks to the Universal time if
// no daylight saving is in used.
return new DateTime(tick, DateTimeKind.Local, isAmbiguousLocalDst);
}
- // Private object for locking instead of locking on a public type for SQL reliability work.
- private static Object s_InternalSyncObject;
- private static Object InternalSyncObject
- {
- get
- {
- if (s_InternalSyncObject == null)
- {
- Object o = new Object();
- Interlocked.CompareExchange<Object>(ref s_InternalSyncObject, o, null);
- }
- return s_InternalSyncObject;
- }
- }
-
public override DaylightTime GetDaylightChanges(int year)
{
if (year < 1 || year > 9999)
currentDaylightChanges = new DaylightTime(DateTime.MinValue, DateTime.MinValue, TimeSpan.Zero);
}
- lock (InternalSyncObject)
+ lock (m_CachedDaylightChanges)
{
if (!m_CachedDaylightChanges.Contains(objYear))
{