コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
 public NetLogMonitor(NetLogConfiguration configuration, Action <dynamic> callback, bool enableDebugging = false) : base(configuration.path, @"netLog", enableDebugging, (result) => HandleNetLogLine(result, callback))
 {
 }
コード例 #4
0
 private void updateNetLogConfiguration()
 {
     NetLogConfiguration netLogConfiguration = new NetLogConfiguration();
     if (!String.IsNullOrWhiteSpace(netLogPathTextBox.Text))
     {
         netLogConfiguration.path = netLogPathTextBox.Text.Trim();
     }
     netLogConfiguration.ToFile();
 }
コード例 #5
0
 public static void StartLogMonitor(NetLogConfiguration configuration)
 {
     if (configuration != null)
     {
         NetLogMonitor monitor = new NetLogMonitor(configuration, (result) => LogQueue.Add(result));
         monitor.start();
     }
 }
コード例 #6
0
 public NetLogMonitor(NetLogConfiguration configuration, Action<dynamic> callback)
     : base(configuration.path, @"netLog", (result) => HandleNetLogLine(result, callback))
 {
 }