Files
ntpa/Ntp.Analyzer.Gui/Model/Host.cs
T

86 lines
2.4 KiB
C#

//
// Host.cs
//
// Author:
// Carsten Sonne Larsen <cs@innolan.dk>
//
// Copyright (c) 2013
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Net;
namespace Ntp.Analyzer.Gui.Model
{
public sealed class Host
{
private static int lastID = 1;
public Host ()
: this("new daemon", "192.168.1.1", 9070)
{
}
public Host (string name, string address, int port)
{
this.id = lastID++;
this.name = name;
this.address = address;
this.port = port;
}
private readonly int id;
private string name;
private string address;
private int port;
public int Id {
get { return id; }
}
public string Name {
get { return name; }
set { name = value; }
}
public string Address {
get { return address; }
set { address = value; }
}
public int Port {
get { return port; }
set { port = value; }
}
public IPAddress IpAddress {
get { return IPAddress.Parse (address); }
}
public IPEndPoint EndPoint {
get { return new IPEndPoint (IpAddress, port); }
}
public override string ToString ()
{
return String.Format ("{0} ({1}:{2})", Name, Address, Port);
}
}
}