public ParsedSegment(PacketSegmentStructure structure, object value) { m_subSegments = new Dictionary <string, ParsedSegment>(StringComparer.InvariantCultureIgnoreCase); m_structure = structure; if (value is List <ParsedSegment> ) { var list = (List <ParsedSegment>)value; Value = list.Count; if (IsList) { throw new Exception("Used List-CTor for Segment that is not a list."); } m_list = list; } else { Value = value; if (IsList) { m_list = new List <ParsedSegment>(); } } }
public PacketSegmentStructure GetSegment(PacketSegmentStructure segment, string name) { foreach (var subSegment in segment) { if (subSegment == null) { // from here on segments arent initialized yet -> stop search return(null); } if (subSegment.Name == name) { return(subSegment); } var found = GetSegment(subSegment, name); if (found != null) { return(found); } } return(null); }
public SwitchPacketSegmentStructure(string name, PacketSegmentStructure refSegment, params SwitchCase[] map) : base(SimpleType.NotSimple, name) { Cases = map.ToList(); ReferenceSegment = refSegment; }
public ListPacketSegmentStructure(string name, PacketSegmentStructure lengthSegment, params PacketSegmentStructure[] segments) : base(name, segments) { LengthSegment = lengthSegment; }
static void WarnLength(SimpleType type, PacketSegmentStructure segment, PacketParser parser) { log.Warn( "Packet {0} has invalid definition and tries to read {1} with insufficient remaining length at {2}", parser.Packet.PacketId, type, segment); }
public PacketDefinition(PacketId packetId, PacketSender sender, PacketSegmentStructure structure) { PacketIds = new[] { packetId }; Sender = sender; Structure = structure ?? new ComplexPacketSegmentStructure(); }
public PacketDefinition(PacketId[] packetIds, PacketSender sender, PacketSegmentStructure structure) { PacketIds = packetIds; Sender = sender; Structure = structure ?? new ComplexPacketSegmentStructure(); }