/// <summary> /// Formats as block-formatted string of an <see cref="IBgpPeer" />. /// </summary> /// <param name="bgpPeer">The data to format.</param> /// <returns>The formatted string.</returns> public string Format(IBgpPeer bgpPeer) { if (bgpPeer == null) { return("<null>"); } StringBuilder returnBuilder = new StringBuilder(256); returnBuilder.Append("ID:").AppendLine(bgpPeer.Id); returnBuilder.Append("Name:").AppendLine(bgpPeer.Name); returnBuilder.Append("Instance").AppendLine(bgpPeer.Instance); returnBuilder.Append("Local Address: ").AppendLine(bgpPeer.LocalAddress?.ToString()); returnBuilder.Append("Remote Address: ").AppendLine(bgpPeer.RemoteAddress?.ToString()); returnBuilder.Append("Remote AS: ").AppendLine(bgpPeer.RemoteAs.ToString()); returnBuilder.Append("NextHop choice: ").AppendLine(bgpPeer.NexthopChoice); returnBuilder.Append("Multihop: ").AppendLine(bgpPeer.Multihop.ToString()); returnBuilder.Append("RouteReflex: ").AppendLine(bgpPeer.RouteReflect.ToString()); returnBuilder.Append("HoldTime: ").AppendLine(bgpPeer.HoldTime.ToString()); returnBuilder.Append("Ttl: ").AppendLine(bgpPeer.Ttl.ToString()); returnBuilder.Append("Address Families: ").AppendLine(string.Join(", ", bgpPeer.AddressFamilies.Select(f => f.ToString()))); returnBuilder.Append("Default Originate: ").AppendLine(bgpPeer.DefaultOriginate); returnBuilder.Append("Remove Priv. AS: ").AppendLine(bgpPeer.RemovePrivateAs.ToString()); returnBuilder.Append("AS Override: ").AppendLine(bgpPeer.AsOverride.ToString()); returnBuilder.Append("Passive: ").AppendLine(bgpPeer.Passive.ToString()); returnBuilder.Append("Use BFD: ").AppendLine(bgpPeer.UseBfd.ToString()); returnBuilder.Append("Remote ID: ").AppendLine(bgpPeer.RemoteId); returnBuilder.Append("Uptime: ").AppendLine(bgpPeer.Uptime.ToString()); returnBuilder.Append("Prefix count: ").AppendLine(bgpPeer.PrefixCount.ToString()); returnBuilder.Append("Updates sent: ").AppendLine(bgpPeer.UpdatesSent.ToString()); returnBuilder.Append("Updates received: ").AppendLine(bgpPeer.UpdatesReceived.ToString()); returnBuilder.Append("Withdrawn sent: ").AppendLine(bgpPeer.WithdrawnSent.ToString()); returnBuilder.Append("Withdrawn received: ").AppendLine(bgpPeer.WithdrawnReceived.ToString()); returnBuilder.Append("Remote hold time: ").AppendLine(bgpPeer.RemoteHoldTime.ToString()); returnBuilder.Append("Used hold time: ").AppendLine(bgpPeer.UsedHoldTime.ToString()); returnBuilder.Append("Used Keepalive time: ").AppendLine(bgpPeer.UsedKeepaliveTime.ToString()); returnBuilder.Append("Refresh Capability: ").AppendLine(bgpPeer.RefreshCapability.ToString()); returnBuilder.Append("AS4 Capability: ").AppendLine(bgpPeer.As4Capability.ToString()); returnBuilder.Append("State: ").AppendLine(bgpPeer.State); returnBuilder.Append("Established: ").AppendLine(bgpPeer.Established.ToString()); returnBuilder.Append("Disabled: ").AppendLine(bgpPeer.Disabled.ToString()); return(returnBuilder.ToString()); }
/// <summary> /// Copy-construct from an IBgpPeer. /// </summary> /// <param name="bgpPeer">The source to copy.</param> public BgpPeerStoreOnlyContainer(IBgpPeer bgpPeer) { this.Id = bgpPeer.Id; this.Name = bgpPeer.Name; this.Instance = bgpPeer.Instance; this.RemoteAddress = bgpPeer.RemoteAddress; this.RemoteAs = bgpPeer.RemoteAs; this.NexthopChoice = bgpPeer.NexthopChoice; this.Multihop = bgpPeer.Multihop; this.RouteReflect = bgpPeer.RouteReflect; this.HoldTime = bgpPeer.HoldTime; this.Ttl = bgpPeer.Ttl; this.AddressFamilies = bgpPeer.AddressFamilies; this.DefaultOriginate = bgpPeer.DefaultOriginate; this.RemovePrivateAs = bgpPeer.RemovePrivateAs; this.AsOverride = bgpPeer.AsOverride; this.Passive = bgpPeer.Passive; this.UseBfd = bgpPeer.UseBfd; this.RemoteId = bgpPeer.RemoteId; this.LocalAddress = bgpPeer.LocalAddress; this.Uptime = bgpPeer.Uptime; this.PrefixCount = bgpPeer.PrefixCount; this.UpdatesSent = bgpPeer.UpdatesSent; this.UpdatesReceived = bgpPeer.UpdatesReceived; this.WithdrawnSent = bgpPeer.WithdrawnSent; this.WithdrawnReceived = bgpPeer.WithdrawnReceived; this.RemoteHoldTime = bgpPeer.RemoteHoldTime; this.UsedHoldTime = bgpPeer.UsedHoldTime; this.UsedKeepaliveTime = bgpPeer.UsedKeepaliveTime; this.RefreshCapability = bgpPeer.RefreshCapability; this.As4Capability = bgpPeer.As4Capability; this.State = bgpPeer.State; this.Established = bgpPeer.Established; this.Disabled = bgpPeer.Disabled; this.StateEnumeration = bgpPeer.StateEnumeration; }
/// <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()); }