Open sandboxFocus

Class TemplateInvocation

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.

Inheritance
TemplateInvocation
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public sealed record TemplateInvocation : IEquatable<TemplateInvocation>
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.

Constructors

Name Description
TemplateInvocation(string, ITemplateProvider, object?)
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.

TemplateInvocation(string, object?)

Properties

Name Description
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 }).

TemplateName

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

TemplateProvider

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

Methods

Name Description
Deconstruct(out string, out TemplateProvider, out object?)
Equals(TemplateInvocation?)
Equals(object?)
GetHashCode()
ToString()

Operators

Name Description
operator ==(TemplateInvocation?, TemplateInvocation?)
operator !=(TemplateInvocation?, TemplateInvocation?)

Extension Methods

See Also