/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of %APPDATA%\EDDI\netlog.json is used /// </summary> public static NetLogConfiguration FromFile(string filename = null) { if (filename == null) { String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI"; Directory.CreateDirectory(dataDir); filename = dataDir + "\\netlog.json"; } NetLogConfiguration configuration; try { String configurationData = File.ReadAllText(filename); configuration = JsonConvert.DeserializeObject <NetLogConfiguration>(configurationData); configuration.dataPath = filename; } catch { configuration = new NetLogConfiguration(); configuration.dataPath = filename; // See if there was old information present String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI"; string oldFilename = dataDir + "\\productpath"; try { string path = File.ReadAllText(oldFilename); if (path != null) { configuration.path = path; configuration.ToFile(); File.Delete(oldFilename); } } catch { } } return(configuration); }
/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of %APPDATA%\EDDI\netlog.json is used /// </summary> public static NetLogConfiguration FromFile(string filename=null) { if (filename == null) { String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI"; Directory.CreateDirectory(dataDir); filename = dataDir + "\\netlog.json"; } NetLogConfiguration configuration; try { String configurationData = File.ReadAllText(filename); configuration = JsonConvert.DeserializeObject<NetLogConfiguration>(configurationData); configuration.dataPath = filename; } catch { configuration = new NetLogConfiguration(); configuration.dataPath = filename; // See if there was old information present String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI"; string oldFilename = dataDir + "\\productpath"; try { string path = File.ReadAllText(oldFilename); if (path != null) { configuration.path = path; configuration.ToFile(); File.Delete(oldFilename); } } catch { } } return configuration; }
public NetLogMonitor(NetLogConfiguration configuration, Action <dynamic> callback, bool enableDebugging = false) : base(configuration.path, @"netLog", enableDebugging, (result) => HandleNetLogLine(result, callback)) { }
private void updateNetLogConfiguration() { NetLogConfiguration netLogConfiguration = new NetLogConfiguration(); if (!String.IsNullOrWhiteSpace(netLogPathTextBox.Text)) { netLogConfiguration.path = netLogPathTextBox.Text.Trim(); } netLogConfiguration.ToFile(); }
public static void StartLogMonitor(NetLogConfiguration configuration) { if (configuration != null) { NetLogMonitor monitor = new NetLogMonitor(configuration, (result) => LogQueue.Add(result)); monitor.start(); } }
public NetLogMonitor(NetLogConfiguration configuration, Action<dynamic> callback) : base(configuration.path, @"netLog", (result) => HandleNetLogLine(result, callback)) { }