title: Exposing specific namespaces to Jint
body: <p>I would like to allow scripts running in Jint to access a pre-existing API I have set up as a namespace. By that I mean I have a single namespace that contains the API, including other namespaces. I do not want to allow the scripts access to the rest of the code - including the .Net framework.</p>
  
  <p>I have already posted this on the Jint forum here: <a href="http://jint.codeplex.com/discussions/310772" rel="nofollow">http://jint.codeplex.com/discussions/310772</a>
  However, no disrespect to them but the forum does not appear to be very active and I would like to be able to answer this ASAP so I am posting here as well.</p>
  
  <p>A while ago, ThomasMaierhofer achieved something similar to this that I could probably modify to work this out here: <a href="http://jint.codeplex.com/discussions/211291" rel="nofollow">http://jint.codeplex.com/discussions/211291</a></p>
  
  <p>To my inexperienced brain this seems like a really neat way of exposing an API to the engine, but I have never seen it done like this before.</p>
  
  <p><strong>So my questions are: Would this work? And if so, why has it not been done like this before? And is there any way I could achieve this without modifying the Jint source so I can easily update the Jint .dll as new versions become available?</strong></p>
  
  <p><strong>EDIT:</strong>
  The current API I have consists of multiple classes each with multiple functions. I can expose specific instances of these classes absolutely fine using SetParameter. Jint also has an AllowClr property that allows the script to access the CLR by fully qualifying  namespaces. This is the example code they give demonstrating what happens if you set this to false.
  Source: <a href="http://jint.codeplex.com/wikipage?title=Using%20.NET%20classes%20from%20scripts" rel="nofollow">http://jint.codeplex.com/wikipage?title=Using%20.NET%20classes%20from%20scripts</a></p>
  
  <pre><code>string stringBuilder = @"
      var sb = new System.Text.StringBuilder();
      return sb.ToString();
      ";
  var engine = new JintEngine();
  engine.AllowClr = false;
  engine.Run(stringBuilder); // throws a SecurityException
  </code></pre>
  
  <p>I would like to allow this, but <strong>only for a specific namespace, not everything else.</strong> I hope that makes the question clearer.</p>
  
  <p>Thanks for your help,</p>
  
  <p>Sam.</p>
  
  <p>P.S. I am working in VB.Net but answers involving C# are fine.</p>