Example #1
0
        private void PrintServerModule(IServerModule module, IEnumerable <string> printOptions)
        {
            var versionAttribute = module.GetType().Assembly.GetCustomAttribute <AssemblyFileVersionAttribute>();

            Console.Write("    " + module.Name.PadRight(30));

            var warningCount = module.Notifications.Count(n => n.Severity == Severity.Warning);
            var errorCount   = module.Notifications.Count(n => n.Severity >= Severity.Error);

            Console.Write(" (");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(warningCount);
            Console.ResetColor();
            Console.Write(" | ");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(errorCount);
            Console.ResetColor();
            Console.Write(")");

            Console.CursorLeft = 50;
            CommandHelper.PrintState(module.State, false, 17);
            Console.WriteLine("Version: " + (versionAttribute == null ? "N/A" : versionAttribute.Version));

            if (printOptions == null)
            {
                return;
            }

            Console.WriteLine();
            foreach (var printOption in printOptions)
            {
                switch (printOption)
                {
                case "-e":
                    var relevantNotifications = module.Notifications
                                                .Where(n => n.Severity >= Severity.Warning)
                                                .OrderBy(n => n.Timestamp).ToArray();
                    if (!relevantNotifications.Any())
                    {
                        break;
                    }

                    Console.WriteLine("Notifications for " + module.Name + ":");
                    foreach (var notification in relevantNotifications)
                    {
                        PrintNotification(notification);
                    }
                    break;

                case "-d":
                    Console.WriteLine("Dependencies of " + module.Name + ":");
                    foreach (var startDependency in ModuleManager.StartDependencies(module))
                    {
                        Console.WriteLine(" Module: " + startDependency.Name.PadRight(29) + "State: " +
                                          startDependency.State);
                    }
                    break;

                default:
                    break;
                }
            }
        }