-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSharpCodeBuilder.AppendFormat.cs
More file actions
48 lines (44 loc) · 2.85 KB
/
CSharpCodeBuilder.AppendFormat.cs
File metadata and controls
48 lines (44 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
namespace NetEvolve.CodeBuilder;
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
public partial class CSharpCodeBuilder
{
/// <summary>
/// Appends a formatted string to the current builder using invariant culture.
/// </summary>
/// <param name="format">A composite format string.</param>
/// <param name="arg0">The object to format.</param>
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="format"/> is <see langword="null"/>.</exception>
/// <exception cref="FormatException">Thrown when <paramref name="format"/> is invalid or the index of a format item is greater than zero.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CSharpCodeBuilder AppendFormat(string format, object? arg0) =>
AppendFormat(CultureInfo.InvariantCulture, format, arg0);
/// <summary>
/// Appends a formatted string to the current builder using invariant culture.
/// </summary>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="format"/> is <see langword="null"/>.</exception>
/// <exception cref="FormatException">Thrown when <paramref name="format"/> is invalid or the index of a format item is greater than the number of elements in <paramref name="args"/> minus 1.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CSharpCodeBuilder AppendFormat(string format, params object?[] args) =>
AppendFormat(CultureInfo.InvariantCulture, format, args);
/// <summary>
/// Appends a formatted string to the current builder using the specified format provider.
/// </summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="format"/> is <see langword="null"/>.</exception>
/// <exception cref="FormatException">Thrown when <paramref name="format"/> is invalid or the index of a format item is greater than the number of elements in <paramref name="args"/> minus 1.</exception>
public CSharpCodeBuilder AppendFormat(IFormatProvider? provider, string format, params object?[] args)
{
EnsureIndented();
_ = _builder.AppendFormat(provider, format, args);
return this;
}
}