/// <summary> /// Reads the configuration from the given file /// </summary> /// <param name="xmlPath"></param> public static EngineOptions ReadFromFile( String xmlPath ) { EngineOptions engineOptions = new EngineOptions(); // deserialize configuration options try { XmlSerializer serializer = new XmlSerializer( typeof ( EngineOptions ) ); TextReader reader = new StreamReader( xmlPath ); engineOptions = ( EngineOptions ) serializer.Deserialize( reader ); reader.Close( ); } catch ( Exception e ) { throw new ConfigurationReadException( "Error while reading configuration.", e ); } return engineOptions; }
/// <summary> /// Stores the configuration to the given file /// </summary> /// <param name="xmlPath"></param> public static void WriteToFile( EngineOptions engineOptions, String xmlPath ) { if ( engineOptions == null ) { return; } try { XmlSerializer serializer = new XmlSerializer( typeof ( EngineOptions ) ); TextWriter writer = new StreamWriter( xmlPath ); serializer.Serialize( writer, engineOptions ); writer.Close( ); } catch ( Exception e ) { throw new ConfigurationReadException( "Error while writig configuration.", e ); } }
/// <summary> /// Writes the configuration to the default config file /// </summary> public static void Write( EngineOptions engineOptions) { WriteToFile( engineOptions, DefaultConfigFilePath ); }