Beispiel #1
0
 /// <summary>
 /// Checks if a specific key exists in the settings
 /// </summary>
 /// <param name="key">Key to check</param>
 /// <returns>true if existing</returns>
 public bool CheckSettingsExist(string key)
 {
     lock (Lock)
     {
         return(SerializedSettings.ContainsKey(key));
     }
 }
Beispiel #2
0
 /// <summary>
 /// Fetches settings for a given key, returning null if no setting was found
 /// </summary>
 /// <typeparam name="T_Item">The type to cast the result to</typeparam>
 /// <param name="key">The key to fetch the settings for</param>
 /// <returns>null if not found, the object otherwise</returns>
 public T_Item FetchSettings <T_Item>(string key)
 {
     lock (Lock)
     {
         if (!SerializedSettings.ContainsKey(key))
         {
             return(default(T_Item));
         }
         return((T_Item)SerializedSettings[key]);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Fetches settings for a given key, returning null if no setting was found
 /// </summary>
 /// <typeparam name="T_Item">The type to cast the result to</typeparam>
 /// <param name="key">The key to fetch the settings for</param>
 /// <returns>null if not found, the object otherwise</returns>
 public T_Item FetchSettings <T_Item>(string key)
 {
     lock (Lock)
     {
         try
         {
             if (SerializedSettings == null || !SerializedSettings.ContainsKey(key))
             {
                 SimpleLogger.Log(SimpleLogLevel.Info, "Settings use default of: " + key);
                 var res = default(T_Item);
                 SerializedSettings.Add(key, res);
                 return(res);
             }
             return((T_Item)SerializedSettings[key]);
         }
         catch (Exception ex)
         {
             SimpleLogger.Log(SimpleLogLevel.Warn, "Fail to fetch settings for: '" + key + "'  " + ex.Message);
             return(default(T_Item));
         }
     }
 }