/// <summary>
        /// Gets the <see cref="DateTime"/> equivalent of the <see cref="Timestamp"/>.
        /// </summary>
        /// <param name="block">The <see cref="InterfaceDescriptionBlock"/> used to determine the resolution of the <see cref="Timestamp"/>.</param>
        /// <param name="precisionLoss">True if there was precision loss during the transformation.</param>
        /// <returns>The <see cref="DateTime"/> equivalent of the <see cref="Timestamp"/>.</returns>
        public DateTime GetTimestamp(InterfaceDescriptionBlock block, out bool precisionLoss)
        {
            TimestampTransformer transformer;

            try
            {
                transformer = block.GetTimestampTransformer();
            }
            catch (NotImplementedException ex)
            {
                throw new NotSupportedException(ex.Message, ex);
            }
            precisionLoss = transformer.PrecisionLoss;
            return(transformer.ToDateTime(this.Timestamp));
        }
Esempio n. 2
0
        /// <summary>
        /// Read the next block from the file cursor upcast to the base class.
        /// </summary>
        /// <returns>The next block from the file cursor upcast to the base class.</returns>
        /// <remarks>The return type will be the base class (<see cref="BlockBaser"/>) but the actual type will be different.</remarks>
        public BlockBase ReadBlock()
        {
            BlockBase block;
            BlockType type = this.PeekStoreType();

            switch (type)
            {
            case BlockType.EnhancedPacket:
                block = new EnhancedPacketBlock(this.reader);
                break;

            case BlockType.InterfaceDescription:
                block = new InterfaceDescriptionBlock(this.reader);
                break;

            case BlockType.InterfaceStatistics:
                block = new InterfaceStatisticsBlock(this.reader);
                break;

            case BlockType.NameResolution:
                block = new NameResolutionBlock(this.reader);
                break;

            case BlockType.Packet:
                block = new PacketBlock(this.reader);
                break;

            case BlockType.SectionHeader:
                block = new SectionHeaderBlock(this.reader);
                break;

            case BlockType.SimplePacket:
                block = new SimplePacketBlock(this.reader);
                break;

            case BlockType.None:
                block = null;
                break;

            default:
                throw new IOException("Unable to determine the block type (type = " + type + ").");
            }

            return(block);
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the <see cref="DateTime"/> equivalent of the <see cref="Timestamp"/>.
 /// </summary>
 /// <param name="block">The <see cref="InterfaceDescriptionBlock"/> used to determine the resolution of the <see cref="Timestamp"/>.</param>
 /// <param name="precisionLoss">True if there was precision loss during the transformation.</param>
 /// <returns>The <see cref="DateTime"/> equivalent of the <see cref="Timestamp"/>.</returns>
 public DateTime GetTimestamp(InterfaceDescriptionBlock block, out bool precisionLoss)
 {
     TimestampTransformer transformer;
     try
     {
         transformer = block.GetTimestampTransformer();
     }
     catch (NotImplementedException ex)
     {
         throw new NotSupportedException(ex.Message, ex);
     }
     precisionLoss = transformer.PrecisionLoss;
     return transformer.ToDateTime(this.Timestamp);
 }
 public DateTime GetTimestamp(InterfaceDescriptionBlock block)
 {
     return(DateTime.FromBinary(this.Timestamp / block.GetTimePrecisionDivisor()));
 }
 public DateTime GetTimestamp(InterfaceDescriptionBlock block)
 {
     return DateTime.FromBinary(this.Timestamp / block.GetTimePrecisionDivisor());
 }