Pregunta

I need to learn a certain programming subject and I don't know where to start, would like your help.

This is what I need do do, I have a user form (UI) and the user enter "Rules" in the form of: if operator(obj1) then assign(obj1,string)...

I take this rules, and translate them into actual code, and I want to put that code somewhere in a function/my code.

for example:

main {

UI...
/* when we reach here, means the user done writing rules */

/*Function that translate the user rules to actual code */
translate();

for {
/* This is where I want to put the code after translation */
}
}

How do I put the code inside the loop (or anywhere else for that matters) after the program started running?

I ofcourse don't look for an actual answer, more to give you an idea what I need so you can refer me to a certain subject to study about.

¿Fue útil?

Solución

I presume, you are in process of creating a custom rule engine, which has the capability of validating your rules on fly. Within my ability, you need to start reading c# scripting, code generation, dynamic loading or reflection etc are some to start with.

To give a kick start, following are some of the step which I can think off;

  1. Grab the rule definition (xml or csv)
  2. Write a small helper which will read rule entries from the definition and convert it into c# source code. This is similar to c# scripting.
  3. On successful completion of (2), create a dll out of the source code
  4. Now reflect/dynamically load the dll from (3) to where ever you wanted to validate the rule.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top