main.exe: main.cs WebThing.dll SoupSettings.so
gmcs $(CSFLAGS) -r:WebThing.dll main.cs
-WebThing.dll: WebThing.cs
- gmcs $(CSFLAGS) $(references) -target:library -out:$@ $<
+WebThing.dll: WebThing.cs WebThingPlugin.cs
+ gmcs $(CSFLAGS) $(references) -target:library -out:$@ $^
SoupSettings.so: SoupSettings.c
$(CC) $(CFLAGS) -shared $(LDFLAGS) $< -o $@
private Gtk.Table WidgetGrid;
private Gtk.Alignment InteriorOverlay;
- public Dictionary<string,object> Plugins;
+ public Dictionary<string,WebThingPlugin> Plugins;
public Dictionary<string,string> Options;
public string[] Arguments;
_Window.ShowAll();
- Plugins = new Dictionary<string, object>();
+ Plugins = new Dictionary<string,WebThingPlugin>();
// TODO: Conf.Get("plugins") instead of hard-coded path?
using (TextReader f = new StreamReader("plugins.conf")) {
string line;
public void LoadPlugin(string assemblyname) {
Assembly a = Assembly.LoadFile("plugins/" + assemblyname + ".dll");
- object obj = a.CreateInstance("Plugin", false, BindingFlags.ExactBinding, null, new object[] { this }, null, null);
- Plugins[assemblyname] = obj;
+ Type[] types = a.GetTypes();
+ foreach (Type t in types) {
+ if (t.GetInterface("WebThingPlugin") != null) {
+ WebThingPlugin p = (WebThingPlugin) a.CreateInstance(t.FullName, false, BindingFlags.ExactBinding, null, null, null, null);
+ p.Init(this);
+ Plugins[t.FullName] = p;
+ Console.WriteLine("Successfully loaded {0}", t.FullName);
+ }
+ }
}
public void AttachWidget(Gtk.Widget widget, CompassDirection direction, AttachOptions xoptions, AttachOptions yoptions) {