Table of Contents

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 string

Start delimiter.

See Also

TokenFunction(string, string)

Initializes an instance of a TokenFunction with a start and end delimiter.

protected TokenFunction(string tokenStartDelimiter, string tokenEndDelimiter)

Parameters

tokenStartDelimiter string

Start delimiter.

tokenEndDelimiter string

End delimiter.

See Also

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 StringBuilder

Message template containing tokens.

log LogEntry

Log entry containing properties to format.

See Also

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 string

Token value between the start and end delimiters.

log LogEntry

Log entry to process.

Returns

string

Formatted value to replace the token.

See Also

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 int

Start index to search for the next token function.

message string

Message template containing tokens.

Returns

string

Inner template of the function.

See Also

See Also