示例#1
0
        public void OnAddPeer()
        {
            if(!CheckPeer())
            {
                GlobalMessageCenter.Instance.Send("MainWindow.MsgBox", "地址信息格式不对");
                return;
            }

            var peer = new PeerInfo()
            {
                Address = Address,
                Port = Port,
                Status = PeerStatus.Unknow,
                Range = PeerRange.Empty,
            };

            if (!CheckRepeat(peer))
            {
                GlobalMessageCenter.Instance.Send("MainWindow.MsgBox", "已存在该地址");
                return;
            }

            PeerInfoList.Add(peer);
        }
示例#2
0
 private bool CheckRepeat(PeerInfo peer)
 {
     return !PeerInfoList.Contains(peer, PeerInfoComparer.Default);
 }
示例#3
0
        private static Peer PeerInfo2Peer(PeerInfo info)
        {
            IPAddress addr;
            if (IPAddress.TryParse(info.Address, out addr))
            {
                return new Peer() { EndPoint = new IPEndPoint(addr, info.Port) };
            }

            return null;
        }