64 lines
1.4 KiB
C#
64 lines
1.4 KiB
C#
// /**
|
|
// * File: IPNode.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using ln.types;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
namespace ln.skyscanner.entities
|
|
{
|
|
public class Node
|
|
{
|
|
public GlobalNetwork GlobalNetwork { get; private set; }
|
|
|
|
public CIDR PrimaryIP { get; set; }
|
|
public String PrimaryMac { get; set; }
|
|
public String Name { get; set; }
|
|
|
|
public DateTime Created { get; }
|
|
public Uri[] URIs => uris.ToArray();
|
|
|
|
|
|
private HashSet<Uri> uris = new HashSet<Uri>();
|
|
|
|
private Node()
|
|
{
|
|
}
|
|
|
|
public Node(GlobalNetwork globalNetwork, CIDR primaryIP)
|
|
{
|
|
GlobalNetwork = globalNetwork;
|
|
|
|
PrimaryIP = primaryIP;
|
|
Name = PrimaryIP.ToString();
|
|
Created = DateTime.Now;
|
|
}
|
|
|
|
public void RemoveURI(Uri uri)
|
|
{
|
|
foreach (Uri u in uris)
|
|
{
|
|
if (uri.Equals(u))
|
|
uris.Remove(u);
|
|
}
|
|
}
|
|
|
|
public void AddURI(Uri uri)
|
|
{
|
|
uris.Add(uri);
|
|
}
|
|
|
|
public IEnumerable<Uri> FindURIs(string scheme)
|
|
{
|
|
return uris.Where((u) => scheme.Equals(u.Scheme));
|
|
}
|
|
|
|
}
|
|
}
|