コード例 #1
0
        private static void Serialize(RealTimeConfig config)
        {
            var serializer = new XmlSerializer(typeof(RealTimeConfig));

            using (var sw = new StreamWriter(SettingsFileName))
            {
                serializer.Serialize(sw, config);
            }
        }
コード例 #2
0
 public static void SaveConfiguration(RealTimeConfig config)
 {
     try
     {
         Serialize(config);
     }
     catch (Exception ex)
     {
         Log.Error("The 'Real Time' mod cannot save its configuration, error message: " + ex.Message);
     }
 }
コード例 #3
0
        /// <summary>
        /// Stores the provided <paramref name="config"/> object to the storage.
        /// </summary>
        ///
        /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
        ///
        /// <param name="config">A <see cref="RealTimeConfig"/> object to store.</param>
        public static void SaveConfiguration(RealTimeConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            try
            {
                Serialize(config);
            }
            catch (Exception ex)
            {
                Log.Error("The 'Real Time' mod cannot save its configuration, error message: " + ex);
            }
        }