Class Template<TContext, TTarget, TRenderingContext>
A general ancestor for any template. All templates derive from this class directly or indirectly. A template is a class that gets instantiated at some point to Render() its content into IRenderingTarget instance. Templates are not necessarily text-based, i.e. they can be image-based or based on various kinds of binary files
Implements
Inherited Members
Namespace: NFX.Templatization
Assembly: NFX.dll
Syntax
public abstract class Template<TContext, TTarget, TRenderingContext> : ITemplate where TContext : class where TTarget : class, IRenderingTarget
  Type Parameters
| Name | Description | 
|---|---|
| TContext | |
| TTarget | |
| TRenderingContext | 
Constructors
Template()
Declaration
protected Template()
  Template(TContext)
Declaration
protected Template(TContext context)
  Parameters
| Type | Name | Description | 
|---|---|---|
| TContext | context | 
Properties
CanReuseInstance
Indicates whether an instance of template class may be reused for invocation of Render() more than once (possibly with different rendering target and/or rendering context)
Declaration
public abstract bool CanReuseInstance { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
Context
Custom context for the lifetime of this template
Declaration
public TContext Context { get; }
  Property Value
| Type | Description | 
|---|---|
| TContext | 
RenderingContext
Returns thread-local rendering context which is specific for this call to Render()
Declaration
public TRenderingContext RenderingContext { get; }
  Property Value
| Type | Description | 
|---|---|
| TRenderingContext | 
Target
Returns thread-local target which is specific for this call to Render()
Declaration
public TTarget Target { get; }
  Property Value
| Type | Description | 
|---|---|
| TTarget | 
Methods
BindGlobalContexts(TContext)
Infrastructure. Sets Context property. Normally this method should never be called by developers
Declaration
public void BindGlobalContexts(TContext context)
  Parameters
| Type | Name | Description | 
|---|---|---|
| TContext | context | 
DoContextBinding()
Infrastructure. Override to perform extra steps after Context property gets set. Normally this method should never be called by developers
Declaration
protected virtual void DoContextBinding()
  DoPostRender(Exception)
Performs post-rendering actions. Return true to rethrow error
Declaration
protected virtual bool DoPostRender(Exception error)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Exception | error | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
DoPreRender()
Performs pre-rendering actions
Declaration
protected virtual void DoPreRender()
  DoRender()
Performs actual rendering
Declaration
protected virtual void DoRender()
  Render(TTarget, TRenderingContext)
Renders template by generating content into target
Declaration
public void Render(TTarget target, TRenderingContext renderingContext)
  Parameters
| Type | Name | Description | 
|---|---|---|
| TTarget | target | A target to render output into  | 
      
| TRenderingContext | renderingContext | A context object for this rendering call  | 
      
Explicit Interface Implementations
ITemplate.Context
Declaration
object ITemplate.Context { get; }
  Returns
| Type | Description | 
|---|---|
| System.Object | 
ITemplate.Render(IRenderingTarget, Object)
Declaration
void ITemplate.Render(IRenderingTarget target, object renderingContext)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IRenderingTarget | target | |
| System.Object | renderingContext |