public static T GetProperty <T>(string key, T defaultValue) { var value = ConfigurationManager.AppSettings[key]; var impl = GetPropertyImpl <T> .CreateInstanceWithCache(GetPropertyImpl <T> .CreateInstance); if (impl == null) { throw new NotSupportedException(); } return(impl.ToPropertyWithCache(key, value, defaultValue)); }
public static void Reset() { if (ms_ready) { lock (ms_lockObj) { if (ms_ready) { ms_instance = null; Thread.MemoryBarrier(); ms_ready = false; } } } }
public static GetPropertyImpl <T> CreateInstanceWithCache(Func <GetPropertyImpl <T> > instantiator) { if (!ms_ready) { lock (ms_lockObj) { if (!ms_ready) { ms_instance = instantiator() as GetPropertyImpl <T>; Thread.MemoryBarrier(); ms_ready = true; } } } return(ms_instance); }