Show / Hide Table of Contents

Class TemplateCompiler

Represents abstraction of template compilers. This class is not thread-safe

Inheritance
System.Object
DisposableObject
TemplateCompiler
TextCSTemplateCompiler
TextJSTemplateCompiler
Implements
System.IDisposable
IConfigurable
System.Collections.Generic.IEnumerable<CompileUnit>
System.Collections.IEnumerable
Inherited Members
DisposableObject.DisposeAndNull<T>(T)
DisposableObject.DisposeStarted
DisposableObject.Disposed
DisposableObject.EnsureObjectNotDisposed()
DisposableObject.Dispose()
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()
Namespace: NFX.Templatization
Assembly: NFX.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
Type Name Description
ITemplateSource[] sources

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
Type Description
IConfigSectionNode

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
Type Description
CompileUnits

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
Type Name Description
ITemplateSource templateSource
Property Value
Type Description
CompileUnit

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
Type Description
IConfigSectionNode

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
public void Compile()

Configure(IConfigSectionNode)

Declaration
public void Configure(IConfigSectionNode node)
Parameters
Type Name Description
IConfigSectionNode node

Destructor()

Declaration
protected override void Destructor()
Overrides
DisposableObject.Destructor()

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
Type Name Description
CompileUnit unit

DoConfigure(IConfigSectionNode)

Override to perform custom configuration

Declaration
protected virtual void DoConfigure(IConfigSectionNode node)
Parameters
Type Name Description
IConfigSectionNode node

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
Type Name Description
ITemplateSource source
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
Type Name Description
ITemplateSource source

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
IConfigurable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T>)
CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T, Int32>)
CollectionUtils.SkipLast<T>(IEnumerable<T>)
CollectionUtils.SkipLast<T>(IEnumerable<T>, Int32)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstOrAnyOrDefault<TResult>(IEnumerable<TResult>, Func<TResult, Boolean>)
CollectionUtils.Distinct<TResult, TKey>(IEnumerable<TResult>, Func<TResult, TKey>)
MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
LookAheadExtensions.AsLookAheadEnumerable<T>(IEnumerable<T>)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX