ResetColor() public static méthode

public static ResetColor ( ) : void
Résultat void
Exemple #1
0
        static void Main(string[] args)
        {
            // This reference is needed to ensure that the sqlite binaries get copied to
            // the output directory correctly.
#pragma warning disable 168
            SQLiteConnection connection;
#pragma warning restore 168

            Logger.SetOutputType(Logger.OutputType.Console);
            Logger.OutputLogLevel = Logger.LogLevel.Debug;

            // Initialize the runtime (load configuration, etc.)
            ServiceRuntime.Instance.Initialize();

            ServiceRuntime.Instance.OnNotify += (sender, eventArgs) =>
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("NOTIFY {0} from device {1} on server {2}",
                                  eventArgs.NotificationType,
                                  eventArgs.UpsContext.Name,
                                  eventArgs.UpsContext.UpsConfiguration.ServerConfiguration.DisplayName);
                Console.ResetColor();
            };

            // Start the WCF service and monitoring task
            ServiceRuntime.Instance.Start();

            Console.WriteLine("Runtime is active. Press ENTER to terminate.");
            Console.ReadLine();

            ServiceRuntime.Instance.Stop();
        }
Exemple #2
0
      public void PrintNameSpaceControllerNameMethodName(Type type)
      {
          C.ForegroundColor = ConsoleColor.Blue;
          StackTrace stackTrace = new StackTrace();
          StackFrame frame      = new StackFrame(skipFrames: 1, fNeedFileInfo: true);

          string methodName;

          try
          {
              methodName = stackTrace.GetFrame(index: 2).GetMethod().Name;
          }

          catch (ArgumentNullException ex)
          {
              methodName = stackTrace.GetFrame(index: 1).GetMethod().Name;
              C.WriteLine(ex.Message);
          }

          C.WriteLine($"NAME_SPACE : {type.Namespace}");
          C.WriteLine($"CONTROLLER : {type.Name}");
          C.WriteLine($"METHOD     : {methodName} @ LINE: {frame.GetFileLineNumber()}");

          C.ResetColor();
      }
Exemple #3
0
        public double ConvertCellWithPercentageSymbolToDouble(string s)
        {
            // _helpers.OpenMethod(1);
            double doubleValue = 0.00;

            // if the cell has data, parse the data
            try
            {
                string[] dataToConvert = s.Split('%');
                // doubleValue = double.Parse(dataToConvert[0], NumberStyles.None, CultureInfo.InvariantCulture);
                doubleValue = double.Parse(dataToConvert[0]);
            }

            // if the cell does not have data, error
            catch (ArgumentNullException nullException)
            {
                C.ForegroundColor = ConsoleColor.Red;
                C.WriteLine($"\nERROR:");
                C.ResetColor();
                C.WriteLine($"Issue converting string to double - likely because no data in csv cell");
                C.WriteLine($"In: CsvHandler > ConvertCellWithPercentageSymbolToDouble() Method\n");
                C.WriteLine($"nullException : {nullException}");
            }
            return(doubleValue);
        }
        private void ConfigureDirectory(Config config)
        {
            // Directory
            C.WriteLine("Output directory:");
            CC.WriteLine(ConsoleColor.DarkGray, "Enter nothing to use your 'My Music' directory.");
            C.ForegroundColor = ConsoleColor.Yellow;
            bool exists;

            do
            {
                config.Output.Directory = C.ReadLine();

                // My Music
                if (string.IsNullOrWhiteSpace(config.Output.Directory))
                {
                    config.Output.Directory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
                    C.SetCursorPosition(0, C.CursorTop - 1);
                    C.WriteLine(config.Output.Directory);
                }

                // Check validity
                exists = Directory.Exists(config.Output.Directory);
                if (!exists)
                {
                    CC.WriteLine(ConsoleColor.Red, "The directory does not exist. Please enter a valid directory.");
                }
            } while (!exists);

            C.ResetColor();
        }
        private void ExecuteCommand(string commandLine)
        {
            List <string> args = new List <string>(commandLine.Split(' '));

            if (args.Count == 0)
            {
                return;
            }
            string cmd = args[0].ToLower();

            try
            {
                IConsoleCommand command = AvailableCommands[cmd];
                args.RemoveAt(0);
                command.Execute(args.ToArray());
            }
            catch (KeyNotFoundException)
            {
                Con.ForegroundColor = ConsoleColor.Red;
                Con.WriteLine("Unknown command: '{0}'", cmd);
                Con.ResetColor();
            }
            catch (Exception e)
            {
                Con.ForegroundColor = ConsoleColor.Red;
                Con.WriteLine("There was an error while executing the command:\n{0}", e);
                Con.ResetColor();
            }
        }
Exemple #6
0
 internal static void WriteLine(string message, string colour)
 {
     lock (syncOutput)
     {
         Cons.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), colour);
         Cons.WriteLine(message);
         Cons.ResetColor();
     }
 }
Exemple #7
0
 public static void DisplayAssemblyInfo(string assemblyName, string assemblyVersion)
 {
     ForegroundColor = ConsoleColor.Green;
     SysConsole.WriteLine(new String('*', NumberOfChars) + "\r\n");
     SysConsole.WriteLine($"      {assemblyName}");
     SysConsole.WriteLine($"      version: {assemblyVersion}" + "\r\n");
     SysConsole.WriteLine(new String('*', NumberOfChars) + "\r\n");
     SysConsole.ResetColor();
 }
Exemple #8
0
      public void Intro(object obj, string str)
      {
          C.ForegroundColor = ConsoleColor.Green;
          StackFrame frame      = new StackFrame(1, true);
          int        lineNumber = frame.GetFileLineNumber();

          C.WriteLine($"\n{str.ToUpper()} --> {obj} --> [@ Line# {lineNumber}]\n");
          C.ResetColor();
      }
Exemple #9
0
 public void PrintNullPlayerBase(string firstName, string lastName)
 {
     C.ForegroundColor = ConsoleColor.Red;
     C.WriteLine($"\n****************************************************************");
     C.WriteLine($"PLAYER BASE DOES NOT EXIST FOR: {firstName} {lastName}");
     C.WriteLine($"See: {_sfbbPlayerIdMapConfiguration.Link}");
     C.WriteLine($"****************************************************************\n");
     C.ResetColor();
 }
Exemple #10
0
        public static void UseRational()
        {
            // The intend is stated much better than with new Tuple...
            var pi   = new Rational(22, 7);
            var diff = Abs(PI * pi.Item2 - pi.Item1) / pi.Item2;

            Terminal.ForegroundColor = Sys.ConsoleColor.Green;
            Terminal.WriteLine($"The difference to the real PI is {diff}.");
            Terminal.ResetColor();
        }
Exemple #11
0
 private static void Exit(int code = 0)
 {
     if (_manager.Config.KeepOpen)
     {
         C.ResetColor();
         C.WriteLine("Press Enter to exit...");
         C.ReadLine();
     }
     Environment.Exit(code);
 }
Exemple #12
0
 private void SetConsoleColorForEventLevel(EventLevel eventLevel)
 {
     if (_eventLevelColors.TryGetValue(eventLevel, out var color))
     {
         OutConsole.ForegroundColor = color;
     }
     else
     {
         OutConsole.ResetColor();
     }
 }
Exemple #13
0
 private static void CheckEnvironmentVersion()
 {
     if (string.Equals(Environment.Version.ToString(), "Production", StringComparison.Ordinal))
     {
         C.ForegroundColor = ConsoleColor.Red;
         C.WriteLine($"\n***************************************************");
         C.WriteLine("SWITCH TO DEV ENVIRONMENT");
         C.WriteLine($"***************************************************\n");
         C.ResetColor();
     }
 }
Exemple #14
0
      public void DigDeep <T>(T x)
      {
          C.ForegroundColor = ConsoleColor.DarkRed;

          using (StringWriter writer = new StringWriter())
          {
              ObjectDumper.Dumper.Dump(x, "Object Dumper", writer);
              C.Write(writer.ToString());
          }
          C.WriteLine();
          C.ResetColor();
      }
Exemple #15
0
      public void Highlight(string message)
      {
          string fullMessage = JsonConvert.SerializeObject(message, Formatting.Indented).ToUpper(CultureInfo.InvariantCulture);

          using (StringWriter writer = new StringWriter())
          {
              C.ForegroundColor = ConsoleColor.Magenta;
              C.WriteLine($"{fullMessage}");
              C.Write(writer.ToString());
              C.ResetColor();
          }
      }
Exemple #16
0
      public void PrintJObjectItems(JObject JObjectToPrint)
      {
          JObject responseToJson = JObjectToPrint;

          foreach (KeyValuePair <string, JToken> jsonItem in responseToJson)
          {
              C.ForegroundColor = ConsoleColor.DarkMagenta;
              C.WriteLine($"{jsonItem.Key.ToUpper()}");
              C.ResetColor();
              C.WriteLine($"{jsonItem.Value}\n");
          }
      }
Exemple #17
0
        public static void WriteWithColor(string text, ConsoleColor foreground, ConsoleColor?background = null)
        {
            SysConsole.ForegroundColor = foreground;

            if (background != null)
            {
                SysConsole.BackgroundColor = background.Value;
            }

            SysConsole.Write(text);
            SysConsole.ResetColor();
        }
Exemple #18
0
      public void Dig <T>(T x)
      {
          C.ForegroundColor = ConsoleColor.DarkCyan;
          string json = JsonConvert.SerializeObject(x, Formatting.Indented);

          C.WriteLine($"\n------------------------------------------------------------------");
          C.WriteLine("BEGIN DIG");
          C.WriteLine("------------------------------------------------------------------");
          C.WriteLine(json);
          C.WriteLine($"------------------------------------------------------------------\n");
          C.ResetColor();
      }
        private static int Main(string[] args)
        {
            C.WriteLine("-----------------------------------------------------------");
            C.WriteLine("---- Brutal Developer .NET Assembly Strong-Name Signer ----");
            C.WriteLine("-----------------------------------------------------------");
            C.WriteLine(((AssemblyDescriptionAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]).Description);
            C.WriteLine();

            try
            {
                var parsed = Args.Parse <Options>(args);

                if (args.Length == 0 || parsed.Help)
                {
                    ArgUsage.GetStyledUsage <Options>().Write();
                }
                else
                {
                    parsed.Validate();
                    var stats = SignAssemblies(parsed);

                    C.WriteLine();
                    C.WriteLine("{0} file(s) were strong-name signed.", stats.NumberOfSignedFiles);
                    C.WriteLine("{0} references(s) were fixed.", stats.NumberOfFixedReferences);
                }
            }
            catch (ArgException ex)
            {
                C.ForegroundColor = ConsoleColor.Red;
                C.WriteLine(ex.Message);
                C.ResetColor();

                ArgUsage.GetStyledUsage <Options>().Write();

                return(2);
            }
            catch (Exception ex)
            {
                C.ForegroundColor = ConsoleColor.Red;
                C.WriteLine(ex.ToString());
                C.ResetColor();

                return(1);
            }

            if (Debugger.IsAttached)
            {
                C.ReadKey(true);
            }

            return(0);
        }
        public void Emit(LogEvent logEvent)
        {
            if (logEvent == null)
            {
                throw new ArgumentNullException(nameof(logEvent));
            }

            var outputProperties = logEvent.Properties;
            var outputStream     = GetOutputStream(logEvent.Level);

            lock (_syncRoot)
            {
                try
                {
                    foreach (var outputToken in _outputTemplate.Tokens)
                    {
                        var propertyToken = outputToken as PropertyToken;
                        if (propertyToken == null)
                        {
                            RenderOutputTemplateTextToken(outputToken, outputProperties, outputStream);
                        }
                        else
                        {
                            switch (propertyToken.PropertyName)
                            {
                            case OutputProperties.LevelPropertyName:
                                RenderLevelToken(logEvent.Level, outputToken, outputProperties, outputStream);
                                break;

                            case OutputProperties.MessagePropertyName:
                                RenderMessageToken(logEvent, outputStream);
                                break;

                            case OutputProperties.ExceptionPropertyName:
                                RenderExceptionToken(propertyToken, outputProperties, outputStream);
                                break;

                            case "EventData":
                            case "Event":
                                RenderEventData(logEvent, outputStream);
                                break;

                            default:
                                RenderOutputTemplatePropertyToken(propertyToken, outputProperties, outputStream);
                                break;
                            }
                        }
                    }
                }
                finally { SysConsole.ResetColor(); }
            }
        }
Exemple #21
0
        public static void DisplayMenu(ConsoleColor consoleColor, List <string> menuItems)
        {
            ForegroundColor = consoleColor;

            SysConsole.WriteLine(new String('-', NumberOfChars));

            foreach (string menuItem in menuItems)
            {
                SysConsole.WriteLine(menuItem);
            }

            SysConsole.WriteLine(new String('-', NumberOfChars));
            SysConsole.ResetColor();
        }
Exemple #22
0
      // * If non-async method, set frameNumber to 1
      // * If async method, set frameNumber to 3
      public void OpenMethod(int frameNumber)
      {
          C.ForegroundColor = ConsoleColor.Green;

          StackTrace stackTrace      = new StackTrace();
          string     methodName      = stackTrace.GetFrame(index: frameNumber).GetMethod().Name;
          StackFrame frame           = new StackFrame(skipFrames: 1, fNeedFileInfo: true);
          string     fileName        = frame.GetFileName();
          int        lineNumber      = frame.GetFileLineNumber();
          string     fileNameTrimmed = Path.GetFileName(path: fileName);

          C.WriteLine($"OPEN  [ Line {lineNumber} @ {currentTime} ] {fileNameTrimmed} > {methodName} [{frameNumber}]");
          C.ResetColor();
      }
Exemple #23
0
      public void CloseMethod(int frameNumber)
      {
          C.ForegroundColor = ConsoleColor.Red;

          StackTrace stackTrace      = new StackTrace();
          string     methodName      = stackTrace.GetFrame(frameNumber).GetMethod().Name;
          StackFrame frame           = new StackFrame(1, fNeedFileInfo: true);
          string     fileName        = frame.GetFileName();
          int        lineNumber      = frame.GetFileLineNumber();
          string     fileNameTrimmed = Path.GetFileName(fileName);

          C.WriteLine($"CLOSE [ Line {lineNumber} @ {currentTime} ] {fileNameTrimmed} > {methodName} [{frameNumber}]");
          C.ResetColor();
      }
Exemple #24
0
 public void Draw(string a)
 {
     if (this.IsMonochrome)
     {
         C.ForegroundColor = ConsoleColor.Gray;
         C.WriteLine(a);
         C.ResetColor();
     }
     else
     {
         C.ForegroundColor = ConsoleColor.Green;
         C.WriteLine(a);
         C.ResetColor();
     }
 }
Exemple #25
0
      public void Spotlight(string message)
      {
          string fullMessage = JsonConvert.SerializeObject(message, Formatting.Indented).ToUpper(CultureInfo.InvariantCulture);

          StackFrame frame      = new StackFrame(skipFrames: 1, fNeedFileInfo: true);
          int        lineNumber = frame.GetFileLineNumber();

          using (StringWriter writer = new StringWriter())
          {
              C.ForegroundColor = ConsoleColor.Magenta;
              C.WriteLine($"{fullMessage} @ Line#: {lineNumber}");
              C.Write(writer.ToString());
              C.ResetColor();
          }
      }
        public void ConfirmThatWinnerAndLoserLengthsMatch(int[] winnerData, int[] loserData)
        {
            // * Check if there are equal # of ints in 'winnerData' and 'loserData'
            C.WriteLine($"winnerData.Length : {winnerData.Length}");
            C.WriteLine($"loserData.Length  : {loserData.Length}");

            // * Make sure the number of winning teams is same as number of losing teams
            // * Each matchup should have 1 winner and 1 loser
            if (winnerData.Length != loserData.Length)
            {
                C.ForegroundColor = ConsoleColor.Red;
                C.WriteLine($"\nLENGTH OF WINNER AND LOSER DATA DO NOT MATCH\n");
                C.ResetColor();
                throw new Exception();
            }
        }
Exemple #27
0
        public static void Write(ConsoleColor color, object value, bool beautify = false)
        {
            ForegroundColor = color;

            if (!beautify)
            {
                SysConsole.Write(value);
            }
            else
            {
                var array = value.ToString().Split("\\n").ToList();
                array.ForEach(l => WriteLine(ConsoleColor.Green, l));
            }

            SysConsole.ResetColor();
        }
Exemple #28
0
        /// <summary>
        /// Writes <paramref name="format"/> as an error text to the <see cref="SystemConsole"/>.
        /// </summary>
        /// <param name="format">A composite format string.</param>
        /// <param name="args">An array of objects to write using <paramref name="format"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is <c>null</c>.</exception>
        /// <exception cref="IOException">Thrown when an I/O error occurred.</exception>
        /// <exception cref="FormatException">Thrown when the format specification in <paramref name="format"/> is invalid.</exception>
        /// <seealso cref="SystemConsole.WriteLine(string, object[])"/>
        public static void WriteErrorLine(string format, params object[] args)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            SystemConsole.ForegroundColor = ConsoleColor.Red;
            SystemConsole.WriteLine(format, args);
            SystemConsole.ResetColor();
        }
        static async Task Main(string[] args)
        {
            try
            {
                RunAsync().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                SystemConsole.ForegroundColor = ConsoleColor.Red;
                SystemConsole.WriteLine(ex.Message);
                SystemConsole.ResetColor();
            }

            SystemConsole.WriteLine("Press any key to exit");
            SystemConsole.ReadKey();
        }
Exemple #30
0
      // See : https://msdn.microsoft.com/en-us/library/system.io.path.getfilename(v=vs.110).aspx
      public void CompleteMethod()
      {
          C.ForegroundColor = ConsoleColor.Blue;
          StackTrace stackTrace = new StackTrace();

          string methodName = stackTrace.GetFrame(1).GetMethod().Name;

          StackFrame frame = new StackFrame(1, true);

          string fileName   = frame.GetFileName();
          int    lineNumber = frame.GetFileLineNumber();

          string fileNameTrimmed = Path.GetFileName(fileName);

          C.WriteLine($"\n**********|\t{fileNameTrimmed} ---> COMPLETED {methodName}  [Line: {lineNumber} @ {currentTime}]\t|**********\n");

          C.ResetColor();
      }