/// <summary> /// Saves the current BamConf into the specified root /// </summary> /// <param name="rootDir">The directory to save into</param> /// <param name="overwrite">If true, overwrite any existing file</param> /// <param name="format">The file format to use, will affect the resulting file extension</param> public void Save(string rootDir, bool overwrite = false, ConfFormat format = ConfFormat.Json) { string filePath = "."; switch (format) { case ConfFormat.Yaml: filePath = Path.Combine(rootDir, "{0}.yaml"._Format(typeof(BamConf).Name)); if (overwrite || !File.Exists(filePath)) { this.ToYaml().SafeWriteToFile(filePath, overwrite); } break; case ConfFormat.Json: filePath = Path.Combine(rootDir, "{0}.json"._Format(typeof(BamConf).Name)); if (overwrite || !File.Exists(filePath)) { this.ToJson(true).SafeWriteToFile(filePath, overwrite); } break; case ConfFormat.Xml: filePath = Path.Combine(rootDir, "{0}.xml"._Format(typeof(BamConf).Name)); if (overwrite || !File.Exists(filePath)) { this.ToXml().SafeWriteToFile(filePath, overwrite); } break; } }
/// <summary> /// Saves the current configuration if the config /// file doesn't currently exist /// </summary> /// <param name="format">The format to save the configuration in</param> /// <param name="overwrite">If true overwrite the existing cofig file</param> /// <returns>The BamConf</returns> public BamConf SaveConf(bool overwrite = false, ConfFormat format = ConfFormat.Json) { BamConf conf = GetCurrentConf(); conf.Save(ContentRoot, overwrite, format); OnSavedConf(conf); return(conf); }
public void Save(bool overwrite = false, ConfFormat format = ConfFormat.Json) { Save(ContentRoot, overwrite, format); }