Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.60 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Dynamic;
  3. using IronRuby;
  4. using IronRuby.Builtins;
  5. using Microsoft.Scripting.Hosting;
  6. using Microsoft.Scripting;
  7.  
  8. namespace DynamicTest
  9. {
  10.         class MainClass
  11.         {
  12.                 public static void Main (string[] args)
  13.                 {
  14.                         var engine = Ruby.CreateEngine();
  15.                         engine.Execute (
  16. @"require 'mscorlib'
  17. require 'DynamicTest.exe'
  18. include DynamicTest
  19. include System
  20. ");
  21.                        
  22.                         var script = engine.CreateScriptSourceFromString (@"
  23. puts ex.foo
  24. ");
  25.                         dynamic ex = new ExpandoObject ();
  26.                         ex.foo = null;
  27.                         var scope = engine.CreateScope ();
  28.                         scope.SetVariable ("ex", ex);
  29.                         script.Execute (scope);
  30.                 }
  31.         }
  32. }