Open sandboxFocus

Method VisitProperties

VisitProperties<TState>(ILoggingPropertyVisitor<TState>, ref TState, in LoggingPropertyVisitorOptions)

Invokes the Visit<TValue>(string, TValue, in LoggingPropertyOptions, ref TState) method of an interface implementation for each property on the current context, and, optionally, for inherited properties in ancestor contexts.

Declaration
public void VisitProperties<TState>(ILoggingPropertyVisitor<TState> visitor, ref TState state, in LoggingPropertyVisitorOptions options = default)
Parameters
Type Name Description
ILoggingPropertyVisitor<TState> visitor

The visitor implementation.

TState state

The opaque state passed through to the visitor.

LoggingPropertyVisitorOptions options

Visitor options.

Type Parameters
Name Description
TState

The type of the opaque state passed through to the visitor.

VisitProperties(Action<string, object>, bool)

Invokes a delegate each property on the current context, and, optionally, for inherited properties in ancestor contexts. This offers a simple way to visit properties, but it has a performance overhead compared to VisitProperties<TState>(ILoggingPropertyVisitor<TState>, ref TState, in LoggingPropertyVisitorOptions) because it is weakly typed and cause the allocation of a closure class to build the action. It also does not expose the LoggingPropertyOptions.

Declaration
public void VisitProperties(Action<string, object> action, bool includeAncestors = true)
Parameters
Type Name Description
Action<string, object> action

The delegate to call for each property. The first value is the property name, the second its value.

bool includeAncestors

Whether inherited properties of ancestor contexts should be visited too.