2using System.Collections.Generic;
4using System.Linq.Expressions;
5using System.Reflection;
22 #region Private Variables
26 private Memory sharedMemory;
27 private Dictionary<string, Routine> routines;
28 private Dictionary<object, Interpreter> locks;
30 private bool optimize;
34 #region Internal Properties
36 internal Dictionary<object, Interpreter> Locks
43 #region Public Methods
51 scanner =
new ScannerPrototype();
55 routines =
new Dictionary<string, Routine>();
57 locks =
new Dictionary<object, Interpreter>();
68 string path = relativeDirectoryPath;
70 foreach (
string dll
in System.IO.Directory.GetFiles(path,
"*.dll"))
73 if (dll == path +
"ScriptStack.dll")
76 Assembly assembly =
null;
80 assembly = Assembly.LoadFile(dll);
82 catch (Exception e) { }
84 Type[] arrayTypes = assembly.GetExportedTypes();
86 foreach (Type type
in arrayTypes)
89 if (!typeof(
Model).IsAssignableFrom(type))
92 ConstructorInfo constructorInfo =
null;
95 constructorInfo = type.GetConstructor(
new Type[0]);
97 catch (Exception e) {
continue; }
99 object objectHostModule = constructorInfo.Invoke(
new object[0]);
119 Assembly assembly =
null;
122 assembly = Assembly.LoadFile(relativeDirectoryPath);
124 catch (Exception e) { }
126 Type[] arrayTypes = assembly.GetExportedTypes();
128 foreach (Type type
in arrayTypes)
131 if (!typeof(
Model).IsAssignableFrom(type))
134 ConstructorInfo constructorInfo =
null;
137 constructorInfo = type.GetConstructor(
new Type[0]);
139 catch (Exception e) {
continue; }
141 object objectHostModule = constructorInfo.Invoke(
new object[0]);
166 return routines.ContainsKey(routine);
172 foreach (
Routine routine
in model.Routines)
180 foreach (
Routine routine
in model.Routines)
188 string name = routine.
Name;
190 if (routines.ContainsKey(name))
193 routine.Handler = host;
195 routines[name] = routine;
202 if (!routines.ContainsKey(routine))
205 routines.Remove(routine);
225 #region Public Properties
232 get {
return scanner; }
233 set { scanner = value; }
238 get {
return sharedMemory; }
241 public ReadOnlyDictionary<String, Routine>
Routines {
244 return new ReadOnlyDictionary<string, Routine>(routines);
250 get {
return debug; }
251 set { debug = value; }
256 get {
return optimize; }
257 set { optimize = value; }
262 get {
return new ReadOnlyDictionary<object,Interpreter>(locks); }
void LoadComponent(string relativeDirectoryPath)
Manager()
A Manager object is responsible for memory management, type evaluation and loading of plugins.
void Register(Model model)
ReadOnlyDictionary< object, Interpreter > ActiveLocks
bool IsRegistered(string routine)
Scanner Scanner
A Scanner reference.
void UnRegister(string routine)
void LoadComponents(string relativeDirectoryPath)
void Register(Routine routine)
Register a new Routine.
void UnRegister(Model model)
ReadOnlyDictionary< String, Routine > Routines
void Register(Routine routine, Host host)
static Memory AllocateSharedMemory()
A Routine is an abstract representation of a method.
The main interface to create a Host. A Host can implement Routine's to extend its functionality.