ImportJson() public method

public ImportJson ( Jayrock.Json.JsonReader reader ) : void
reader Jayrock.Json.JsonReader
return void
示例#1
0
        public static JsonPalette Auto(ConsoleBrush defaultBrush)
        {
            string setting;

            try
            {
                setting = Settings.Default[defaultBrush.Background + "Palette"];
            }
            catch (KeyNotFoundException)
            {
                setting = null;
            }

            if (string.IsNullOrEmpty(setting))
            {
                setting      = Settings.BlackPalette;
                defaultBrush = new ConsoleBrush(ConsoleColor.White, ConsoleColor.Black);
            }

            var palette = new JsonPalette(defaultBrush);

            palette.ImportJson(setting);

            return(palette);
        }
示例#2
0
        public static JsonPalette Auto(ConsoleBrush defaultBrush)
        {
            string setting;

            try
            {
                setting = (string) Settings.Default[defaultBrush.Background + "Palette"];
            }
            catch (SettingsPropertyNotFoundException)
            {
                setting = null;
            }

            if (string.IsNullOrEmpty(setting))
            {
                setting = Settings.Default.BlackPalette;
                defaultBrush = new ConsoleBrush(ConsoleColor.White, ConsoleColor.Black);
            }

            var palette = new JsonPalette(defaultBrush);
            palette.ImportJson(setting);

            return palette;
        }
示例#3
0
        public string[] Parse(string[] args)
        {
            Debug.Assert(args != null);

            var inputs    = new Queue <string>(args);
            var anonymous = new Queue <string>(args.Length);

            char?altNamedToken = null;

            if (Path.DirectorySeparatorChar != '/')
            {
                altNamedToken = '/';
            }

            while (inputs.Count > 0)
            {
                var arg = DequeueSafely(inputs);

                if (arg.Length > 1 && (arg[0] == '-' || (altNamedToken.HasValue && arg[0] == altNamedToken.Value)))
                {
                    var parts = arg.Split(new[] { '=', ':' }, 2);
                    var name  = parts[0].TrimStart(arg[0]);

                    if (name.Length == 0)
                    {
                        break;
                    }

                    var value = parts.Length > 1 ? parts[1] : string.Empty;

                    switch (name)
                    {
                    case "p":
                    case "palette":
                    {
                        if (value.Length == 0)
                        {
                            continue;
                        }

                        if (value[0] != '{')
                        {
                            value = "{" + value + "}";
                        }

                        Palette.ImportJson(value);
                        break;
                    }

                    case "m":
                    case "mono":
                    {
                        if (Convert.ToBoolean(Mask.EmptyString(value, Boolean.TrueString)))
                        {
                            Palette = new JsonPalette(ConsoleBrush.Current);
                        }
                        break;
                    }

                    case "?":
                    case "help":
                    {
                        if (Help != null)
                        {
                            Help(this, EventArgs.Empty);
                        }
                        break;
                    }

                    default:
                    {
                        throw new ApplicationException(string.Format("Unknown option '{0}'.", arg));
                    }
                    }
                }
                else
                {
                    anonymous.Enqueue(arg);
                }
            }

            args = anonymous.ToArray();
            return(args);
        }