Re: is there a very simple script interpreter?
From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 07/18/04
- Next message: David Logan: "Re: C# Printing??"
- Previous message: William Stacey [MVP]: "Re: TreeView Question"
- In reply to: hOSAM: "Re: is there a very simple script interpreter?"
- Next in thread: hOSAM: "Re: is there a very simple script interpreter?"
- Reply: hOSAM: "Re: is there a very simple script interpreter?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 18 Jul 2004 09:49:18 -0400
Another approach would be to serialize/deserialize a class as xml. You can
modify this "config" file as needed. You could sim your IF statements with
field values or use strings and parse the string. You could also allow c#
code in the strings and run it with the codedom class, but have not tried
that yet myself.
Config config = // get config via xml serializer from disk, etc.
switch(config.FuncName)
{
"func1":
if ( config.Compare == Operator.gt )
// do this
break;
"func2":
break;
}
public class Config
{
public string FuncName;
public Operator Compare;
}
public enum Operator
{
gt,
lt,
eq,
}
-- William Stacey, MVP "hOSAM" <bkazlak_BUT_NO_SPAMMING@yahoo.com> wrote in message news:uPF1JPCbEHA.1248@TK2MSFTNGP11.phx.gbl... > Hi Maurice, > > Actually, the script I am referring to would be written by a developer, and > yes it will be executed via reflection on the currently executing assembly. > > The application that will use this configuration scheme is really in need of > executing commands based on scripts. I can describe this application as " a > buiseness system that its flow will change every 3 months, but the basic and > atomic functionality will remain the same even after 100 years". > > For example, let's say that acommand named "RunSchedular" is invoked. At > this time the command will run functions func1(), then func2(), then > func3(). However, after 3 months from now, it will run func1(), then func2() > if and only if the return value from func1() is greater than 6. > > IF func1() > 6 > func2() > ELSE > func4() > END IF > > The problem is that every 3 months, the flow will change. Currently, I > cannot see anyway to get around this except for using custom configuration > script that will be interpretted at runtime. > > "Maurice Reeves" <maurice.reeves@gmail.com> wrote in message > news:cda31s$dtj@odak26.prod.google.com... > > You could use Reflection to instantiate your business logic and then > > look at your object and see if it has a Command corresponding to the > > name in the script, and if it does, execute it, but frankly that seems > > like a hell of a lot of overhead to do what should probably be done in > > the code itself. > > Why are you doing things this way? Did the client request it? > > > >
- Next message: David Logan: "Re: C# Printing??"
- Previous message: William Stacey [MVP]: "Re: TreeView Question"
- In reply to: hOSAM: "Re: is there a very simple script interpreter?"
- Next in thread: hOSAM: "Re: is there a very simple script interpreter?"
- Reply: hOSAM: "Re: is there a very simple script interpreter?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|