コード例 #1
0
        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));
        }
コード例 #2
0
 public static void Reset()
 {
     if (ms_ready)
     {
         lock (ms_lockObj)
         {
             if (ms_ready)
             {
                 ms_instance = null;
                 Thread.MemoryBarrier();
                 ms_ready = false;
             }
         }
     }
 }
コード例 #3
0
 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);
 }