?? addressrange.cs
字號:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace SDP
{
/// <summary>
/// This class describes a range of addresses.
/// </summary>
public class AddressRange
{
private IPAddress address;
/// <summary>
/// Gets the value of the starting adress.
/// </summary>
public IPAddress Address
{
get { return this.address; }
}
private uint numberOfAddresses;
/// <summary>
/// Gets the number of ports in the range.
/// </summary>
public uint NumberOfAddresses
{
get { return this.numberOfAddresses; }
}
private byte ttl;
/// <summary>
/// Gets the Time To Live value.
/// </summary>
public byte TTL
{
get { return this.ttl; }
}
/// <summary>
/// Instantiates a new AddressRange.
/// </summary>
/// <param name="address">The unicast starting address. The default number of addresses is one, so this
/// range is effectively one address.</param>
public AddressRange(IPAddress address) : this(address, 1) { }
/// <summary>
/// Instantiates a new AddressRange.
/// </summary>
/// <param name="address">The multiciast starting address.</param>
/// <param name="ttl">The Time to Live.</param>
public AddressRange(IPAddress address, byte ttl) : this(address, 1, ttl) { }
/// <summary>
/// Instantiates a new AddressRange.
/// </summary>
/// <param name="address">The multicast hierarchial starting address.</param>
/// <param name="numberOfAddresses">The number of addresses in the range. This value must
/// be greater than or equal to one.</param>
/// <param name="ttl">The Time to Live.</param>
public AddressRange(IPAddress address, uint numberOfAddresses, byte ttl)
{
if (address == null) throw new ArgumentNullException("address");
if (numberOfAddresses < 1) throw new ArgumentException("Number of addresses must be greater than or equal to one.");
this.ttl = ttl;
this.address = address;
this.numberOfAddresses = numberOfAddresses;
}
/// <summary>
/// Converts an AddressRange to its string representation.
/// </summary>
/// <returns>A string.</returns>
public override string ToString()
{
string s = this.address.ToString();
if (this.ttl == 0) return s;
s = s + "/" + ttl.ToString();
if (this.numberOfAddresses == 1) return s;
s = s + "/" + numberOfAddresses;
return s;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -