AddSetting() public method

public AddSetting ( string section, string setting ) : void
section string
setting string
return void
Esempio n. 1
0
        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;           
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 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();
 }