コード例 #1
0
ファイル: ParsedSegment.cs プロジェクト: NecroSharper/WCell
        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
ファイル: SimpleTypes.cs プロジェクト: NecroSharper/WCell
 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();
 }