Пример #1
0
        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>();
                }
            }
        }
Пример #2
0
 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);
 }
Пример #3
0
 public SwitchPacketSegmentStructure(string name, PacketSegmentStructure refSegment, params SwitchCase[] map)
     : base(SimpleType.NotSimple, name)
 {
     Cases            = map.ToList();
     ReferenceSegment = refSegment;
 }
Пример #4
0
 public ListPacketSegmentStructure(string name, PacketSegmentStructure lengthSegment,
                                   params PacketSegmentStructure[] segments)
     : base(name, segments)
 {
     LengthSegment = lengthSegment;
 }
Пример #5
0
 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);
 }
Пример #6
0
 public PacketDefinition(PacketId packetId, PacketSender sender, PacketSegmentStructure structure)
 {
     PacketIds = new[] { packetId };
     Sender    = sender;
     Structure = structure ?? new ComplexPacketSegmentStructure();
 }
Пример #7
0
 public PacketDefinition(PacketId[] packetIds, PacketSender sender, PacketSegmentStructure structure)
 {
     PacketIds = packetIds;
     Sender    = sender;
     Structure = structure ?? new ComplexPacketSegmentStructure();
 }