Example #1
0
 /// <summary>
 /// SAve a Configuration to file
 /// </summary>
 /// <param name="config">Configuration to be saved</param>
 /// <returns>True if Serialization succeeded : False otherwise</returns>
 public static bool SaveConfiguration(Config config)
 {
     try
     {
         SerializableConfig serializable = new SerializableConfig(config);
         Serializer.SerializeObj(serializable, $"{WorkingDirectoryPath}{ConfigFilename}");
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Example #2
0
        /// <summary>
        /// Get a Configuration from file
        /// </summary>
        /// <param name="filename">Path + filename of configuration file</param>
        /// <returns>A Config if the Deserialization succeeded : null otherwise</returns>
        public static Config ReadConfiguration()
        {
            Config newConfig = null;

            try
            {
                SerializableConfig serializable = Serializer.DeserializeObj <SerializableConfig>($"{WorkingDirectoryPath}{ConfigFilename}");
                newConfig = serializable.Deserialize();
            }
            catch
            {
                // No config file found
                newConfig = new Config();
            }

            return(newConfig);
        }