Joutsen v0.5.0+12-g5dd5f7e
Public Member Functions | List of all members
Joutsen.StringFormatter Class Reference

A class that can format Strings with nummeric or named placeholders/identifiers. More...

Public Member Functions

 StringFormatter (IFormatProvider formatProvider=null)
 Creates a new instance with a format provider. More...
 
string Format (string format, params object[] values)
 Formats a String with numeric placeholders. More...
 
string Format (string format, Map< String, Object > values)
 Formats a String with named placeholders. More...
 
string Format (string format, object values)
 Formats a String with named placeholders. More...
 

Detailed Description

A class that can format Strings with nummeric or named placeholders/identifiers.

Version
0.0.1

Constructor & Destructor Documentation

◆ StringFormatter()

Joutsen.StringFormatter.StringFormatter ( IFormatProvider  formatProvider = null)

Creates a new instance with a format provider.

Parameters
formatProviderthe format provider to use to format values into strings. Uses the InvariantCulture if null.
Since
Unreleased

Member Function Documentation

◆ Format() [1/3]

string Joutsen.StringFormatter.Format ( string  format,
Map< String, Object >  values 
)

Formats a String with named placeholders.

Parameters
formatThe format String containing named placeholders
valuesPairs of name and value where each name is a placeholder that will be replaced with the corresponding value returns The formatted String
Remarks
The format String can contain placeholders in the form of "{&lt;name&gt;}" which will be replaced by the value in the @paramref{values} dictionary that is associated with the key <name>. All additional formats that are supported by System.String.Format are supported.

◆ Format() [2/3]

string Joutsen.StringFormatter.Format ( string  format,
object  values 
)

Formats a String with named placeholders.

Parameters
formatThe format String containing named placeholders
valuesAn System.Object where each property name used as a placeholder in the format String will be replaced with the properties value
Returns
The formatted String
Remarks
The format String can contain placeholders in the form of "{&lt;name&gt;}" which will be replaced by the value of the values object's property <name>. All additional formats that are supported by @seefw{System.String.Format are supported.

◆ Format() [3/3]

string Joutsen.StringFormatter.Format ( string  format,
params object[]  values 
)

Formats a String with numeric placeholders.

Parameters
formatThe format String
valuesThe objects that are filled into the format string according to their index in the array
Returns
The formatted String
Remarks
This is a shorthand extension method for System.String.Format.