/// <summary>
 /// Construct from a querier traceroute hop.
 /// </summary>
 /// <param name="querierHop">The querier hop to construct from.</param>
 public TracerouteWebHop(ITracerouteHop querierHop)
 {
     this.Address      = querierHop.Address?.ToString();
     this.LossPercent  = querierHop.LossPercent;
     this.SentCount    = querierHop.SentCount;
     this.Status       = querierHop.Status.ToString();
     this.Info         = querierHop.Info;
     this.LastRttMs    = querierHop.LastRtt;
     this.AverageRttMs = querierHop.AverageRtt;
     this.BestRttMs    = querierHop.BestRtt;
     this.WorstRttMs   = querierHop.WorstRtt;
 }
        /// <summary>
        /// Formats as block-formatted string of an <see cref="ITracerouteHop" />.
        /// </summary>
        /// <param name="tracerouteHop">The data to format.</param>
        /// <returns>The formatted string.</returns>
        public string Format(ITracerouteHop tracerouteHop)
        {
            if (tracerouteHop == null)
            {
                return("<null>");
            }

            StringBuilder returnBuilder = new StringBuilder(256);

            returnBuilder
            .Append("Address:").Append(tracerouteHop.Address)
            .Append(", RTT ").Append(tracerouteHop.BestRtt)
            .Append(" / ").Append(tracerouteHop.AverageRtt)
            .Append(" / ").Append(tracerouteHop.WorstRtt)
            .Append(", Last RTT ").Append(tracerouteHop.LastRtt)
            .Append(", Loss ").Append(tracerouteHop.LossPercent)
            .Append(", Sent ").Append(tracerouteHop.SentCount);

            return(returnBuilder.ToString());
        }
        /// <summary>
        /// Formats a generic object if it's of one of the supported types.
        /// </summary>
        /// <param name="someObject">The object to format.</param>
        /// <returns>The formatted text.</returns>
        public string Format(object someObject)
        {
            if (someObject == null)
            {
                return("<null>");
            }

            IDeviceSystemData asDevSysData = someObject as IDeviceSystemData;

            if (asDevSysData != null)
            {
                return(this.Format(asDevSysData));
            }

            IInterfaceDetails asIfDetails = someObject as IInterfaceDetails;

            if (asIfDetails != null)
            {
                return(this.Format(asIfDetails));
            }

            IInterfaceDetail asIfDetail = someObject as IInterfaceDetail;

            if (asIfDetail != null)
            {
                return(this.Format(asIfDetail));
            }

            IWirelessPeerInfos asWiPeerInfos = someObject as IWirelessPeerInfos;

            if (asWiPeerInfos != null)
            {
                return(this.Format(asWiPeerInfos));
            }

            IWirelessPeerInfo asWiPeerInfo = someObject as IWirelessPeerInfo;

            if (asWiPeerInfo != null)
            {
                return(this.Format(asWiPeerInfo));
            }

            ILinkDetails asLinkDetails = someObject as ILinkDetails;

            if (asLinkDetails != null)
            {
                return(this.Format(asLinkDetails));
            }

            IBgpPeers asBgpPeers = someObject as IBgpPeers;

            if (asBgpPeers != null)
            {
                return(this.Format(asBgpPeers));
            }

            IBgpPeer asBgpPeer = someObject as IBgpPeer;

            if (asBgpPeer != null)
            {
                return(this.Format(asBgpPeer));
            }

            ITracerouteResult asTracerouteResult = someObject as ITracerouteResult;

            if (asTracerouteResult != null)
            {
                return(this.Format(asTracerouteResult));
            }

            ITracerouteHop asTracerouteHop = someObject as ITracerouteHop;

            if (asTracerouteHop != null)
            {
                return(this.Format(asTracerouteHop));
            }

            // fallback: call the object's ToString
            return(someObject.ToString());
        }