Class PropertyToken
A message template token representing a log event property.
public sealed class PropertyToken : MessageTemplateToken
- Inheritance
-
PropertyToken
- Inherited Members
Constructors
PropertyToken(string, string, string?, in Alignment?, Destructuring)
Construct a PropertyToken.
public PropertyToken(string propertyName, string rawText, string? format = null, in Alignment? alignment = null, Destructuring destructuring = Destructuring.Default)
Parameters
propertyName
stringThe name of the property.
rawText
stringThe token as it appears in the message template.
format
stringThe format applied to the property, if any.
alignment
Alignment?The alignment applied to the property, if any.
destructuring
DestructuringThe destructuring strategy applied to the property, if any.
Exceptions
- ArgumentNullException
When
propertyName
isnull
- ArgumentNullException
When
rawText
isnull
Properties
Alignment
Alignment applied to the property.
public Alignment? Alignment { get; }
Property Value
Destructuring
Destructuring strategy applied to the property.
public Destructuring Destructuring { get; }
Property Value
Format
Format applied to the property.
public string? Format { get; }
Property Value
IsPositional
public bool IsPositional { get; }
Property Value
Length
The token's length.
public override int Length { get; }
Property Value
PropertyName
The property name.
public string PropertyName { get; }
Property Value
Methods
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GetHashCode()
Serves as a hash function for a particular type.
public override int GetHashCode()
Returns
Render(IReadOnlyDictionary<string, LogEventPropertyValue>, TextWriter, IFormatProvider?)
Render the token to the output.
public override void Render(IReadOnlyDictionary<string, LogEventPropertyValue> properties, TextWriter output, IFormatProvider? formatProvider = null)
Parameters
properties
IReadOnlyDictionary<string, LogEventPropertyValue>Properties that may be represented by the token.
output
TextWriterOutput for the rendered string.
formatProvider
IFormatProviderSupplies culture-specific formatting information, or null.
Exceptions
- ArgumentNullException
When
properties
isnull
- ArgumentNullException
When
output
isnull
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryGetPositionalValue(out int)
Try to get the integer value represented by the property name.
public bool TryGetPositionalValue(out int position)
Parameters
position
intThe integer value, if present.
Returns
- bool
True if the property is positional, otherwise false.