Class TemplateCompiler
Represents abstraction of template compilers. This class is not thread-safe
Inheritance
System.Object
TemplateCompiler
Implements
System.IDisposable
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Azos.dll
Syntax
public abstract class TemplateCompiler : DisposableObject, IDisposable, IConfigurable, IEnumerable<CompileUnit>, IEnumerable
Constructors
TemplateCompiler()
Declaration
protected TemplateCompiler()
TemplateCompiler(ITemplateSource[])
Declaration
protected TemplateCompiler(params ITemplateSource[] sources)
Parameters
TemplateCompiler(IEnumerable<ITemplateSource>)
Declaration
protected TemplateCompiler(IEnumerable<ITemplateSource> sources)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<ITemplateSource> |
sources |
|
Fields
m_Assembly
Declaration
protected Assembly m_Assembly
Field Value
Type |
Description |
System.Reflection.Assembly |
|
m_AssemblyFileName
Declaration
protected string m_AssemblyFileName
Field Value
Type |
Description |
System.String |
|
m_CodeCompilerErrors
Declaration
protected List<Exception> m_CodeCompilerErrors
Field Value
Type |
Description |
System.Collections.Generic.List<System.Exception> |
|
m_Options
Declaration
protected IConfigSectionNode m_Options
Field Value
m_ReferencedAssemblies
Declaration
protected List<string> m_ReferencedAssemblies
Field Value
Type |
Description |
System.Collections.Generic.List<System.String> |
|
m_ReferencedAssembliesSearchPath
Declaration
protected string m_ReferencedAssembliesSearchPath
Field Value
Type |
Description |
System.String |
|
m_Units
Declaration
protected CompileUnits m_Units
Field Value
Properties
Assembly
Returns compiled assembly or null if only source have been compiled when CompileCode=false;
Declaration
public Assembly Assembly { get; }
Property Value
Type |
Description |
System.Reflection.Assembly |
|
AssemblyFileName
Gets/sets filename for assembly, if null then assembly is created in-memory only
Declaration
[Config("$asm-file")]
public string AssemblyFileName { get; set; }
Property Value
Type |
Description |
System.String |
|
BaseTypeName
Sets the name of base type that templates inherit from.
This type must directly or indirectly inherit from Template
Declaration
[Config("$base-type")]
public string BaseTypeName { get; set; }
Property Value
Type |
Description |
System.String |
|
CodeCompilerErrors
Returns code compilation errors
Declaration
public IEnumerable<Exception> CodeCompilerErrors { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<System.Exception> |
|
CompileCode
Indicates whether language compilation should be performed and Assembly be built
Declaration
[Config("$compile-code")]
public bool CompileCode { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Compiled
Indicates whether this instance was compiled
Declaration
public bool Compiled { get; }
Property Value
Type |
Description |
System.Boolean |
|
CompileUnitsWithErrors
Returns compile units that have errors
Declaration
public IEnumerable<CompileUnit> CompileUnitsWithErrors { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<CompileUnit> |
|
HasErrors
Indicates whether some units have template compilation errors or code compiler errors exist
Declaration
public bool HasErrors { get; }
Property Value
Type |
Description |
System.Boolean |
|
Item[ITemplateSource]
Returns a compile unit by template source or throws if it does not exist
Declaration
public CompileUnit this[ITemplateSource templateSource] { get; }
Parameters
Property Value
LanguageName
Gets the name of the language that this compiler supports, i.e. "C#"
Declaration
public abstract string LanguageName { get; }
Property Value
Type |
Description |
System.String |
|
LanguageSourceFileExtension
Gets the name of the language source code file extension that this compiler supports, i.e. ".cs"
Declaration
public abstract string LanguageSourceFileExtension { get; }
Property Value
Type |
Description |
System.String |
|
Namespace
Sets the name of namespace that classes compiled into
Declaration
[Config("$namespace")]
public string Namespace { get; set; }
Property Value
Type |
Description |
System.String |
|
Options
Config options section used for compilation
Declaration
[Config("options")]
public IConfigSectionNode Options { get; set; }
Property Value
ReferencedAssemblies
Returns referenced assemblies
Declaration
public IEnumerable<string> ReferencedAssemblies { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
ReferencedAssembliesSearchPath
Gets/sets path for referenced assemblies that do not have a path in their names
Declaration
[Config("$ref-path")]
public string ReferencedAssembliesSearchPath { get; set; }
Property Value
Type |
Description |
System.String |
|
Methods
Compile()
Performs compilation if it has not already been performed
Declaration
Declaration
public void Configure(IConfigSectionNode node)
Parameters
Destructor()
Declaration
protected override void Destructor()
Overrides
DoBeforeCompileTemplateSources()
Override to transform compile units before compilation starts
Declaration
protected virtual void DoBeforeCompileTemplateSources()
DoCompileCode()
Override to perform compilation of code into assembly
Declaration
protected abstract void DoCompileCode()
DoCompileTemplateSource(CompileUnit)
Override to perform code generation from template source into code
Declaration
protected abstract void DoCompileTemplateSource(CompileUnit unit)
Parameters
Override to perform custom configuration
Declaration
protected virtual void DoConfigure(IConfigSectionNode node)
Parameters
EnsureNotCompiled()
Throws an exception if this instance has already been compiled
Declaration
public void EnsureNotCompiled()
ExcludeTemplateSource(ITemplateSource)
Exclude template source from compilation
Declaration
public bool ExcludeTemplateSource(ITemplateSource source)
Parameters
Returns
Type |
Description |
System.Boolean |
|
GenerateUniqueName()
Generates unique identifier suitable for use in code per compiler instance
Declaration
public string GenerateUniqueName()
Returns
Type |
Description |
System.String |
|
GetEnumerator()
Declaration
public IEnumerator<CompileUnit> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<CompileUnit> |
|
IncludeTemplateSource(ITemplateSource)
Includes template source into compilation
Declaration
public void IncludeTemplateSource(ITemplateSource source)
Parameters
ReferenceAssembly(String)
References assembly by its name if it is already not referenced
Declaration
public void ReferenceAssembly(string aname)
Parameters
Type |
Name |
Description |
System.String |
aname |
|
RegisterDefaultUsings(HashSet<String>)
Override to provide default using clauses
Declaration
protected virtual void RegisterDefaultUsings(HashSet<string> usings)
Parameters
Type |
Name |
Description |
System.Collections.Generic.HashSet<System.String> |
usings |
|
UnReferenceAssembly(String)
Removes assembly reference by its name if it was already referenced
Declaration
public bool UnReferenceAssembly(string aname)
Parameters
Type |
Name |
Description |
System.String |
aname |
|
Returns
Type |
Description |
System.Boolean |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods