Conditional string template parser.
Inheritance Hierarchy
NReco.Data StringTemplate
Namespace: NReco.Data
Assembly: NReco.Data (in NReco.Data.dll) Version: 1.0.2
Syntax
The StringTemplate type exposes the following members.
Constructors
Name | Description | |
---|---|---|
StringTemplate(String) | Initializes a new instance of the StringTemplate class | |
StringTemplate(String, Int32) | Initializes a new instance of the StringTemplate class |
Methods
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FormatTemplate(IDictionary String, Object ) |
Replaces the format items in a specified string with the string representations of corresponding objects in a specified dictionary.
| |
FormatTemplate(Func String, StringTemplate TokenResult ) |
Replaces the format items in a specified string with the string representations of corresponding objects returned by value handler.
| |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ReadFormatOptions | ||
ReadName | ||
ReplaceTokens | ||
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Fields
Name | Description | |
---|---|---|
ExtraNameChars | ||
Template |
Properties
Name | Description | |
---|---|---|
RecursionLevel |
Get or set max recursion level of token replacement (for cases when token value contains token definitions).
| |
ReplaceMissedTokens |
Get or set flag that determines replacement behaviour when token is not defined (true by default)
|
Remarks
@@Test
Examples
var strTpl = new StringTemplate("@Name[Hello, {0}; Hi all]!"); Console.Write( strTpl.FormatTemplate( new Dictionary<string,object>() { {"Name", "John"} } ) ); // Hi, John! Console.Write( strTpl.FormatTemplate( new Dictionary<string,object>() ) ); // Hi, all!
See Also