D
Don Stewart
Hello all,
Is there a way to take a user entered string and Compile it into a module or
function that I can use from within my program.
I want to allow the users to enter C# code that will fill a function that I
could call from within my code.
I would like to give the user some specific parameters that they can use and
have them write code that will return a value, so that the user can make
their own formula's.
Perhaps something in CodeDom?
Something like this really fake code??
- (Just trying to get my point accross):
Private void Sample()
{
string Users_Code_From_Text_Box =
"int SomeValue = (Parameter1 * Parameter2) / 3.14159;" +
"return SomeValue * 5;";
System.CodeDom.??FunctionModule?? UsersFunction =
System.CodeDom.??CompileFunctionModule??( Users_Code_From_Text_Box,
int, int, int);
int Result = UsersFunction.Run( 1, 2 );
MessageBox.Show( Result.ToString() );
}
Don stewart
(e-mail address removed)
Is there a way to take a user entered string and Compile it into a module or
function that I can use from within my program.
I want to allow the users to enter C# code that will fill a function that I
could call from within my code.
I would like to give the user some specific parameters that they can use and
have them write code that will return a value, so that the user can make
their own formula's.
Perhaps something in CodeDom?
Something like this really fake code??
- (Just trying to get my point accross):
Private void Sample()
{
string Users_Code_From_Text_Box =
"int SomeValue = (Parameter1 * Parameter2) / 3.14159;" +
"return SomeValue * 5;";
System.CodeDom.??FunctionModule?? UsersFunction =
System.CodeDom.??CompileFunctionModule??( Users_Code_From_Text_Box,
int, int, int);
int Result = UsersFunction.Run( 1, 2 );
MessageBox.Show( Result.ToString() );
}
Don stewart
(e-mail address removed)