public AgentTemplateConfigWindow() { InitializeComponent(); for (int i = 0; i < AgentBase.AgentsTypesList.Length; i++) { cbType.Items.Add(AgentBase.AgentsTypesList[i]); } template = new AgentTemplate(); this.DataContext = template; }
public AgentTemplateConfigWindow(AgentTemplate template) { InitializeComponent(); this.template = template; this.DataContext = this.template; for (int i = 0; i < AgentBase.AgentsTypesList.Length; i++) { cbType.Items.Add(AgentBase.AgentsTypesList[i]); if (AgentBase.AgentsTypesList[i].Type.Name == template.Type) { cbType.SelectedIndex = i; } } }
IEnumerator LoadTemplates() { WWWForm form = new WWWForm(); StringBuilder query = new StringBuilder(); query.Append("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>").Append("\n"); query.Append("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>").Append("\n"); query.Append("PREFIX ajan: <http://www.ajan.de/ajan-ns#>").Append("\n"); query.Append("SELECT DISTINCT ?label ?uri ?capability").Append("\n"); query.Append("WHERE {?uri rdf:type ajan:AgentTemplate. ?uri rdfs:label ?label. ?uri ajan:endpoint ?endpoint. ?endpoint ajan:capability ?capability .}"); form.AddField("query", query.ToString()); using (UnityWebRequest www = UnityWebRequest.Post(Repository, form)) { yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); string response = www.downloadHandler.text; string[] lines = response.Split('\n'); templateList.Clear(); for (int i = 1; i < lines.Length-1; i++) { string[] line = lines[i].Split(','); string label = line[0].Replace("\n", "").Replace("\r", ""); AgentTemplate template = new AgentTemplate(); foreach (AgentTemplate entry in templateList) { if (entry.label.Equals(label)) { template = entry; break; } } if (template.label == null) { template.label = label; template.uri = line[1].Replace("\n", "").Replace("\r", ""); templateList.Add(template); atList.Add(line[0]); } template.endpoints.Add(line[2].Replace("\n", "").Replace("\r", "")); } } } }