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
propertyNamestringThe name of the property.
rawTextstringThe token as it appears in the message template.
formatstringThe format applied to the property, if any.
alignmentAlignment?The alignment applied to the property, if any.
destructuringDestructuringThe destructuring strategy applied to the property, if any.
Exceptions
- ArgumentNullException
When
propertyNameisnull- ArgumentNullException
When
rawTextisnull
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
objobjectThe 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
propertiesIReadOnlyDictionary<string, LogEventPropertyValue>Properties that may be represented by the token.
outputTextWriterOutput for the rendered string.
formatProviderIFormatProviderSupplies culture-specific formatting information, or null.
Exceptions
- ArgumentNullException
When
propertiesisnull- ArgumentNullException
When
outputisnull
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
positionintThe integer value, if present.
Returns
- bool
True if the property is positional, otherwise false.