Esempio n. 1
0
        private static void SaveConfig(Type type, IConfigurable configurable)
        {
            //var configPath = $"Config\\{type.Name}.xml";
            var configPath = Path.Combine("Config", $"{type.Name}.xml");

            Log.Config.Trace($"Saving config file: {configPath}");

            try
            {
                // Serialize config
                var document = new XDocument();
                {
                    var rootElement = new XElement(type.Name);
                    configurable.Serialize(rootElement);
                    document.Add(rootElement);
                }

                document.Save(configPath);
            }
            catch (Exception e)
            {
                Log.Config.Error($"Failed to save config file: {configPath}");
                Log.Config.Trace(e.Message);
            }
        }