Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        /// <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 );
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Writes the configuration to the default config file
 /// </summary>
 public static void Write( EngineOptions engineOptions)
 {
     WriteToFile( engineOptions, DefaultConfigFilePath );
 }