Exemplo n.º 1
0
        private static bool QuoteValueCore(string str, StringBuilder sb, bool force)
        {
            if (string.IsNullOrEmpty(str))
            {
                sb.Append("{}");
                return(true);
            }

            int ich = sb.Length;

            if (!force && TryNoQuoting(str, sb))
            {
                return(false);
            }
            Contracts.Assert(ich == sb.Length);

            // We need to quote. See if we can just slap curlies around it.
            if (TryNaiveQuoting(str, sb))
            {
                return(true);
            }
            Contracts.Assert(ich == sb.Length);

            var quoter = new CmdQuoter(str, sb);

            quoter.QuoteValueCore();
            return(true);
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            if (IsEmpty)
            {
                return("{}");
            }

            if (_settings.Length == 0)
            {
                return(_kind);
            }

            string        str = CmdParser.CombineSettings(_settings);
            StringBuilder sb  = new StringBuilder();

            CmdQuoter.QuoteValue(str, sb, true);
            return(_kind + sb.ToString());
        }