示例#1
0
        public string Format <T0>(T0 arg0)
        {
            var builder = new DefaultInterpolatedStringHandler(2, 1, CultureInfo.InvariantCulture);

            builder.AppendLiteral(_formatSegments[0]);
            FormatArgument(ref builder, arg0, _valueAlignments[0], _valueFormats[0]);
            builder.AppendLiteral(_formatSegments[1]);
            return(builder.ToString());
        }
        public void ToString_DoesntClear()
        {
            DefaultInterpolatedStringHandler handler = new DefaultInterpolatedStringHandler(0, 0);

            handler.AppendLiteral("hi");
            for (int i = 0; i < 3; i++)
            {
                Assert.Equal("hi", handler.ToString());
            }
            Assert.Equal("hi", handler.ToStringAndClear());
        }
示例#3
0
        public string Format <T0, T1, T2, T3, T4, T5>(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
        {
            var builder = new DefaultInterpolatedStringHandler(7, 6, CultureInfo.InvariantCulture);

            builder.AppendLiteral(_formatSegments[0]);
            FormatArgument(ref builder, arg0, _valueAlignments[0], _valueFormats[0]);
            builder.AppendLiteral(_formatSegments[1]);
            FormatArgument(ref builder, arg1, _valueAlignments[1], _valueFormats[1]);
            builder.AppendLiteral(_formatSegments[2]);
            FormatArgument(ref builder, arg2, _valueAlignments[2], _valueFormats[2]);
            builder.AppendLiteral(_formatSegments[3]);
            FormatArgument(ref builder, arg3, _valueAlignments[3], _valueFormats[3]);
            builder.AppendLiteral(_formatSegments[4]);
            FormatArgument(ref builder, arg4, _valueAlignments[4], _valueFormats[4]);
            builder.AppendLiteral(_formatSegments[5]);
            FormatArgument(ref builder, arg5, _valueAlignments[5], _valueFormats[5]);
            builder.AppendLiteral(_formatSegments[6]);
            return(builder.ToString());
        }
 public readonly override string ToString() => _innerHandler.ToString();