public void Add(IModuleNotification item)
        {
            lock (_lockObj)
                _internalList.Add(item);

            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item));
        }
Beispiel #2
0
        /// <summary>
        /// Prints a module notification to the console
        /// </summary>
        private static void PrintNotification(IModuleNotification notification)
        {
            var dashes = Enumerable.Repeat("-", Console.WindowWidth);
            var line   = dashes.Aggregate((sum, next) => sum + next);

            Console.WriteLine(line);

            Console.WriteLine("Timestamp: " + notification.Timestamp);

            Console.Write("Severity: ");

            if (notification.Severity == Severity.Warning)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }

            if (notification.Severity >= Severity.Error)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }

            Console.WriteLine(notification.Severity);
            Console.ResetColor();

            Console.WriteLine("Message: " + notification.Message);
            Console.Write("Exception: ");

            if (notification.Exception != null)
            {
                Console.WriteLine(Environment.NewLine + ExceptionPrinter.Print(notification.Exception));
            }
        }
        public bool Contains(IModuleNotification item)
        {
            bool contains;

            lock (_lockObj)
                contains = _internalList.Contains(item);

            return(contains);
        }
        public bool Remove(IModuleNotification item)
        {
            bool removed;

            lock (_lockObj)
                removed = _internalList.Remove(item);

            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item));
            return(removed);
        }
 /// <summary>
 /// Constructor for a notification.
 /// </summary>
 /// <param name="notification">A notification raisded by a module.</param>
 public NotificationModel(IModuleNotification notification)
 {
     Timestamp = notification.Timestamp;
     if (notification.Exception != null)
     {
         Exception = new SerializableException(notification.Exception);
     }
     Message  = notification.Message;
     Severity = notification.Severity;
 }
 /// <inheritdoc />
 void IServerModuleStateContext.LogNotification(IModuleNotification notification)
 {
     Notifications.Add(notification);
 }