Beispiel #1
0
        public void Run()
        {
            var matcherPeriod = TimeSpan.FromMilliseconds(this.options.MatcherWaitTime);
            var brokerPeriod  = TimeSpan.FromMilliseconds(this.options.BrokerWaitTime);

            var matcherManager = new MatcherManager(this.options.Companies, this.context, matcherPeriod);
            var brokerManager  = new BrokerManager(this.options.Companies, this.context, "broker", brokerPeriod);

            matcherManager.Start(this.options.NumberOfMatchers);
            brokerManager.Start(this.options.NumberOfBrokers);

            this.logger.LogInformation($"cql version {this.context.GetCqlVersion()}; app started");

            if (this.options.UseConsistencyMonitor)
            {
                var monitorPeriod = TimeSpan.FromMilliseconds(this.options.ConsistencyMonitorWaitTime);
                var monitor       = new ConsistencyMonitor(this.options.Companies, this.context, this.logger, monitorPeriod);
                monitor.Start();
            }
            else
            {
                matcherManager.Wait();
                brokerManager.Wait();
            }
        }
Beispiel #2
0
        internal static Hashtable[] GetMatchColors <T>()
        {
            IColorMatcher <T> matcher = (IColorMatcher <T>)MatcherManager.GetMatcher(typeof(T));

            return((from match in matcher.GetMatches()
                    select new Hashtable {
                [HashtableColor] = match.ForegroundColor,
                [HashtableMatch] = match.GetMatchData()
            }).ToArray());
        }
Beispiel #3
0
        internal static void SetMatcherColors <T>(Hashtable[] matcherColors)
        {
            IColorMatcher <T> matcher = (IColorMatcher <T>)MatcherManager.GetMatcher(typeof(T));

            var matches = from matcherColor in matcherColors
                          let foregroundColor                         = (ConsoleColor)matcherColor[HashtableColor]
                                                            let match = matcherColor[HashtableMatch]
                                                                        select matcher.CreateMatch(foregroundColor, match);

            matcher.SetMatches(matches);
        }
Beispiel #4
0
        public static string GetAnsiString(object target)
        {
            IColorMatcher colorMatcher;

            if (!MatcherManager.TryGetMatcher(target.GetType(), out colorMatcher))
            {
                return(ColorReset);
            }

            IColorMatch match = colorMatcher.GetMatch(target);

            return(match == null ? ColorReset : sForegroundAnsiColors[match.ForegroundColor]);
        }
Beispiel #5
0
 protected EntitiesContext()
 {
     Manager = new TrimManager(this);
     Matcher = new MatcherManager(Manager);
 }
Beispiel #6
0
        static AnsiColorOut()
        {
            sFileInfoColorMatcher = new Lazy <IColorMatcher>(() => MatcherManager.GetMatcher(typeof(FileSystemInfo)));

            sProcessColorMatcher = new Lazy <IColorMatcher>(() => MatcherManager.GetMatcher(typeof(Process)));

            sForegroundAnsiColors = new Dictionary <ConsoleColor, string> {
                { ConsoleColor.DarkGray, "\x1B[1;30m" },
                { ConsoleColor.Black, "\x1B[0;30m" },

                { ConsoleColor.Red, "\x1B[1;31m" },
                { ConsoleColor.DarkRed, "\x1B[0;31m" },

                { ConsoleColor.Green, "\x1B[1;32m" },
                { ConsoleColor.DarkGreen, "\x1B[0;32m" },

                { ConsoleColor.Yellow, "\x1B[1;33m" },
                { ConsoleColor.DarkYellow, "\x1B[0;33m" },

                { ConsoleColor.Blue, "\x1B[1;34m" },
                { ConsoleColor.DarkBlue, "\x1B[0;34m" },

                { ConsoleColor.Magenta, "\x1B[1;35m" },
                { ConsoleColor.DarkMagenta, "\x1B[0;35m" },

                { ConsoleColor.Cyan, "\x1B[1;36m" },
                { ConsoleColor.DarkCyan, "\x1B[0;36m" },

                { ConsoleColor.White, "\x1B[1;37m" },
                { ConsoleColor.Gray, "\x1B[0;37m" },
            };

            sBackgroundAnsiColors = new Dictionary <ConsoleColor, string> {
                { ConsoleColor.DarkGray, "\x1B[1;40m" },
                { ConsoleColor.Black, "\x1B[0;40m" },

                { ConsoleColor.Red, "\x1B[1;41m" },
                { ConsoleColor.DarkRed, "\x1B[0;41m" },

                { ConsoleColor.Green, "\x1B[1;42m" },
                { ConsoleColor.DarkGreen, "\x1B[0;42m" },

                { ConsoleColor.Yellow, "\x1B[1;43m" },
                { ConsoleColor.DarkYellow, "\x1B[0;43m" },

                { ConsoleColor.Blue, "\x1B[1;44m" },
                { ConsoleColor.DarkBlue, "\x1B[0;44m" },

                { ConsoleColor.Magenta, "\x1B[1;45m" },
                { ConsoleColor.DarkMagenta, "\x1B[0;45m" },

                { ConsoleColor.Cyan, "\x1B[1;46m" },
                { ConsoleColor.DarkCyan, "\x1B[0;46m" },

                { ConsoleColor.White, "\x1B[1;47m" },
                { ConsoleColor.Gray, "\x1B[0;47m" },
            };

            ForegroundColorReset = "\x1B[39m";
            BackgroundColorReset = "\x1B[49m";
            ColorReset           = "\x1B[0m";
        }