/// <summary> /// Load a single extension. Has the same usage value as <see cref="FolderSetup_listeners(string, Dictionary{int, ServerExtensionInitializer}, Logging.Logging)"/> /// </summary> /// <param name="asmPath">Path to the assembly extension</param> /// <param name="output">The dictionary to put the link between ports and extensions</param> /// <param name="logOutput">Default : null. Logger to log information (ex : listener set up)</param> public static void LoadAssembly(string asmPath, Dictionary <PEndPoint, ServerExtensionInitializer> output, Logging.Logging logOutput = null) { var asm = Assembly.Load(File.ReadAllBytes(asmPath)); foreach (var tstr in INTERACTION_CLASSES) { Type t = asm.GetType(tstr); if (t == null) { continue; } MethodInfo minfo = t.GetMethod(LOAD_METHOD); if (minfo == null) { continue; } var dic = (Dictionary <PEndPoint, Action <Client> >)minfo.Invoke(null, new object[] { logOutput }); foreach (var entry in dic) { if (output.ContainsKey(entry.Key)) { if (logOutput != null) { logOutput.Alert("Assembly " + Path.GetFileNameWithoutExtension(asmPath) + " tried to bind port " + entry.Key.Port + ". That port is already bound"); } continue; } output.Add(entry.Key, new ServerExtensionInitializer(asm, entry.Value, asmPath)); Listener.Instantiate(entry.Key); if (logOutput != null) { logOutput.Log("Listener set up on port " + entry.Key.Port + " for assembly " + Path.GetFileNameWithoutExtension(asmPath)); } } } LOADED_ASSEMBLYS.Add(asm.GetName().Name, asm); EXTENSIONS_PATH.Add(asm.GetName().Name, asmPath); if (logOutput != null) { logOutput.Info("Extension assembly " + asm.GetName().Name + " loaded"); } }