Open sandboxFocus

Constructor TemplateInvocation

TemplateInvocation(string, TemplateProvider, object?)

Represents a delegate-like encapsulation of a template method invocation. This enables passing template calls as parameters to other templates, supporting advanced patterns like decorator composition.

Declaration
public TemplateInvocation(string TemplateName, TemplateProvider TemplateProvider, object? Arguments = null)
Parameters
Type Name Description
string TemplateName

The name of the called template method. This method must be annotated with TemplateAttribute.

TemplateProvider TemplateProvider

An optional TemplateProvider specifying where to find the template, or default if the current template provider (usually the current aspect) should be used.

object Arguments

Compile-time template arguments that will be passed to the template. These are typically anonymous objects whose properties map to template parameters (e.g., new { paramName = value }).

Remarks

TemplateInvocation is similar to a delegate in that it captures everything needed to invoke a template: the template name, the template provider, and any compile-time arguments. Unlike a delegate, it is a compile-time construct that generates code when invoked via InvokeTemplate(TemplateInvocation, object?).

This is useful when an aspect allows customizations that must call back to the aspect's logic. For example, a caching aspect could allow derived classes to wrap the caching logic in a try/catch by accepting a TemplateInvocation that the customization template must invoke.

See Also

TemplateInvocation(string, object?)

Declaration
public TemplateInvocation(string templateName, object? arguments = null)
Parameters
Type Name Description
string templateName
object arguments

TemplateInvocation(string, ITemplateProvider, object?)

Declaration
public TemplateInvocation(string templateName, ITemplateProvider templateProvider, object? arguments = null)
Parameters
Type Name Description
string templateName
ITemplateProvider templateProvider
object arguments