DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
Script.cs
Go to the documentation of this file.
1 using System;
2 using System.IO;
3 using System.Reflection;
4 using CSScriptLibrary;
5 
6 namespace DirectOutput.Scripting
7 {
8 
12  public class Script
13  {
17  public FileInfo File { get; private set; }
18 
19 
23  public bool Compiled
24  {
25  get
26  {
27  return (CompilationException == null);
28  }
29  }
30 
34  public Exception CompilationException { get; private set; }
35 
36 
40  public Assembly Assembly { get; set; }
41 
42 
50  public Script(string ScriptFilename, bool ThrowExceptions = false) : this(new FileInfo(ScriptFilename), ThrowExceptions) { }
51 
59  public Script(FileInfo ScriptFile, bool ThrowExceptions = false)
60  {
61  this.File = ScriptFile;
62 
63  Assembly A = null;
64  try
65  {
66  A = CSScript.Load(ScriptFile.FullName, null, true);
67  Assembly = A;
68  Log.Write("Script file loaded and compiled: {0}".Build(ScriptFile.FullName));
69  }
70  catch (Exception e)
71  {
72  CompilationException = e;
73 
74  Log.Exception("Could not load and compile script file: {0}".Build(ScriptFile.FullName), e);
75 
76  if (ThrowExceptions)
77  {
78  throw new Exception("A error occured while loading or loading the script file {0}.".Build(ScriptFile.FullName),e);
79  }
80  }
81 
82 
83  }
84 
88  public Script() { }
89 
90 
91  }
92 }