Esempio n. 1
0
 /// <summary>
 /// Called to either initially load, or force a reload our config file var; 
 /// called by mod initialization and again potentially at mapload hense the options. 
 /// </summary>
 /// <param name="bForceReread">Set to true to flush the old object and create a new one.</param>
 /// <param name="bNoReloadVars">Set this to true to NOT reload the values from the new read of config file to our class level counterpart vars</param>
 public static void ReloadConfigValues(bool bForceReread, bool bNoReloadVars)
 {
     try
     {
         if (bForceReread)
         {
             config = null;
             if (DEBUG_LOG_ON & DEBUG_LOG_LEVEL >= 1) { Helper.dbgLog("Config re-read requested."); }
         }
         config = Configuration.Deserialize(MOD_CONFIGPATH);
         if (config == null)
         {
             config = new Configuration();
             //reset of setting should pull defaults
             Helper.dbgLog("Existing config was null. Created new one.");
             Configuration.Serialize(MOD_CONFIGPATH, config); //let's write it.
         }
         if (config != null && bNoReloadVars == false) //set\refresh our vars by default.
         {
             DEBUG_LOG_ON = config.DebugLogging;
             DEBUG_LOG_LEVEL = config.DebugLoggingLevel;
             if (DEBUG_LOG_ON & DEBUG_LOG_LEVEL == 0) { DEBUG_LOG_LEVEL = 1; }
             if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL >= 2) { Helper.dbgLog("Vars refreshed"); }
         }
         if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL >= 2) { Helper.dbgLog("Reloaded Config data."); }
     }
     catch (Exception ex)
     { Helper.dbgLog("Exception while loading config values.", ex, true); }
 }
Esempio n. 2
0
 public static void Serialize(string filename, Configuration config)
 {
     var serializer = new XmlSerializer(typeof(Configuration));
     try
     {
         using (var writer = new StreamWriter(filename))
         {
             serializer.Serialize(writer, config);
         }
     }
     catch (System.IO.IOException ex1)
     {
         Helper.dbgLog("Filesystem or IO Error: \r\n", ex1, true);
     }
     catch (Exception ex1)
     {
         Helper.dbgLog(ex1.Message.ToString() + "\r\n", ex1, true);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Constrain certain values read in from the config file that will either cause issue or just make no sense. 
 /// </summary>
 /// <param name="tmpConfig"> An instance of an initialized Configuration object (byref)</param>
 public static void ValidateConfig(ref Configuration tmpConfig)
 {
 }