public bool ToIni(string inifilename = "DataStore") { string inipath = Path.Combine(Util.GetPublicFolder(), RemoveChars(inifilename).Trim() + ".ini"); File.WriteAllText(inipath, ""); IniParser ini = new IniParser(inipath); ini.Save(); foreach (string section in this.datastore.Keys) { Hashtable ht = (Hashtable)this.datastore[section]; foreach (object setting in ht.Keys) { try { string key = "NullReference"; string val = "NullReference"; if (setting != null) { if (setting.GetType().GetMethod("ToString", Type.EmptyTypes) == null) { key = "type:" + setting.GetType().ToString(); } else { key = setting.ToString(); } } if (ht[setting] != null) { if (ht[setting].GetType().GetMethod("ToString", Type.EmptyTypes) == null) { val = "type:" + ht[setting].GetType().ToString(); } else { val = ht[setting].ToString(); } } ini.AddSetting(section, key, val); } catch (Exception ex) { Logger.LogException(ex); } } } ini.Save(); return(true); }
public bool TableToIni(string tablename, string inipath) { Hashtable hashtable = (Hashtable)this.datastore[tablename]; if (hashtable != null) { if (!Path.HasExtension(inipath)) { inipath += ".ini"; } File.WriteAllText(inipath, ""); IniParser ini = new IniParser(inipath); ini.Save(); foreach (string setting in hashtable.Keys) { ini.AddSetting(tablename, setting, hashtable[setting].ToString()); } ini.Save(); return(true); } return(false); }
public void ToIni() { var ini = new IniParser(path); ini.AddSetting("Def", "itemCount", itemCount.ToString()); ini.AddSetting("Def", "ownerCanUse", OwnerUse.ToString()); ini.AddSetting("Def", "modCanUse", ModeratorUse.ToString()); ini.AddSetting("Def", "normalCanUse", NormalUse.ToString()); for (var i = 0; i < itemCount; i++) { ini.AddSetting(i.ToString(), "Name", items[i].Name); ini.AddSetting(i.ToString(), "Amount", items[i].Amount.ToString()); } ini.Save(); }
public void Items() { var path = Path.Combine(GetPublicFolder(), "Items.ini"); if (!File.Exists(path)) { File.AppendAllText("", path); } var ini = new IniParser(path); foreach (ItemDefinition item in ItemManager.Instance.itemList) { ini.AddSetting(item.displayName.english, "itemid", item.itemid.ToString()); ini.AddSetting(item.displayName.english, "category", item.category.ToString()); ini.AddSetting(item.displayName.english, "shortname", item.shortname); ini.AddSetting(item.displayName.english, "description", item.displayDescription.english); } ini.Save(); }
public void Initialize() { string ConfigPath = DirectoryConfig.GetInstance().GetConfigPath("Core"); if (File.Exists(ConfigPath)) { ConfigFile = new IniParser(ConfigPath); Debug.Log("Config " + ConfigPath + " loaded!"); } else { File.Create(ConfigPath).Close(); ConfigFile = new IniParser(ConfigPath); Debug.Log("Core config " + ConfigPath + " Created!"); Debug.Log("The config will be filled with the default values."); GenerateConfig(); ConfigFile.Save(); } }
public bool ToIni(string inifilename = "DataStore") { string inipath = Path.Combine(Util.GetPublicFolder(), RemoveChars(inifilename).Trim() + ".ini"); File.WriteAllText(inipath, ""); IniParser ini = new IniParser(inipath); ini.Save(); foreach (string section in this.datastore.Keys) { Hashtable ht = (Hashtable)this.datastore[section]; foreach (object setting in ht.Keys) { try { string key = "NullReference"; string val = "NullReference"; if (setting != null) { if (setting.GetType().GetMethod("ToString", Type.EmptyTypes) == null) { key = "type:" + setting.GetType().ToString(); } else { key = setting.ToString(); } } if (ht[setting] != null) { if (ht[setting].GetType().GetMethod("ToString", Type.EmptyTypes) == null) { val = "type:" + ht[setting].GetType().ToString(); } else { val = ht[setting].ToString(); } } ini.AddSetting(section, key, val); } catch (Exception ex) { Logger.LogException(ex); } } } ini.Save(); return true; }
public void Initialize() { string ConfigPath = Path.Combine(Util.GetServerFolder(), "DirectoryConfig.cfg"); if (File.Exists(ConfigPath)) { DirConfig = new IniParser(ConfigPath); Debug.Log("Config " + ConfigPath + " loaded!"); } else { char sc = Path.DirectorySeparatorChar; Directory.CreateDirectory(Util.GetPublicFolder()); File.Create(ConfigPath).Close(); DirConfig = new IniParser(ConfigPath); Debug.Log("Config " + ConfigPath + " Created!"); Debug.Log("The config will be filled with the default values."); DirConfig.AddSetting("Directories", "Core", "%data%" + sc + "Core.cfg"); DirConfig.AddSetting("Directories", "Pluton", "%public%" + sc + "Pluton.cfg"); DirConfig.AddSetting("Directories", "Hashes", "%data%" + sc + "Hashes.ini"); DirConfig.Save(); } }
public bool TableToIni(string tablename, string inipath) { Hashtable hashtable = (Hashtable)this.datastore[tablename]; if (hashtable != null) { if (!Path.HasExtension(inipath)) inipath += ".ini"; File.WriteAllText(inipath, ""); IniParser ini = new IniParser(inipath); ini.Save(); foreach (string setting in hashtable.Keys) { ini.AddSetting(tablename, setting, hashtable[setting].ToString()); } ini.Save(); return true; } return false; }