Click or drag to resize

IEvaluator Interface

A generic interface of the CS-Script evaluator. It encapsulates the generic functionality of the evaluator regardless of the nature of the underlying compiling services (e.g. Mono, Roslyn, CodeDom).

Namespace:  CSScriptLib
Assembly:  CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
Syntax
C#
public interface IEvaluator

The IEvaluator type exposes the following members.

Properties
  NameDescription
Public propertyDebugBuild
Gets or sets a value indicating whether to compile script with debug symbols.

Note, setting DebugBuild will only affect the current instance of Evaluator. If you want to emit debug symbols for all instances of Evaluator then use EvaluatorConfig.DebugBuild.

Public propertyDisableReferencingFromCode
Gets or sets the flag indicating if the script code should be analyzed and the assemblies that the script depend on (via '//css_...' and 'using ...' directives) should be referenced.
Top
Methods
  NameDescription
Public methodCode exampleCheck
Compiles the specified script text without loading it into the AppDomain or writing to the file system.
Public methodCode exampleClone
Clones the parent IEvaluator.

This method returns a freshly initialized copy of the IEvaluator. The cloning 'depth' can be controlled by the copyRefAssemblies.

This method is a convenient technique when multiple IEvaluator instances are required (e.g. for concurrent script evaluation).

Public methodCode exampleCompileAssemblyFromCode
Compiles C# code (script) into assembly file. The C# code is a typical C# code containing a single or multiple class definition(s).
Public methodCode exampleCompileAssemblyFromFile
Compiles C# file (script) into assembly file. The C# contains typical C# code containing a single or multiple class definition(s).
Public methodCode exampleCompileCode
Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s).
Public methodCode exampleCompileMethod
Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it.

This method is a logical equivalent of CompileCode(String, CompileInfo) but is allows you to define your script class by specifying class method instead of whole class declaration.

Public methodCode exampleCreateDelegate(String)
Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.

Returns non-typed MethodDelegate for class-less style of invoking.

Public methodCode exampleCreateDelegateT(String)
Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.

Returns typed MethodDelegateT for class-less style of invoking.

Public methodGetReferencedAssemblies
Returns set of referenced assemblies.

Notre: the set of assemblies is cleared on Reset.

Public methodGetReferencedAssemblies(String, String)
Analyses the script code and returns set of locations for the assemblies referenced from the code with CS-Script directives (//css_ref).
Public methodCode exampleLoadCode(String, Object)
Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code.
Public methodCode exampleLoadCodeT(String, Object)
Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code.
Public methodCode exampleLoadDelegateT
Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.

Returns instance of T delegate for the first method in the auto-generated class.

Public methodCode exampleLoadFile(String, Object)
Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first class defined in the script file.
Public methodCode exampleLoadFileT(String, Object)
Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first class defined in the script file. After initializing the class instance it is aligned to the interface specified by the parameter T.

Note: the script class does not have to inherit from the T parameter as the proxy type will be generated anyway.

Public methodCode exampleLoadMethod(String)
Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.
Public methodCode exampleLoadMethodT(String)
Wraps C# code fragment into auto-generated class (type name DynamicClass), evaluates it and loads the class to the current AppDomain.

After initializing the class instance it is aligned to the interface specified by the parameter T.

Public methodReferenceAssembliesFromCode
References the assemblies from the script code.

The method analyses and tries to resolve CS-Script directives (e.g. '//css_ref') and 'used' namespaces based on the optional search directories.

Public methodReferenceAssembly(Assembly)
References the given assembly.

It is safe to call this method multiple times for the same assembly. If the assembly already referenced it will not be referenced again.

Public methodReferenceAssembly(String)
References the given assembly by the assembly path.

It is safe to call this method multiple times for the same assembly. If the assembly already referenced it will not be referenced again.

Public methodReferenceAssemblyByName
References the name of the assembly by its partial name.

Note that the referenced assembly will be loaded into the host AppDomain in order to resolve assembly partial name.

It is an equivalent of Evaluator.ReferenceAssembly(Assembly.LoadWithPartialName(assemblyPartialName))

Public methodReferenceAssemblyByNamespace
References the assembly by the given namespace it implements.

Adds assembly reference if the namespace was successfully resolved (found) and, otherwise does nothing

Public methodReferenceAssemblyOf(Object)
References the assembly by the object, which belongs to this assembly.

It is safe to call this method multiple times for the same assembly. If the assembly already referenced it will not be referenced again.

Public methodReferenceAssemblyOfT
References the assembly by the object, which belongs to this assembly.

It is safe to call this method multiple times for the same assembly. If the assembly already referenced it will not be referenced again.

Public methodReferenceDomainAssemblies
References the assemblies the are already loaded into the current AppDomain.
Public methodReset
Resets Evaluator.

Resetting means clearing all referenced assemblies, recreating evaluation infrastructure (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services.

Optionally the default current AppDomain assemblies can be referenced automatically with referenceDomainAssemblies.

Public methodTryReferenceAssemblyByNamespace
References the assembly by the given namespace it implements.
Top
See Also