Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Sep 15, 2024
1 parent f261a36 commit 784e6e0
Show file tree
Hide file tree
Showing 7 changed files with 2,254 additions and 281 deletions.
56 changes: 40 additions & 16 deletions NamingFormatter/DIctionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ partial class Named
/// <param name="tw">Format text writer.</param>
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -57,7 +58,8 @@ partial class Named
public static void WriteFormat(
this TextWriter tw,
string format,
Dictionary<string, object?> keyValues)
Dictionary<string, object?> keyValues,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -67,7 +69,8 @@ public static void WriteFormat(
WriteFormat(
tw,
format,
key => keyValues[key]);
key => keyValues[key],
options);
}

/// <summary>
Expand All @@ -77,6 +80,7 @@ public static void WriteFormat(
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="fallback">Fallback delegate.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -101,7 +105,8 @@ public static void WriteFormat(
this TextWriter tw,
string format,
Dictionary<string, object?> keyValues,
Func<string, object?> fallback)
Func<string, object?> fallback,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -117,7 +122,8 @@ public static void WriteFormat(
format,
key => keyValues.TryGetValue(key, out var value) ?
value :
fallback(key));
fallback(key),
options);
}

#if !NET35 && !NET40
Expand All @@ -127,6 +133,7 @@ public static void WriteFormat(
/// <param name="tw">Format text writer.</param>
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -149,7 +156,8 @@ public static void WriteFormat(
public static Task WriteFormatAsync(
this TextWriter tw,
string format,
Dictionary<string, object?> keyValues)
Dictionary<string, object?> keyValues,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -159,7 +167,8 @@ public static Task WriteFormatAsync(
return WriteFormatAsync(
tw,
format,
key => keyValues[key]);
key => keyValues[key],
options);
}

/// <summary>
Expand All @@ -169,6 +178,7 @@ public static Task WriteFormatAsync(
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="fallback">Fallback delegate.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -193,7 +203,8 @@ public static Task WriteFormatAsync(
this TextWriter tw,
string format,
Dictionary<string, object?> keyValues,
Func<string, object?> fallback)
Func<string, object?> fallback,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -209,7 +220,8 @@ public static Task WriteFormatAsync(
format,
key => keyValues.TryGetValue(key, out var value) ?
value :
fallback(key));
fallback(key),
options);
}
#endif

Expand All @@ -219,6 +231,7 @@ public static Task WriteFormatAsync(
/// <param name="formatProvider">The format provider.</param>
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -240,7 +253,8 @@ public static Task WriteFormatAsync(
public static string Format(
IFormatProvider formatProvider,
string format,
Dictionary<string, object?> keyValues)
Dictionary<string, object?> keyValues,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -250,7 +264,8 @@ public static string Format(
return Format(
formatProvider,
format,
key => keyValues[key]);
key => keyValues[key],
options);
}

/// <summary>
Expand All @@ -260,6 +275,7 @@ public static string Format(
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="fallback">Fallback delegate.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -283,7 +299,8 @@ public static string Format(
IFormatProvider formatProvider,
string format,
Dictionary<string, object?> keyValues,
Func<string, object?> fallback)
Func<string, object?> fallback,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -299,14 +316,16 @@ public static string Format(
format,
key => keyValues.TryGetValue(key, out var value) ?
value :
fallback(key));
fallback(key),
options);
}

/// <summary>
/// Format string with named format-key.
/// </summary>
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -327,7 +346,8 @@ public static string Format(
/// </example>
public static string Format(
string format,
Dictionary<string, object?> keyValues)
Dictionary<string, object?> keyValues,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -336,7 +356,8 @@ public static string Format(

return Format(
format,
key => keyValues[key]);
key => keyValues[key],
options);
}

/// <summary>
Expand All @@ -345,6 +366,7 @@ public static string Format(
/// <param name="format">The format string (can include format-key).</param>
/// <param name="keyValues">Key-value dictionary.</param>
/// <param name="fallback">Fallback delegate.</param>
/// <param name="options">Options</param>
/// <returns>Formatted string.</returns>
/// <example>
/// <code>
Expand All @@ -367,7 +389,8 @@ public static string Format(
public static string Format(
string format,
Dictionary<string, object?> keyValues,
Func<string, object?> fallback)
Func<string, object?> fallback,
FormatOptions options = default)
{
if (keyValues == null)
{
Expand All @@ -382,7 +405,8 @@ public static string Format(
format,
key => keyValues.TryGetValue(key, out var value) ?
value :
fallback(key));
fallback(key),
options);
}
}
}
Loading

0 comments on commit 784e6e0

Please sign in to comment.