Example #1
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)
 {
     //put some stuff here to validate and change actual values of the config object
     //if you think they are out of bounds, like if you have a display
     //refresh rate and you want to set limits around it.
     if (tmpConfig.GuiOpacity > 1.0f | tmpConfig.GuiOpacity < 0.10f) tmpConfig.GuiOpacity = 1.0f;
     if (tmpConfig.AutoRefreshSeconds > 60.0f | tmpConfig.AutoRefreshSeconds < 1.0f) tmpConfig.AutoRefreshSeconds = 3.0f;
 }
Example #2
0
 //Save the given instance of your config data to disk as XML
 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)
     {
         Logger.dbgLog("Filesystem or IO Error: \r\n", ex1, true);
     }
     catch (Exception ex1)
     {
         Logger.dbgLog(ex1.Message.ToString() + "\r\n", ex1, true);
     }
 }