예제 #1
0
파일: Debug.cs 프로젝트: mikem8361/runtime
 /// <summary>Creates an instance of the handler..</summary>
 /// <param name="literalLength">The number of constant characters outside of interpolation expressions in the interpolated string.</param>
 /// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
 /// <param name="condition">The condition Boolean passed to the <see cref="Debug"/> method.</param>
 /// <param name="shouldAppend">A value indicating whether formatting should proceed.</param>
 /// <remarks>This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.</remarks>
 public WriteIfInterpolatedStringHandler(int literalLength, int formattedCount, bool condition, out bool shouldAppend)
 {
     if (condition)
     {
         // Only used in debug, but could be used on non-failure code paths, so use a cached builder.
         _stringBuilderHandler = new StringBuilder.AppendInterpolatedStringHandler(literalLength, formattedCount,
                                                                                   StringBuilderCache.Acquire(DefaultInterpolatedStringHandler.GetDefaultLength(literalLength, formattedCount)));
         shouldAppend = true;
     }
     else
     {
         _stringBuilderHandler = default;
         shouldAppend          = false;
     }
 }
예제 #2
0
 /// <summary>Creates an instance of the handler..</summary>
 /// <param name="literalLength">The number of constant characters outside of interpolation expressions in the interpolated string.</param>
 /// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
 /// <param name="condition">The condition Boolean passed to the <see cref="Debug"/> method.</param>
 /// <param name="shouldAppend">A value indicating whether formatting should proceed.</param>
 /// <remarks>This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.</remarks>
 public WriteIfInterpolatedStringHandler(int literalLength, int formattedCount, bool condition, out bool shouldAppend)
 {
     if (condition)
     {
         _stringBuilderHandler = new StringBuilder.AppendInterpolatedStringHandler(literalLength, formattedCount, new StringBuilder(DefaultInterpolatedStringHandler.GetDefaultLength(literalLength, formattedCount)));
         shouldAppend          = true;
     }
     else
     {
         _stringBuilderHandler = default;
         shouldAppend          = false;
     }
 }