Beispiel #1
0
 /// <summary>
 /// Indents the builder to the current formatting depth.
 /// </summary>
 /// <param name="builder">
 /// The builder.
 /// </param>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="respectWhiteSpace">
 /// A value indicating whether to respect white space.
 /// </param>
 /// <returns>
 /// The original <see cref="StringBuilder"/>.
 /// </returns>
 public static StringBuilder Indent(
     this StringBuilder builder, FormattingContext context, bool respectWhiteSpace = true) =>
 builder.Append(context.GetIndent(respectWhiteSpace));
Beispiel #2
0
        /// <summary>
        /// Gets a blank string that will indent to the current formatting depth.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="respectWhiteSpace">
        /// A value indicating whether to respect white space.
        /// </param>
        /// <returns>
        /// A blank string that will indent to the current formatting depth.
        /// </returns>
        public static string GetIndent(this FormattingContext context, bool respectWhiteSpace = true)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(respectWhiteSpace && context.Element.PreserveSpace ? string.Empty : context.GetIndent(context.Depth));
        }