Esempio n. 1
0
        public override string ToString()
        {
            var builder = new StringBuilder();

            builder.Append(Argument);
            builder.Length--;

            if (Width > 0)
            {
                builder.Append(',');

                if (LeftAlign)
                {
                    builder.Append('-');
                }

                builder.Append(Width);
            }

            string formatString = FormatString.ToString();

            if (formatString.Length > 0)
            {
                builder.Append(':');
                builder.Append(formatString);
            }

            builder.Append('}');

            return(builder.ToString());
        }
 public SimpleFormat(
     Location location, Expression argument, bool leftAlign, int width, FormatString formatString)
     : base(location, argument)
 {
     LeftAlign = leftAlign;
     Width = width;
     FormatString = Utilities.ThrowIfNull(formatString, "formatString");
 }
Esempio n. 3
0
 public SimpleFormat(
     Location location, Expression argument, bool leftAlign, int width, FormatString formatString)
     : base(location, argument)
 {
     LeftAlign    = leftAlign;
     Width        = width;
     FormatString = Utilities.ThrowIfNull(formatString, "formatString");
 }
Esempio n. 4
0
        protected override object DoVisit(FormatString formatString)
        {
            int originalLength = this.formatted.Length;

            foreach (FormatStringItem item in formatString.Items)
            {
                this.formatted.Append(Visit(item));
            }

            string formattedString = this.formatted.ToString(originalLength, this.formatted.Length - originalLength);

            this.formatted.Length = originalLength;

            return formattedString;
        }