29 |
LoadedConfigPlugins = new List<IConfigPlugin>(); |
LoadedConfigPlugins = new List<IConfigPlugin>(); |
30 |
LoadedInputPlugins = new List<IInputPlugin>(); |
LoadedInputPlugins = new List<IInputPlugin>(); |
31 |
LoadedWindowPlugins = new List<IWindowPlugin>(); |
LoadedWindowPlugins = new List<IWindowPlugin>(); |
32 |
|
LoadedUserControlPlugins = new List<IUserControlPlugin>(); |
33 |
} |
} |
34 |
#region IPluginLoader Members |
#region IPluginLoader Members |
35 |
public void LoadPlugins() { LoadPlugins(false); } |
public void LoadPlugins() { LoadPlugins(false); } |
54 |
GetConfigPluginsFromDll(fi); |
GetConfigPluginsFromDll(fi); |
55 |
GetInputPluginsFromDll(fi); |
GetInputPluginsFromDll(fi); |
56 |
GetWindowPluginsFromDll(fi); |
GetWindowPluginsFromDll(fi); |
57 |
|
GetUserControlPluginsFromDll(fi); |
58 |
} |
} |
59 |
|
|
60 |
if (!silent) |
if (!silent) |
64 |
if (!silent) |
if (!silent) |
65 |
logger.Info.WriteLine(" Loaded {0} window plugins", LoadedWindowPlugins.Count); |
logger.Info.WriteLine(" Loaded {0} window plugins", LoadedWindowPlugins.Count); |
66 |
if (!silent) |
if (!silent) |
67 |
|
logger.Info.WriteLine(" Loaded {0} usercontrol plugins", LoadedUserControlPlugins.Count); |
68 |
|
if (!silent) |
69 |
logger.Info.WriteLine("Plugins Loaded."); |
logger.Info.WriteLine("Plugins Loaded."); |
70 |
} |
} |
71 |
catch (ReflectionTypeLoadException ex) |
catch (ReflectionTypeLoadException ex) |
90 |
public List<IConfigPlugin> LoadedConfigPlugins { get; private set; } |
public List<IConfigPlugin> LoadedConfigPlugins { get; private set; } |
91 |
public List<IInputPlugin> LoadedInputPlugins { get; private set; } |
public List<IInputPlugin> LoadedInputPlugins { get; private set; } |
92 |
public List<IWindowPlugin> LoadedWindowPlugins { get; private set; } |
public List<IWindowPlugin> LoadedWindowPlugins { get; private set; } |
93 |
|
public List<IUserControlPlugin> LoadedUserControlPlugins { get; private set; } |
94 |
|
|
95 |
public IConfigPlugin GetConfigPlugin(string t) |
public IConfigPlugin GetConfigPlugin(string t) |
96 |
{ |
{ |
122 |
foreach (IWindowPlugin c in LoadedWindowPlugins) { } |
foreach (IWindowPlugin c in LoadedWindowPlugins) { } |
123 |
return null; |
return null; |
124 |
} |
} |
125 |
|
private IUserControlPlugin GetUserControlPlugin() |
126 |
|
{ |
127 |
|
foreach (IUserControlPlugin c in LoadedUserControlPlugins) { } |
128 |
|
return null; |
129 |
|
} |
130 |
#endregion |
#endregion |
131 |
|
|
132 |
private void GetConfigPluginsFromDll(FileInfo dll) |
private void GetConfigPluginsFromDll(FileInfo dll) |
223 |
} |
} |
224 |
} |
} |
225 |
} |
} |
226 |
|
} |
227 |
|
} |
228 |
|
private void GetUserControlPluginsFromDll(FileInfo dll) |
229 |
|
{ |
230 |
|
logger.Debug.WriteLine(" Getting UserControl plugins contained in {0}", dll.Name); |
231 |
|
Assembly asm = Assembly.LoadFile(dll.FullName); |
232 |
|
List<Type> types = new List<Type>(asm.GetTypes()); |
233 |
|
foreach (Type type in types) |
234 |
|
{ |
235 |
|
if (type.BaseType == typeof(UserControlPlugin)) |
236 |
|
{ |
237 |
|
ConstructorInfo ci = null; |
238 |
|
ci = type.GetConstructor(new Type[] { }); |
239 |
|
if (ci == null) |
240 |
|
{ |
241 |
|
throw new NullReferenceException(string.Format("Unable to bind to constructor for type: {0}", type.Name)); |
242 |
|
} |
243 |
|
else |
244 |
|
{ |
245 |
|
object o = ci.Invoke(new object[] { }); |
246 |
|
IUserControlPlugin c = (IUserControlPlugin)o; |
247 |
|
if (c == null) |
248 |
|
{ |
249 |
|
throw new NullReferenceException(string.Format("Failed to cast type {0} to IConfigPlugin", type.Name)); |
250 |
|
} |
251 |
|
else |
252 |
|
{ |
253 |
|
logger.Debug.WriteLine(" Loaded UserControl Plugin [name={0}] from {1}", c.Name, dll.Name); |
254 |
|
LoadedUserControlPlugins.Add(c); |
255 |
|
} |
256 |
|
} |
257 |
|
} |
258 |
} |
} |
259 |
} |
} |
260 |
} |
} |