X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=PluginManager.cs;h=7ef976cd022af09c2fb80b527e9d5ee8bd902bd4;hb=HEAD;hp=551d5fdf56d4f88afa4b5018a7ce6841767f2d0a;hpb=02acfc22dbfa3d145d265157fdf616a950fa30c6;p=WebThing.git diff --git a/PluginManager.cs b/PluginManager.cs index 551d5fd..7ef976c 100644 --- a/PluginManager.cs +++ b/PluginManager.cs @@ -23,10 +23,14 @@ namespace bytex64.WebThing { } public void LoadPlugin(string assemblyname) { - Assembly a = Assembly.LoadFile(Environment.GetEnvironmentVariable("WEBTHING_HOME") + "/plugins/" + assemblyname + ".dll"); + Assembly a = FindAssembly(assemblyname); + if (a == null) return; Type[] types = a.GetTypes(); + foreach (Type t in types) { if (t.IsSubclassOf(typeof(WebThingPlugin))) { + if (Plugins.ContainsKey(t.FullName)) + continue; WebThingPlugin p = (WebThingPlugin) a.CreateInstance(t.FullName, false, BindingFlags.ExactBinding, null, null, null, null); p.Init(wt); Plugins[t.FullName] = p; @@ -36,6 +40,17 @@ namespace bytex64.WebThing { } } + private Assembly FindAssembly(string assemblyname) { + foreach (string path in Config.PluginPath) { + try { + return Assembly.LoadFile(path + "/" + assemblyname + ".dll"); + } catch { + } + } + Console.WriteLine("Could not find {0}", assemblyname); + return null; + } + public void WebViewSetup(WebView view) { foreach (string key in PluginOrder) { Plugins[key].InitWebView(view);