public PacketEntry GetPacket(string moduleId, string cmd) { ModuleEntry module = null; foreach (ModuleEntry m in this._modules) { if (m.id == moduleId) { module = m; break; } } if (module == null) { return(null); } foreach (PacketEntry packet in module.packets) { if (packet.id == cmd) { return(packet); } } return(null); }
public void Parse(string text) { this.ParseInternalStructs(); XML xml = new XML(text); XMLList dtoNodes = xml.Elements("structs")[0].Elements(); foreach (XML dtoNode in dtoNodes) //parse structs { if (!this.CreateStruct(ushort.Parse(dtoNode.GetAttribute("id")), dtoNode.GetAttribute("name"), false, out DTOEntry dto)) { this.ParseField(dto, dtoNode, dtoNodes); } } XMLList moduleNodes = xml.Elements("modules")[0].Elements(); foreach (XML moduleNode in moduleNodes) //parse modules { ModuleEntry module = new ModuleEntry(); module.id = moduleNode.GetAttribute("id"); module.key = moduleNode.GetAttribute("key"); this._modules.Add(module); XMLList packetNodes = moduleNode.Elements(); foreach (XML packetNode in packetNodes) //parse packets { PacketEntry packet = new PacketEntry(this, module); packet.id = packetNode.GetAttribute("cmd"); packet.key = packetNode.GetAttribute("key"); packet.dto = this.FindDTO(packetNode.GetAttribute("struct")); if (packetNode.HasAttribute("reply")) { packet.reply = packetNode.GetAttribute("reply"); } module.packets.Add(packet); } } }
public PacketEntry(Interpreter interpreter, ModuleEntry module) { this._interpreter = interpreter; this.module = module; }