コード例 #1
0
        private void UpdateLogDescription(object sender, ConfigChangedEventArgs e)
        {
            LogDescriptionConfig logDescriptionConfig = CreateLogDescription(e.ConfigPath);

            RemoveLogDescription(e.ConfigPath);
            AddLogDescription(e.ConfigPath, logDescriptionConfig);
        }
コード例 #2
0
        public override bool Equals(ChangeMonitorableConfigFile other)
        {
            LogDescriptionConfig o = other as LogDescriptionConfig;

            if (other == null)
            {
                return(false);
            }
            return(this.Equals(o));
        }
コード例 #3
0
 public bool Equals(LogDescriptionConfig other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.FileMask.ToString(), FileMask.ToString()) &&
            Equals(other.Encoding, Encoding) &&
            Equals(other.Id, Id) &&
            Equals(other.ConfigFileName, ConfigFileName) &&
            other.LogDirectories.Count == LogDirectories.Count &&
            other.LogDirectories.All(dir => LogDirectories.Contains(dir));
 }
コード例 #4
0
 private static LogDescriptionConfig CreateLogDescription(string fullPath)
 {
     LogDescriptionConfig logDescriptionConfig = null;
     try
     {
         FileInfo fileInfo = new FileInfo(fullPath);
         logDescriptionConfig = new LogDescriptionConfig(fileInfo.FullName);
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot create LogDescription from config file " + fullPath + ": " + ex);
     }
     return logDescriptionConfig;
 }
コード例 #5
0
        private static LogDescriptionConfig CreateLogDescription(string fullPath)
        {
            LogDescriptionConfig logDescriptionConfig = null;

            try
            {
                FileInfo fileInfo = new FileInfo(fullPath);
                logDescriptionConfig = new LogDescriptionConfig(fileInfo.FullName);
            }
            catch (Exception ex)
            {
                _logger.Error("Cannot create LogDescription from config file " + fullPath + ": " + ex);
            }
            return(logDescriptionConfig);
        }
コード例 #6
0
 public bool Equals(LogDescriptionConfig other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.FileMask.ToString(), FileMask.ToString()) &&
            Equals(other.Encoding, Encoding) &&
            Equals(other.Id, Id) &&
            Equals(other.ConfigFileName, ConfigFileName) &&
            other.LogDirectories.Count == LogDirectories.Count &&
            other.LogDirectories.All(dir => LogDirectories.Contains(dir)));
 }
コード例 #7
0
        private void AddLogDescription(string fullPath, LogDescriptionConfig logDescriptionConfig)
        {
            if (logDescriptionConfig == null) return;
            _rwLocker.EnterWriteLock();
            try
            {
                if (_logDescriptions.ContainsKey(fullPath))
                {

                    _logger.Warn(String.Format("LogDescription from file {0} already added. Recreating it.", fullPath));
                    return;
                }
                _logDescriptions.Add(fullPath, logDescriptionConfig);
                logDescriptionConfig.ConfigChanged += UpdateLogDescription;
                logDescriptionConfig.ConfigRenamed += RenameLogDescription;
                logDescriptionConfig.WatchForChanges();

            }
            finally
            {
                _rwLocker.ExitWriteLock();
            }
        }
コード例 #8
0
 private void AddLogDescription(string fullPath, LogDescriptionConfig logDescriptionConfig)
 {
     if (logDescriptionConfig == null)
     {
         return;
     }
     _rwLocker.EnterWriteLock();
     try
     {
         if (_logDescriptions.ContainsKey(fullPath))
         {
             _logger.Warn(String.Format("LogDescription from file {0} already added. Recreating it.", fullPath));
             return;
         }
         _logDescriptions.Add(fullPath, logDescriptionConfig);
         logDescriptionConfig.ConfigChanged += UpdateLogDescription;
         logDescriptionConfig.ConfigRenamed += RenameLogDescription;
         logDescriptionConfig.WatchForChanges();
     }
     finally
     {
         _rwLocker.ExitWriteLock();
     }
 }