Exemplo n.º 1
0
        /// <summary>
        /// Selects the packet context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="packet">The packet.</param>
        /// <returns>List with packet context.</returns>
        private static ICollection <Packet> SelectPacketContext(IExecutionContext context, PacketLocation packet)
        {
            List <Packet> packets;
            PacketLog     log = context.LogManager.GetPacketLog(packet.LogIndex);

            if (log != null && log.Count > 0)
            {
                // Calculate first/last indices
                int firstPacketIndex = Math.Max(0, packet.PacketIndex - PACKET_CONTEXT_SIZE);
                int lastPacketIndex  = Math.Min(log.Count, packet.PacketIndex + PACKET_CONTEXT_SIZE);

                // Select range
                packets = log.GetRange(firstPacketIndex, lastPacketIndex);
            }
            else
            {
                packets = new List <Packet>(0);
            }

            return(packets);
        }