Show / Hide Table of Contents

Class ScriptBodyFactory

Implementation of IGetsScriptBody which returns a string suitable for compilation (by the Roslyn scripting API) to a C# script.

Inheritance
System.Object
ScriptBodyFactory
Implements
IGetsScriptBody
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: ZptSharp.Expressions.CSharpExpressions
Assembly: ZptSharp.CSharpExpressions.dll
Syntax
public class ScriptBodyFactory : IGetsScriptBody

Methods

| Improve this Doc View Source

GetScriptBody(ExpressionDescription)

Creates a string which corresponds to a statement lambda that matches the delegate CSharpExpression.

Declaration
public string GetScriptBody(ExpressionDescription description)
Parameters
Type Name Description
ExpressionDescription description

The expression description.

Returns
Type Description
System.String

The script body.

Remarks

The full returned lambda string would look something like this when returned:

__zptCSharpScriptParameters__ => {
    dynamic variable1 = __zptCSharpScriptParameters__["variable1"];
    dynamic variable2 = __zptCSharpScriptParameters__["variable2"];
return variable1 + variable2;

}

In that sample, the references variable1 & variable2 are two sample variables which are 'in scope' for the expression. These lines would be replaced by however many lines of code are required to describe all of the variables which are defined at the point where the expression is being evaluated.

Additionally, the variable1 + variable2 part of the lambda is a stand-in for the actual expression body which is being evaluated. Note that the final semicolon is not a part of the expression, nor is it expected to be included by the expression.

Finally, if TALES 'type' expressions have been used to create explicit type designations for variables, then those variables won't be treated as dynamic objects. Instead they will be strongly-typed and there will be a cast operator used in their assignment from the dicionary of input parameters.

Implements

IGetsScriptBody
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX