Based Host implementation for hosting the RazorEngine. This base acts as a host wrapper for implementing high level host services around the RazorEngine class.
Provides the ability to run in a separate AppDomain and to cache and store generated assemblies to avoid constant parsing and recompilation.
For example implementations can provide assembly template caching so assemblies don't recompile for each access.
System.MarshalByRefObject
Westwind.RazorHosting.RazorBaseHostContainer<TBaseTemplateType>
public abstract class RazorBaseHostContainer<TBaseTemplateType> : MarshalByRefObject, IDisposable
Class Members
Member | Description | |
---|---|---|
Constructor |
||
Engine |
Cached instance of the Host. Required to keep the reference to the host alive for multiple uses. |
|
AddAssemblyFromType |
Adds an assembly to the referenced assemblies from an existing .NET Type. public void AddAssemblyFromType(Type instance) public void AddAssemblyFromType(object instance) |
|
Dispose |
Automatically stops the host public sealed void Dispose() |
|
InitializeLifetimeService |
Force this host to stay alive indefinitely public virtual object InitializeLifetimeService() |
|
RenderTemplate |
public virtual bool RenderTemplate(TextReader reader, object model, TextWriter writer) |
|
Start |
Call to start the Host running. Follow by a calls to RenderTemplate to render individual templates. Call Stop when done. public virtual bool Start() |
|
Stop |
Stops the Host and releases the host AppDomain and cached assemblies. public bool Stop() |
|
ToString |
public virtual string ToString() |
|
BaseBinaryFolder |
Base folder location where the AppDomain is hosted. By default uses the same folder as the host application. Determines where binary dependencies are found for assembly references. |
|
CodeProvider |
Optionally provide a CSharpCodeProvider code Default uses System.CSharp.CSharpCodeProvider |
|
Configuration |
Engine Configuration |
|
ErrorMessage |
Any error messages |
|
GeneratedNamespace |
Name of the generated namespace for template classes |
|
ReferencedAssemblies |
List of referenced assemblies as string values. Must be in GAC or in the current folder of the host app/ base BinaryFolder |
|
ReferencedNamespaces |
List of additional namespaces to add to all templates. By default: System, System.Text, System.IO, System.Linq |
|
ThrowExceptions |
Determines whether errors throw exceptions or return error status messages. |
|
UseAppDomain |
Determines whether the Container hosts Razor in a separate AppDomain. Seperate AppDomain hosting allows unloading and releasing of resources. |
Requirements
Namespace: Westwind.RazorHostingAssembly: westwind.razorhosting.dll
© West Wind Technologies, 2018 • Updated: 06/07/18
Comment or report problem with topic