/// <summary> /// /// </summary> /// <param name="verbose"></param> /// <param name="assembly"></param> /// <param name="agentLibrary"></param> /// <returns>returns a dictionary containing agentnames and a dictionary containing attributes for the agent</returns> public virtual List <Tuple <string, object> > InitAgents(bool verbose, string assembly, string agentLibrary) { List <Tuple <string, object> > agentsInit = null; string agentsInitFile = string.Format("{0}_{1}", agentLibrary, "init.txt"); // check if the agent init file exists if (!CheckAgentInitFile(agentsInitFile)) { throw new UsageException(string.Format("cannot find specified agent init file in directory '{0}' which should contain the agent init file '{1}'", config["InitPath"], agentsInitFile)); } if (verbose) { Console.Out.WriteLine(string.Format("reading initialisation file '{0}'", agentsInitFile)); } try { agentsInit = AgentInitParser.initAgentFile(GetAgentInitFileString(agentsInitFile)); } catch (Exception e) { try { agentsInit = AgentInitParser.initAgentFile(GetAgentInitFileString(assembly, agentsInitFile)); } catch (Exception) { throw new UsageException("reading agent initialisation file Failed", e); } } return(agentsInit); }
/// <summary> /// /// </summary> /// <param name="verbose"></param> /// <param name="assembly"></param> /// <param name="agentLibrary"></param> /// <returns>returns a dictionary containing agentnames and a dictionary containing attributes for the agent</returns> public override List <Tuple <string, object> > InitAgents(bool verbose, string assembly, string agentLibrary) { if (connector == null || !connector.Ready()) { return(null); } List <Tuple <string, object> > agentsInit = null; string agentsInitFile = string.Format("{0}_{1}", agentLibrary, "init.txt"); // check if the agent init file exists //if (connector.GetInitFileStream(agentsInitFile) == null) // throw new UsageException(string.Format("cannot find specified agent init file in for library '{0}' in the resources", // agentLibrary)); if (verbose) { Console.Out.WriteLine(string.Format("reading initialisation file '{0}'", agentsInitFile)); } try { agentsInit = AgentInitParser.initAgentFile(connector.GetInitFileStream(agentsInitFile)); } catch (Exception) { try { agentsInit = AgentInitParser.initAgentFile(connector.GetInitFileStream(agentLibrary)); } catch (Exception) { //TODO: meaningfull error message regarding the agentinit file which seems to be either corrupt or not linked } } return(agentsInit); }