// codebase/idl/idl.somename.dll contains generated API wrapper for somename // codebase/api/api.somename.dll contains actual user-written code for API private ApiInstance(string name, string codepath) { path = Path.Combine(Path.Combine(codepath, "idl"), "idl." + name + ".dll"); // todo: for runtime code replacement, use appdomains and refcount active requests assy = Assembly.LoadFile(path); if (assy == null) { throw new FileNotFoundException("Could not find assembly: " + path); } Console.WriteLine("Loaded {0} from {1}", name, path); foreach (Type t in assy.GetExportedTypes()) { Console.WriteLine("Examining type {0}", t.Name); if ((t.Name == name || t.Name == "idl." + name) && typeof(WrapperBase).IsAssignableFrom(t)) { Console.WriteLine("Found type {0}", t.Name); wrapper = (WrapperBase)assy.CreateInstance(t.FullName); wrapper.CodePath = codepath; wrapper.Initialize(); break; } } if (wrapper == null) { throw new FileNotFoundException("Could not instantiate wrapper type: " + path); } api_counter.Count(); }