PeerContact.PeerEndPoints 属性
定义
获取与此 PeerEndPointCollection 关联的 PeerContact。Gets the PeerEndPointCollection associated with this PeerContact.
public:
virtual property System::Net::PeerToPeer::Collaboration::PeerEndPointCollection ^ PeerEndPoints { System::Net::PeerToPeer::Collaboration::PeerEndPointCollection ^ get(); };
[get: System.Security.SecurityCritical]
public override System.Net.PeerToPeer.Collaboration.PeerEndPointCollection PeerEndPoints { get; }
[<get: System.Security.SecurityCritical>]
member this.PeerEndPoints : System.Net.PeerToPeer.Collaboration.PeerEndPointCollection
Public Overrides ReadOnly Property PeerEndPoints As PeerEndPointCollection
属性值
与此 PeerEndPoint 关联的 PeerContact 集合。The PeerEndPoint collection associated with this PeerContact. 此属性的默认值为 null。The default value for this property is null.
- 属性
例外
已释放 PeerContact 对象。This PeerContact object has been disposed.
示例
下面的代码示例演示了属性的正确用法 PeerEndPoints :The following code example illustrates the proper usage of the PeerEndPoints property:
// If more than one endpoint for a contact exists, let the user choose which to use.
//Parameters:
// pContact - contact to pick an endpoint for
// return value: pPeerEndpoint - the endpoint the user picked
private static PeerEndPoint PickEndpointForContact(PeerContact pContact)
{
PeerEndPointCollection endPointCollection = pContact.PeerEndPoints;
if (endPointCollection == null)
{
Console.WriteLine("Cannot return endpoint for contact {0} -- PeerEndPointCollection is null.", pContact);
return null;
}
if (endPointCollection.Count == 0)
{
Console.WriteLine("Cannot return endpoint for contact {0} -- PeerEndPointCollection is empty.", pContact);
return null;
}
foreach (PeerEndPoint pep in endPointCollection)
{
Console.WriteLine("PeerEndPoint is {0}:" , pep);
Console.WriteLine("PeerEndPoint information:\n Name: {0}\n IP Address: {1}\n Port: {2}\n",
pep.Name,
pep.EndPoint.Address,
pep.EndPoint.Port);
}
return endPointCollection[0];
}
注解
PeerEndPoint对于此实例所表示的对等互连,是本地对等方、远程对等方还是主机对等方,与该 PeerEndPoint 终结点或中的存在性无关 PeerEndPointCollection ContactManager 。Whether a PeerEndPoint is a local peer, remote peer, or host peer for the peer contact represented by this instance is not relevant to the presence of the PeerEndPoint in either the endpoint PeerEndPointCollection or the ContactManager.