Overview
An open source, .NET Standard 1.3 library with helpful extensions for primitive types - such as formatting strings with named placeholders.
Below are the main features of the library. See the linked code for details.
Please contact me if you have any questions.
Getting Started
NuGet Package Installation
To install the ChannelAdam.PrimitiveExtensions NuGet package
run the following command in the Package Manager Console:
1PM> Install-Package ChannelAdam.PrimitiveExtensions
Usage
1const string format = "Hello {Name} has a {@Cat}";
2format.FormatNamedPlaceholdersWith("Adam", "burmese");
3// "Hello Adam has a burmese";
4
5// How are nested curly brackets handled?
6// Curly brackets must be escaped by doubling each curly bracket - otherwise there is a FormatException.
7// Everything within the curly bracket, to the left of the innermost curly bracket pair, is removed.
8// Everything to the right of the innermost curly bracket pair is kept.
9const string format = "Hello {Name}, a {@Cat} ate my {{{{{ {this {is { removed {__{Homework}__}} fff }} ddd}} a}} }}}}";
10format.FormatNamedPlaceholdersWith("Adam", "burmese", "essay");
11// "Hello Adam, a burmese ate my essay__} fff } ddd} a} }}";
Reference
StringExtensions.cs
public static string FormatNamedPlaceholdersWith(this string format, params object[] args)
public static string FormatWith(this string format, params object[] args)