Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Dictionary<string, Applet> loadApplets(string path)
- {
- Dictionary<string, Applet> applets = new Dictionary<string, Applet>();
- string[] files = Directory.GetFiles(path, "*.dll");
- foreach (string file in files)
- {
- try
- {
- Assembly a = Assembly.LoadFile(file);
- Type[] types = a.GetTypes();
- foreach (Type type in types)
- {
- if (type.GetInterface("IAppletPlugin") != null)
- {
- object[] attribs = type.GetCustomAttributes(
- typeof(AppletInformationAttribute), false);
- if (attribs.Length == 1)
- {
- System.Diagnostics.Debug.Print("Applet loaded");
- AppletInformationAttribute aia = (AppletInformationAttribute)attribs[0];
- Applet applet = new Applet(
- aia.AppletName,
- aia.AppletDescription,
- (IAppletPlugin)Activator.CreateInstance(type));
- applets.Add(aia.AppletName, applet);
- }
- }
- }
- }
- catch (Exception e)
- {
- System.Diagnostics.Debug.Print(e.Message);
- }
- }
- return applets;
- }
Add Comment
Please, Sign In to add comment