1

Possible Duplicate:
How can I read the properties of a C# class dynamically?

Basically, I would like to be able to write a script file (in C# syntax) but then read this into an application so the application will execute the contents of the file.

I don't want the script file to contain the namespaces etc. but the script file will be straight forward C#. For example a script file might look like:

if (Balance == 0 && Withdrawal > 0)
{
    // Don't allow this to happen
}

Basically, like Business Rules but in a script format.

Any ideas or references that I could look at?

1
  • Check this question for information about C# scripting languages. Commented Aug 11, 2010 at 13:23

1 Answer 1

0

In an application I implemented sucessfully scripting by using the C# compiler and dynamically using the generated code.

You can specify the references to use during compilation and compile one or several files "on-the-fly". You get also the warnings/errors on compilation.

This should be done in a clean fashion with AppDomains but here are a few starters.

A more complex way to use scripting is demonstrated in this "game" where also the security aspects are solved correctly along with the use of AppDomain:

The only aspects I am struggling with are:

  • Debugging of the script
  • If you want to keep it simple, how to find an easy GUI for the script snippets
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.