Mono.CSharp 2.1.0.0 System.Object Evaluator: provides an API to evaluate C# statements and expressions dynamically.

This class exposes static methods to execute C# statements and evaluate C# expressions in the current program. Expressions and statements should be fully formed, so they need to end with a semicolon as they would in a regular C# file.

To initialize the evaluator with a number of compiler options call the Init(string[]args) method with a set of command line options that the compiler recognizes.

To interrupt execution of a statement, you can invoke the Evaluator.Interrupt method. This comes in handy if you want to implement a handler for Control-C for example.

- Method
  2.1.0.0
  Mono.CSharp.CompiledMethod `` The expression or statement to compile. Compiles the input string and returns a delegate that represents the compiled code.

  Compiles the input string as a C# expression or statement.

  Unlike the Evaluate method, the resulting delegate can be invoked multiple times without incurring in the compilation overhead.

  This method can only deal with fully formed input strings and does not provide a completion mechanism. If you must deal with partial input (for example for interactive use) use the other overload.

  On success, a delegate is returned that can be used to invoke the method.

- Method
  2.1.0.0
  System.String `` `` The expression or statement to compile. The compiled code will be returned in this delegate. Compiles the input string and returns a delegate that represents the compiled code. On success, a delegate that can be used to invoke the compiled code repeatedly.

  Compiles the input string as a C# expression or statement, unlike the Evaluate method, the resulting delegate can be invoked multiple times without incurring in the compilation overhead.

  If the return value of this function is null, this indicates that the parsing was complete.

  If the return value is a string it indicates that the input string was partial and that the invoking code should provide more code before the code can be successfully compiled.

  If you know that you will always get full expressions or statements and do not care about partial input, you can use the other Compile overload.

  On success, in addition to returning null, the compiled parameter will be set to the delegate that can be invoked to execute the code.

- Method
  2.1.0.0
  System.Object `` The expression to evaluate. Evaluates and expression or statement and returns the result. The result of computing the expression.

  Evaluates the input string as a C# expression or statement and returns the value.

  This method will throw an exception if there is a syntax error, of if the provided input is not an expression but a statement.

  `// First setup the active using statements: Evaluator.Run ("using System;"); int sum = (int) Evaluator.Evaluate ("1+2"); // A more interesting sample Evaluator.Run ("using System.Linq"); Evaluator.Run ("var numbers = new int [] {1,2,3,4,5};"); // We know the result is an IEnumerator, cast it. IEnumerator even = (IEnumerator) Evaluator.Evaluate ("from x in numbers where (x % 2) == 0 select x");`

- Method
  2.1.0.0
  System.String `` `` `` The expression to evaluate. The result will be stored here. If this value is true, the result was set and can be used, otherwise it was not set. Evaluates and expression or statement and returns any result values. If null, the parsing was successful, if not, it means that the input is partial.

  Evaluates the input string as a C# expression or statement. If the input string is an expression the result will be stored in the result variable and the result_set variable will be set to true.

  It is necessary to use the result/result_set pair to identify when a result was set (for example, execution of user-provided input can be an expression, a statement or others, and result_set would only be set if the input was an expression.

  If the return value of this function is null, this indicates that the parsing was complete.

  If the return value is a string, it indicates that the input is partial and that the user should provide an updated string.

- Method
  2.1.0.0
  System.String Returns a list of the active using statements. A list of active using statements. This result can be shown to the user.
- Method
  2.1.0.0
  System.String Returns a list of all local variables. A user-visible list of all local variables defined when invoking the evaluator.
- Method
  2.1.0.0
  System.Void `` Compiler options. Optional initialization for the Evaluator.

  Initializes the Evaluator with the command line options that would be processed by the command line compiler. Only the first call to Init will work, any future invocations are ignored.

  You can safely avoid calling this method if your application does not need any of the features exposed by the command line interface.

- Property
  2.1.0.0
  System.Type The base class for the classes that host the user generated code

  This is the base class that will host the code executed by the Evaluator. By default this is the Mono.CSharp.InteractiveBase class which is useful for interactive use.

  By changing this property you can control the base class and the static members that are available to your evaluated code.

- Method
  2.1.0.0
  System.Void Interrupts the evaluation of an expression executing in Evaluate. Use this method to interrupt long-running invocations.
- Method
  2.1.0.0
  System.Void `` The filename that holds the assembly. Loads the given assembly and exposes the API to the user.
- Method
  2.1.0.0
  System.Void `` The assembly to expose to the evaluated expressions. Exposes the API of the given assembly to the Evaluator After this invocation, the types from the referenced assembly will be accessible to code executed by the evaluator.
- Method
  2.1.0.0
  System.Boolean `` A statement to execute. Executes the given expression or statement. True if the code was succesfully parsed.

  Executes the provided statement, returns true on success, false on parsing errors. Exceptions might be thrown by the called code.

  `// First setup the active using statements: Evaluator.Run ("using System;"); Evaluator.Run ("Console.WriteLine (\"Hello, World\");`