private void SaveSettings() { ConfigNode CN = new ConfigNode(); FieldInfo[] FI = this.GetType().GetFields(); for (int indexFields = 0; indexFields < FI.Length; indexFields++) { FieldInfo currentFI = FI[indexFields]; if (currentFI.IsPublic && currentFI.IsStatic) { IConfigNode tempCN = currentFI.GetValue(this) as IConfigNode; if (null != tempCN) { tempCN.Save(CN.AddNode(currentFI.Name)); } else { CN.AddValue(currentFI.Name, Convert.ToString(currentFI.GetValue(this))); } } } string filePath = Path.ChangeExtension(typeof(StockBugFixPlusController).Assembly.Location, ".cfg"); Debug.Log("Saving StockBugFix and StockPlus Settings: " + filePath); CN.Save(filePath, "StockBugFix and StockPlus Settings"); }
public static string ToConfigString(this IConfigNode inode) { if (inode == null) { return(""); } var node = new ConfigNode(inode.GetID()); inode.Save(node); return(node.ToString()); }