ln.skyscanner/SkyEntities.cs

62 lines
2.0 KiB
C#

// /**
// * File: SkyEntities.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.odb;
using ln.skyscanner.entities;
using System.IO;
using ln.http.resources;
using System.Linq;
using ln.types.odb.mapped;
namespace ln.skyscanner
{
public class SkyEntities
{
[Callable]
public Node[] Nodes => nodeCollection.ToArray();
public SkyScanner SkyScanner { get; }
public string BasePath => Path.Combine(SkyScanner.BasePath, "entities");
public GlobalNetwork GlobalNetwork { get; private set; }
public ODB odDatabase { get; private set; }
public ODBCollection<Node> nodeCollection { get; private set; }
//public ODBCollection<NetworkInterface> interfaceCollection { get; private set; }
//public ODBCollection<IntfIP> intfIPCollection { get; private set; }
public ODBCollection<Subnet> subnetCollection { get; private set; }
public ODBCollection<PointOfPresence> popCollection { get; private set; }
public SkyEntities(SkyScanner skyScanner)
{
SkyScanner = skyScanner;
odDatabase = new ODB(BasePath);
nodeCollection = odDatabase.GetCollection<Node>();
subnetCollection = odDatabase.GetCollection<Subnet>();
nodeCollection.EnableStrongCache(true);
nodeCollection.EnsureIndex("PrimaryIP");
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].IP");
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].Network");
nodeCollection.EnsureIndex("uniqueIdentity");
subnetCollection.EnsureIndex("Network");
popCollection = odDatabase.GetCollection<PointOfPresence>();
popCollection.EnsureIndex("ForeignName");
popCollection.EnsureIndex("nodeIDList[]");
GlobalNetwork = new GlobalNetwork(this);
}
}
}