예제 #1
0
 public static SettingModel getInstance()
 {
     if (instance == null)
     {
         lock (locker)
             if (instance == null)
             {
                 instance = new SettingModel();
                 var settings = DbContext.Get().GetEntityDB <Setting>().GetList();
                 if (settings != null)
                 {
                     var instype = instance.GetType();
                     foreach (var item in settings)
                     {
                         var mbr = instype.GetProperty(item.key);
                         if (mbr != null)
                         {
                             if (mbr.PropertyType == typeof(bool))
                             {
                                 mbr.SetValue(instance, item.value.Asbool());
                             }
                             else if (mbr.PropertyType == typeof(int))
                             {
                                 mbr.SetValue(instance, item.value.AsInt());
                             }
                             else
                             {
                                 mbr.SetValue(instance, item.value);
                             }
                         }
                     }
                 }
             }
     }
     return(instance);
 }
예제 #2
0
 public static void clearCache()
 {
     instance = null;
 }