public override void LoadChildren() { Nodes.Clear(); try { PAKFile f = new PAKFile(Content); var result = PAKLoader.LoadModels(f); foreach (var tuple in result.Models) { string subgroupName = tuple.Item1; Nodes.Add(new ModelTreeNode(subgroupName, ModelFetcher(subgroupName))); } foreach (var msg in result.Messages) { Nodes.Add(msg); if (!this.Text.EndsWith("!")) { this.Text = this.Text + " !"; } } } catch (Exception e) { Nodes.Add("!!! " + e.Message); } }
private Func <Model> ModelFetcher(string sub) { //I feel like I've done too much javascript when this is a solution... return(() => { PAKFile f = new PAKFile(Content); var result = PAKLoader.LoadModels(f); return result.Models.FirstOrDefault(t => t.Item1 == sub).Item2; }); }