Guest User

Sample usage

a guest
Dec 24th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. namespace ScriptInterpreter
  2. {
  3.     public partial class MainWindow : Window
  4.     {
  5.         public MainWindow()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.        
  10.         private void TryRuntimeCompiliationButton_Click(object sender, RoutedEventArgs e)
  11.         {
  12.             try
  13.             {
  14.                 Interpreter inter = new Interpreter();
  15.  
  16.                 inter.AddAssembly("System");
  17.                 inter.AddAssembly("System.Collections.Generic");
  18.  
  19.                 inter.LoadAssemblies();
  20.  
  21.                 inter.LoadIOClasses(@"IOClasses.cs");
  22.                 inter.LoadMethod(@"SampleMethod.cs");
  23.                 inter.Compile();
  24.  
  25.                 var input = new DummyIOClasses.InputClass(new List<double>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
  26.  
  27.                 object result = inter.ExecuteMethod(input);
  28.  
  29.                 DummyIOClasses.OutputClass output = result as DummyIOClasses.OutputClass;
  30.             }
  31.             catch (Exception ex)
  32.             {
  33.                 MessageBox.Show(ex.Message);
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment