473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Execute C# Scripting in a Class Library

Is it possible to execute a C# string inside a méthod ?
I would like duplicate the same behavior than DataBinder.Eval méthod.

Example:
string code = "this.myProperty * 5;";
object result = someCSharpEvaluationObject.Eval(code);

is it possible ? with reflexion pehaps ?
Thanks
Nov 16 '05 #1
3 1208
If your class has a property myProperty you can just use

string code = this.myProperty * 5;
object result = someCSharpEvaluationObject.Eval(code);

Or did I misunderstand your question? Btw if myProperty is of type int, the
variable code should be declared as an int too.

HTH,

Razzie

"Ph. VALLAR" <Ph******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Is it possible to execute a C# string inside a méthod ?
I would like duplicate the same behavior than DataBinder.Eval méthod.

Example:
string code = "this.myProperty * 5;";
object result = someCSharpEvaluationObject.Eval(code);

is it possible ? with reflexion pehaps ?
Thanks

Nov 16 '05 #2

"Ph. VALLAR" <Ph******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Is it possible to execute a C# string inside a méthod ?
I would like duplicate the same behavior than DataBinder.Eval méthod.

Example:
string code = "this.myProperty * 5;";
object result = someCSharpEvaluationObject.Eval(code);


No, atleast not natively. You could write a parser and execution engine, but
that is a significant project. There *may* be a third party solution
available, but I Don't know of one.

There is a mechanism using jscript, but I don't think it will do what you
want. The jscript eval method executes in the context of the method that
calls it, which will likely not allow you to use this, etc as the method
would exist in a jscript assembly instead of in a C# one.
Nov 16 '05 #3
This might help:

http://www.codeproject.com/dotnet/evaluator.asp
Ph. VALLAR wrote:
Is it possible to execute a C# string inside a méthod ?
I would like duplicate the same behavior than DataBinder.Eval méthod.

Example:
string code = "this.myProperty * 5;";
object result = someCSharpEvaluationObject.Eval(code);

is it possible ? with reflexion pehaps ?
Thanks

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: The_Incubator | last post by:
As the subject suggests, I am interested in using Python as a scripting language for a game that is primarily implemented in C++, and I am also interested in using generators in those scripts... ...
4
by: Fred | last post by:
I have read and tried every combination for hours. I'm sorry, but I don't get it. How do I have a form with textboxes and buttons and allow click events to execute a server function then display...
2
by: Rory Plaire | last post by:
Hi, I've been working with the J# browser control. I understand that v1.1b is scriptable, but can't find any examples on how to do this. Can someone point me in the right direction? thanks,...
4
by: Etienne Fortin | last post by:
Now that VSA is dead, what can we do to implement scripting in .NET? I know this question was aked a couple of time, but .NET never really adressed the "scripting" side of programming. Even VSA was...
0
by: christopher diggins | last post by:
Using the OOTL (Object Oriented Template Library, http://www.ootl.org ) it would very feasable to write a scripting engine for C++ programs. The way this hypothetical engine would work is that...
9
by: BoloBaby | last post by:
I have an extremely vexing problem occurring in a program that I am writing. Consider the following block of code: Dim pDancer As New BEDancer mintIndex = mintIndex + 1 pDancer.DancerName =...
3
by: Dave Taylor | last post by:
I'm writing VB.NET code that controls an on-stream X-ray analyzer for determining elemental concentrations in slurry. The program retrieves X-ray peak intensity values and evaluates a regression...
3
by: Mel | last post by:
My server makes a url call that returns a whole bunch of javascripts. I will then have to execute them on the server. I stripped out everything between <bodyand </bodyand I can see the scripts. ...
7
ADezii
by: ADezii | last post by:
The next series of Tips will involve the Microsoft Scripting Runtime Library (Scrrun.dll). This Library is, in my humble opinion, one of the most useful and practical Libraries ever created. With the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.