Esempio n. 1
0
        public void Execute()
        {
            Ball ball = _factory.MakeBall();

            _console.Write(ball.ToString());
            ConsoleKeyInfo key = _console.Read();

            if (key.KeyChar == ' ')
            {
                _console.Write("Smash");
            }
        }
 public void VariablesCommand()
 {
     foreach (var keyValue in _variables)
     {
         _consoleHandler.Write(keyValue.Key + "  ", ConsoleOutputStyle.Output);
         _consoleHandler.WriteLine(keyValue.Value, ConsoleOutputStyle.Information);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Invalidate
        /// </summary>
        public void Invalidate()
        {
            var factor  = Math.Round((Percent / 100M), 1);
            var percent = Percent.ToString("0.0").PadLeft(5, ' ');

            if (_lastFactor == factor && _lastPercent == percent)
            {
                return;
            }

            _lastFactor  = factor;
            _lastPercent = percent;

            var fill  = string.Empty.PadLeft((int)(10 * factor), '■');
            var clean = string.Empty.PadLeft(10 - fill.Length, '■');

            _handler.SetCursorPosition(_x, _y);
            _handler.Write("[");
            _handler.Write(fill, ConsoleOutputStyle.Input);
            _handler.Write(clean + "] (" + percent + "%)");
        }
        void WriteStatePercent(string title, string msg, long?value, long?max)
        {
            if (!value.HasValue || !max.HasValue)
            {
                _consoleHandler.WriteLine(title + ": " + msg + " ");
                return;
            }

            _consoleHandler.Write(title + ": " + msg + " ");

            using (var pg = _consoleHandler.CreatePercent(max.Value))
            {
                pg.Value = value.Value;
            }
        }
Esempio n. 5
0
        public void DecompileCommand(UInt160 contractHash)
        {
            var script = _scriptTable.GetScript(contractHash.ToArray(), false);

            if (script == null)
            {
                throw new ArgumentNullException("Contract not found");
            }

            foreach (var i in script.DecompileScript())
            {
                _consoleHandler.Write($"{i.Location} ", ConsoleOutputStyle.Information);

                if (i is InstructionWithPayload ip)
                {
                    _consoleHandler.Write($"{i.OpCode} ");
                    _consoleHandler.WriteLine($"{{{ip.Payload.ToHexString(true)}}}", ConsoleOutputStyle.DarkGray);
                }
                else
                {
                    _consoleHandler.WriteLine(i.OpCode.ToString());
                }
            }
        }
        public static string ReadJson(string jsonPrototypeString, IConsoleHandler consoleHandler)
        {
            try
            {
                File.WriteAllText(
                    jsonEditorFilePath,
                    jsonPrototypeString
                    );

                var process = TryStartProcess(jsonEditorFilePath);
                TryWaitForExit(process);
                string res;
                CommonHelpers.TryReadAllText(jsonEditorFilePath, out res, 120);
                return(res);
            }
            catch (Exception ex)
            {
                consoleHandler.WriteLine(
                    $"Was error '{ex.Message}' when try to use json editor. \nBut you can write json string as default.",
                    ConsoleColor.DarkRed
                    );
                consoleHandler.WriteLine("Or you can press enter to throw error upper.", ConsoleColor.DarkRed);
                if (!string.IsNullOrWhiteSpace(jsonPrototypeString))
                {
                    consoleHandler.WriteLine($"Prototype: {jsonPrototypeString}", ConsoleColor.DarkYellow);
                }
                consoleHandler.Write("Input json line: ", null);
                var res = consoleHandler.ReadLine();
                if (string.IsNullOrEmpty(res))
                {
                    throw;
                }
                else
                {
                    return(res);
                }
            }
        }