Hi Peter,
Peter Bromberg [C# MVP] ha scritto:
Not sure what you mean about the
sharing of contexts, if your "Javascript context" means "client script" then
this won't do it - it doesn't run like interpreted Javascript in the browser.
I don't need to use any browser, don't worry ;-)
Let me explain better the scenario I'm currently dealing with. I have an
application with it's own context (implemented with a class called
ApplicationContext, could it be a good solution?) with some variables
and so on. Let's say[1]:
int foo = 3;
string bar = "this_is_bar";
Within this context there are some conditions defined by the user with
some javascript code: when they're executed the application can use them
as logical seitches (i.e. if such a condition is true, then do
something, else do something else). Moreover, user can define some
JavaScript functions that can be called within those conditions. Let's
suppose I have this function:
function f(a)
{
return a*a;
}
and a condition using this function, let's say:
function condition_1()
{
if (bar=="this_is_bar")
return f(foo);
else return foo;
}
as you could see in these scripts the user has defined some "logical"
using elements (foo,bar) belonging to the application context; moreover
there are cross-references between these scripts. If I use a dynamic
JScript compilation (and I won't talk about the loss of performance that
it brings). So I should implement something to make this JavaScript
context "talk" with my .NET application, and allow cross-reference
across the same JavaScript context.
Any suggestion?
Thanks in advance,
Giulio
--
[1] : actually I mapped all the variables to instances of a Variable
class I defined, that allow application to treat variables as they're
dynamic (or a sort of). So I actually have:
Variable foo = new Variable(3);
Variable bar = new Variable("this_is_bar");
In this way I can create assembly compiling dinamically the js code,
adding functions (invoked by reflection) taking objects as parameter
just to update the variables values as those Variable objects are
changed. In this way, i.e. compiling each js function into an assembly I
cannot use cross-referece, so I actually have *no* js context. So i
thought to compile all the functions within the same assembly. It's
functional but not so elegant. Moreover the dynamic compilation takes a
looooooooooooooooooong time ;-)