Show / Hide Table of Contents

Class CompilingExpressionEvaluator<TContext, TResult, TArg>

Implements an evaluator that compiles all expressions represented by instances of this class in a certain scope into dynamic assemblies. Every unique scope name creates a separate assembly. The compilation of scope is triggered either by a call to Compile() or first attempt to call Evaluate() on any instance within a scope. Once a scope has been compiled, no further allocations in this scoped are allowed, this is because CLR does not allow to unload assemblies dynamically. Within an expression context is passed as "ctx" and argument as "arg". This class is thread-safe.

Inheritance
System.Object
CompilingExpressionEvaluator<TContext, TResult, TArg>
MessageFilterExpression
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()
Namespace: NFX.Parsing
Assembly: NFX.dll
Syntax
public class CompilingExpressionEvaluator<TContext, TResult, TArg>
Type Parameters
Name Description
TContext
TResult
TArg

Constructors

CompilingExpressionEvaluator(String, String, IEnumerable<String>, IEnumerable<String>)

Allocates a new expression. This call fails if the scope was already compiled

Declaration
public CompilingExpressionEvaluator(string scope, string expression, IEnumerable<string> referencedAssemblies = null, IEnumerable<string> usings = null)
Parameters
Type Name Description
System.String scope

A valid identifier for namespace sub-path like "mycode.test" no leading or trailing "."

System.String expression

A C# expression to compile

System.Collections.Generic.IEnumerable<System.String> referencedAssemblies

An enumerable of assemblies that compiler should reference while building scope assembly i.e. "MyCompany.dll"

System.Collections.Generic.IEnumerable<System.String> usings

Extra usings i.e. "System.IO", "MyCode.Routines" etc.

Properties

Expression

Returns an original expression as string that is to be evaluated

Declaration
public string Expression { get; }
Property Value
Type Description
System.String

Scope

Returns a scope (similar to compilation unit / assembly) that this expression is in

Declaration
public string Scope { get; }
Property Value
Type Description
System.String

Methods

Compile()

Forces the entire scope compilation now, so no delay is incurred on first call to Evaluate().

Declaration
public void Compile()

Evaluate(TContext, TArg)

Evaluates expression using supplied arg in a context. Context is passed as "ctx" and argument as "arg".

Declaration
public TResult Evaluate(TContext context, TArg arg)
Parameters
Type Name Description
TContext context
TArg arg
Returns
Type Description
TResult

IsScopeAlreadyCompiled(String)

Indicates whether this scope has already been compiled and no more epressions can be allocated in it

Declaration
public static bool IsScopeAlreadyCompiled(string scope)
Parameters
Type Name Description
System.String scope
Returns
Type Description
System.Boolean

Extension Methods

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)
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