51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
// /**
|
|
// * File: ODB.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 System.IO;
|
|
using System.Collections.Generic;
|
|
namespace ln.types.odb
|
|
{
|
|
public class ODB
|
|
{
|
|
public String BasePath { get; set; }
|
|
|
|
|
|
|
|
Dictionary<Guid, WeakReference<IPersistent>> persistentObjects = new Dictionary<Guid, WeakReference<IPersistent>>();
|
|
|
|
public ODB()
|
|
{
|
|
BasePath = Path.GetFullPath("./crawler");
|
|
if (!Directory.Exists(BasePath))
|
|
{
|
|
Directory.CreateDirectory(BasePath);
|
|
}
|
|
}
|
|
|
|
public IPersistent GetPersistent(Guid persistenceID)
|
|
{
|
|
if (persistentObjects.ContainsKey(persistenceID))
|
|
{
|
|
WeakReference<IPersistent> weakRef = persistentObjects[persistenceID];
|
|
IPersistent o = null;
|
|
|
|
if (weakRef.TryGetTarget(out o))
|
|
return o;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|