CoreFeatures is an Enum to indicate what built-in features can be available in ReoScript run-time.

Change CoreFeatures

Pass a value of CoreFeatures to indicate what features are allowed to be available. (Default CoreFeatures is StandardFeatures)
ScriptRunningMachine srm = new ScriptRunningMachine(CoreFeatures.StandardFeatures);

To change CoreFeatures to FullFeatures:
ScriptRunningMachine srm = new ScriptRunningMachine(CoreFeatures.FullFeatures);

Sometimes you may don't want your user to user some built-in functions like alert, by remove CoreFeatures.Alert value to disable built-in alert function as below:
CoreFeatures features = CoreFeatures.StandardFeatures & ~(CoreFeatures.Alert);
ScriptRunningMachine srm = new ScriptRunningMachine(features);

Now if attempt to call alert function it will cause an exception to be thrown.
srm.Run("alert('hello');");     // Function is not defined: alert

Tips: sometimes you may also consider to make an override to the alert function by specifying same function name and an empty function body, because there is no exceptions will be caused when user attempt to call this function.

Feature List

Below are the items of CoreFeatures, they could used to change the core features.
  • Alert - alert built-in function
  • Eval - eval built-in function
  • AsyncCalling - Async call(including both setTimeout and setInterval internal function)
  • console - console built-in internal object
  • JSON - JSON built-in object
  • ArrayExtension - Linq-like Array Operations Library
And below are two collections which containing some items above:
  • StandardFeatures - Standard features collection available closely to the ECMAScript standard
  • ExtendedFeatures - All features, including standard features collection and ReoScript extensions

Last edited Jan 17, 2014 at 12:58 PM by unvell, version 5