나는 두 가지 클래스의 부분 목록을 가지고 있습니다. CiscoSwitch 개체는 SwitchConnection 개체 목록을 다른 스위치에 유지 관리합니다. 내가 스위치 목록을 걸어 코드를 쓰려고 노력하고 서로 또는 다른 스위치의 연결 목록에 나열된 동일한 RemoteSwitchName 공통 연결을 가진 스위치를 반환하지만 그것은 목록에 없을 수도 있습니다 CiscoSwitches와 협력하고 있습니다.일부 프로그램 로직 요청 요청
예를 들어 A, B 및 C라는 3 개의 CiscoSwitch 인스턴스 목록이있는 경우 A와 B가 서로 연결될 수 있습니다. B와 C가 서로 직접 연결되어 있지는 않지만 둘 다 D에 연결되어있을 수 있습니다. A는 D에도 연결될 수 있습니다. 각 스위치 연결의 RemoteSwitchName 속성을 목록에있는 다른 스위치의 switchName 속성과 다른 스위치의 다른 SwitchConnections의 RemoteSwitchName 속성입니다.
가능하면 많은 foreach 루프보다는 LINQ를 사용하는 것을 선호합니다.
public CiscoSwitch
{
private string _SwitchName = String.Empty
public string switchName{ get{return _SwitchName;} set{_SwitchName=value;} }
...
public List<SwitchConnection> SwitchConnectionList = new List<SwitchConnection>();
...
}
public class SwitchConnection
// a switch connection is a connection to another switch
// a switch connection can have multiple portchannels
// a switch connection can exist across multiple VSANs
{
// the name of this switch
// not needed, deprecated
// private string _LocalSwitchName;
// public string LocalSwitchName { get { return _LocalSwitchName; } set { _LocalSwitchName = value; } }
// the name of the switch at the other end of the link
private string _RemoteSwitchName;
public string RemoteSwitchName { get { return _RemoteSwitchName; } set { _RemoteSwitchName = value; } }
private string _RemoteIPAddress;
public string RemoteIPAddress { get { return _RemoteIPAddress; } set { _RemoteIPAddress = value; } }
public Dictionary<int, PortChannel> LocalPortChannelList = new Dictionary<int,PortChannel>();
}
당신은 우리에게 이야기를하고 우리에게 몇 가지 코드를 보여주었습니다. 실제 질문은 무엇입니까? 너 뭐 해봤 니? – svick
-1 : 누락 된 질문 부분 외에도 질문 제목이 정말 나쁩니다. –
질문은 내가 원하는 것을하는 방법입니다. 나는 그것이 내가 게시 한 것에 분명하다고 생각했다. "스위치 목록을 탐색하고 목록간에 있지 않을 수도있는 스위치 또는 스위치간에 공통 연결을 되돌릴 수 있습니까?"라는 질문의 형태로 다시 작성되었습니다. 내가 시도한 것에 관해서는 중첩 된 foreach 루프에서 여러 시도를했지만 @ radarbob의 게시물을 읽은 후에 클래스에 몇 가지 메소드를 추가해야한다고 생각한다. –