Esempio n. 1
0
        /// <summary>
        /// Process udp log message by the current processors and optionally perform the <paramref name="action"/>.
        /// </summary>
        /// <param name="item">Log item.</param>
        /// <param name="action">Action to perform if the processors allow it (see
        ///		<see cref="ProcessingResult.ShowToUser"/>.
        ///	</param>
        public void ProcessMessage(LogItem item, Action <IProcessor, ProcessingResult> action)
        {
            IProcessor[] processors;
            lock (_processorsLock)
            {
                processors = CurrentProcessors.Where(a => a.Enabled).ToArray();
            }

            ProcessingResult res      = null;
            IProcessor       stopping = null;

            foreach (var p in processors)
            {
                ProcessingResult r = p.Process(item, null);
                if (r.Stop)
                {
                    res      = r;
                    stopping = p;
                    break;
                }
            }

            if (res != null && !res.ShowToUser)
            {
                return;
            }

            action(stopping, res);
        }
Esempio n. 2
0
 /// <summary>
 /// Called to notify the processors that they will not be used any more.
 /// </summary>
 public void CloseProcessors()
 {
     lock (_processorsLock)
     {
         List <string> _errors = new List <string>();
         CurrentProcessors.ForEach(
             p =>
         {
             try { p.Close(); }
             catch (Exception ex) { _errors.Add(string.Format("Unable to close {0}. {1}", p.ToString(), ex)); }
         });
         if (_errors.Count > 0)
         {
             throw new ApplicationException(string.Join("\n", _errors));
         }
     }
 }