/// <summary>
 /// Initialize with all parameters.
 /// </summary>
 /// <param name="interfaceDetail1">The interface details of side #1.</param>
 /// <param name="interfaceDetail2">The interface details of side #2</param>
 /// <param name="wirelessPeerInfo1">The wireless peer info of side #1.</param>
 /// <param name="wirelessPeerInfo2">The wireless peer info of side #2.</param>
 public LinkRelatedResultCollection(IInterfaceDetail interfaceDetail1, IInterfaceDetail interfaceDetail2, IWirelessPeerInfo wirelessPeerInfo1, IWirelessPeerInfo wirelessPeerInfo2)
 {
     this.WirelessPeerInfo1 = wirelessPeerInfo1;
     this.WirelessPeerInfo2 = wirelessPeerInfo2;
     this.InterfaceDetail1  = interfaceDetail1;
     this.InterfaceDetail2  = interfaceDetail2;
 }
        /// <summary>
        /// Formats as block-formatted string of an <see cref="IInterfaceDetail" />.
        /// </summary>
        /// <param name="interfaceDetail">The data to format.</param>
        /// <returns>The formatted string.</returns>
        public string Format(IInterfaceDetail interfaceDetail)
        {
            if (interfaceDetail == null)
            {
                return("<null>");
            }

            StringBuilder returnBuilder = new StringBuilder(256);

            returnBuilder.Append("Interface #").Append(interfaceDetail.InterfaceId).Append(" (").Append(string.IsNullOrWhiteSpace(interfaceDetail.InterfaceName) ? NotAvailableString : interfaceDetail.InterfaceName).AppendLine("):");
            returnBuilder.Append("  - Type: ").AppendLine(interfaceDetail.InterfaceType.ToString());
            returnBuilder.Append("  - MAC : ").Append(string.IsNullOrWhiteSpace(interfaceDetail.InterfaceName) ? NotAvailableString : interfaceDetail.MacAddressString);

            return(returnBuilder.ToString());
        }
        /// <summary>
        /// Copy-construct.
        /// </summary>
        /// <param name="source">The source to construct from.</param>
        public SerializableInterfaceDetail(IInterfaceDetail source)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source), "Source IInterfaceDetail is null");
            }

            this.InterfaceId      = source.InterfaceId;
            this.InterfaceType    = source.InterfaceType;
            this.MacAddressString = source.MacAddressString;
            this.InterfaceName    = source.InterfaceName;
            this.DeviceAddress    = source.DeviceAddress;
            this.DeviceModel      = source.DeviceModel;

            // we're intentionally not setting QueryDuration.
        }
 public VolatileFetchingInterfaceDetail(IInterfaceDetail underlyingInterfaceDetail, ISnmpLowerLayer lowerLayer)
 {
     this.underlyingInterfaceDetail = underlyingInterfaceDetail ?? throw new System.ArgumentNullException(nameof(underlyingInterfaceDetail));
     this.lowerLayer = lowerLayer ?? throw new System.ArgumentNullException(nameof(lowerLayer));
 }
        /// <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());
        }