Class TokenFunction
- Namespace
- Microsoft.Practices.EnterpriseLibrary.Logging.Formatters
- Assembly
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
Abstract base for all TokenFunction-derived classes. Provides default algorithm for formatting a token.
[Obsolete("Use the TokenHandler delegate instead.")]
public abstract class TokenFunction
- Inheritance
-
TokenFunction
- Inherited Members
Remarks
Extending this class is not the recommended approach for handling tokens.
Constructors
TokenFunction(string)
Initializes an instance of a TokenFunction with a start delimiter and the default end delimiter.
protected TokenFunction(string tokenStartDelimiter)
Parameters
tokenStartDelimiter
stringStart delimiter.
- See Also
-
TokenHandler<T>Formatter<T>
TokenFunction(string, string)
Initializes an instance of a TokenFunction with a start and end delimiter.
protected TokenFunction(string tokenStartDelimiter, string tokenEndDelimiter)
Parameters
- See Also
-
TokenHandler<T>Formatter<T>
Methods
Format(StringBuilder, LogEntry)
Searches for token functions in the message and replace all with formatted values.
public virtual void Format(StringBuilder messageBuilder, LogEntry log)
Parameters
messageBuilder
StringBuilderMessage template containing tokens.
log
LogEntryLog entry containing properties to format.
- See Also
-
TokenHandler<T>Formatter<T>
FormatToken(string, LogEntry)
Abstract method to process the token value between the start and end delimiter.
public abstract string FormatToken(string tokenTemplate, LogEntry log)
Parameters
tokenTemplate
stringToken value between the start and end delimiters.
log
LogEntryLog entry to process.
Returns
- string
Formatted value to replace the token.
- See Also
-
TokenHandler<T>Formatter<T>
GetInnerTemplate(int, string)
Returns the template in between the paratheses for a token function. Expecting tokens in this format: {keyvalue(myKey1)}.
protected virtual string GetInnerTemplate(int startPos, string message)
Parameters
startPos
intStart index to search for the next token function.
message
stringMessage template containing tokens.
Returns
- string
Inner template of the function.
- See Also
-
TokenHandler<T>Formatter<T>