public static bool DumpToFile(out string fileName) { string data; IDictionary <string, Func <string> > dumpables = DataDumper.GetDumpables(); Func <KeyValuePair <string, Func <string> >, string> getKey = kv => { try { return(kv.Value()); } catch (Exception e) { return("ERROR: " + e.Message); } }; lock (DataDumper.MyLock) { data = string.Join("\r\n", dumpables .ToDictionary(kv => kv.Key, getKey) .SafeSelect(kv => kv.Key + ":\r\n" + kv.Value) ); } bool success = DataDumper.DumpToLocalFile(data, out fileName); if (success) { // Allow admins to dump on behalf of server, also if (Main.netMode == 1) { if (ModHelpersMod.Instance.Config.DebugModeDumpAlsoServer || UserHelpers.HasBasicServerPrivilege(Main.LocalPlayer)) { PacketProtocolRequestToServer.QuickRequest <DataDumpProtocol>(-1); } } } return(success); }
//////////////// public static void SetDumpSource(string name, Func <string> dump) { var dumpables = DataDumper.GetDumpables(); lock (DataDumper.MyLock) { dumpables[name] = dump; } }