public LuaSet GetSetting(string name) { if (LuaSettings.ContainsKey(name)) { return(LuaSettings[name]); } else { return(null); } }
public void AddSetting(string Name, string Folder, string LuaExecutable, string WorkingPath, string CommandLine, EncodingName Encoding) { var set = new LuaSet(Folder, LuaExecutable, WorkingPath, CommandLine, Encoding); if (LuaSettings.ContainsKey(Name)) { LuaSettings[Name] = set; } else { LuaSettings.Add(Name, set); } XElement element = null; foreach (var xl in XMLLuaSettings.Elements(SettingConstants.SettingKeys.Set)) { if (xl.Element(SettingConstants.SettingKeys.SetName).Value.Contains(Name)) { element = xl; break; } } if (element == null) { element = new XElement(SettingConstants.SettingKeys.Set); element.Add(new XElement(SettingConstants.SettingKeys.SetName, Name)); element.Add(new XElement(SettingConstants.SettingKeys.LuaFolder, Folder)); element.Add(new XElement(SettingConstants.SettingKeys.LuaExec, LuaExecutable)); element.Add(new XElement(SettingConstants.SettingKeys.WorkingPath, WorkingPath)); element.Add(new XElement(SettingConstants.SettingKeys.LuaExecArg, CommandLine)); element.Add(new XElement(SettingConstants.SettingKeys.FileEncoding, Encoding)); XMLLuaSettings.Add(element); } else { element.ReplaceNodes( new XElement(SettingConstants.SettingKeys.SetName, Name), new XElement(SettingConstants.SettingKeys.LuaFolder, Folder), new XElement(SettingConstants.SettingKeys.LuaExec, LuaExecutable), new XElement(SettingConstants.SettingKeys.WorkingPath, WorkingPath), new XElement(SettingConstants.SettingKeys.LuaExecArg, CommandLine), new XElement(SettingConstants.SettingKeys.FileEncoding, Encoding) ); } }
public void RemoveSetting(string name) { XElement element = null; foreach (var xl in XMLLuaSettings.Elements(SettingConstants.SettingKeys.Set)) { if (xl.Element(SettingConstants.SettingKeys.SetName).Value.Contains(name)) { element = xl; break; } } if (element != null) { element.Remove(); } if (LuaSettings.ContainsKey(name)) { LuaSettings.Remove(name); } }
public bool ContainsSetting(string name) { return(LuaSettings.ContainsKey(name)); }