Esempio n. 1
0
            public bool TryUnparse(StringBuilder sb)
            {
                Contracts.AssertValue(sb);
                if (ResultType == null && KeyCount == null)
                {
                    return(TryUnparseCore(sb));
                }

                if (!TrySanitize())
                {
                    return(false);
                }
                if (CmdQuoter.NeedsQuoting(Name) || CmdQuoter.NeedsQuoting(Source))
                {
                    return(false);
                }

                int ich = sb.Length;

                sb.Append(Name);
                sb.Append(':');
                if (ResultType != null)
                {
                    sb.Append(ResultType.Value.GetString());
                }
                if (KeyCount != null)
                {
                    sb.Append('[');
                    if (!KeyCount.TryUnparse(sb))
                    {
                        sb.Length = ich;
                        return(false);
                    }
                    sb.Append(']');
                }
                else if (!string.IsNullOrEmpty(Range))
                {
                    sb.Append(Range);
                }
                sb.Append(':');
                sb.Append(Source);
                return(true);
            }
Esempio n. 2
0
        private protected virtual bool TryUnparseCore(StringBuilder sb)
        {
            Contracts.AssertValue(sb);

            if (!TrySanitize())
            {
                return(false);
            }
            if (CmdQuoter.NeedsQuoting(Name) || CmdQuoter.NeedsQuoting(Source))
            {
                return(false);
            }

            sb.Append(Name);
            if (Source != Name)
            {
                sb.Append(':').Append(Source);
            }
            return(true);
        }