83 lines
2.1 KiB
C#
83 lines
2.1 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;
|
|
using Castle.DynamicProxy;
|
|
using ln.types.serialize;
|
|
using Castle.Components.DictionaryAdapter;
|
|
using System.Linq;
|
|
using ln.logging;
|
|
using ln.types.odb.values;
|
|
namespace ln.types.odb
|
|
{
|
|
|
|
public class ODB : IDisposable
|
|
{
|
|
public String BasePath { get; set; }
|
|
|
|
Dictionary<string, ODBCollection> collections = new Dictionary<string, ODBCollection>();
|
|
|
|
public ODB(string basePath)
|
|
{
|
|
BasePath = Path.GetFullPath(basePath);
|
|
if (!Directory.Exists(BasePath))
|
|
Directory.CreateDirectory(BasePath);
|
|
}
|
|
|
|
public ODBCollection GetCollection(string colName)
|
|
{
|
|
if (!collections.ContainsKey(colName))
|
|
collections[colName] = new ODBCollection(this, colName);
|
|
|
|
return collections[colName];
|
|
}
|
|
|
|
public ODBCollection<T> GetCollection<T>() where T:class
|
|
{
|
|
return new ODBCollection<T>(this);
|
|
}
|
|
|
|
|
|
internal void DisposeCollection(ODBCollection collection)
|
|
{
|
|
ODBCollection check = collections[collection.CollectionName];
|
|
if (check == collection)
|
|
collections.Remove(collection.CollectionName);
|
|
}
|
|
|
|
private void Initialize()
|
|
{
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
foreach (ODBCollection col in collections.Values.ToArray())
|
|
{
|
|
col.Dispose();
|
|
}
|
|
}
|
|
|
|
static ODB()
|
|
{
|
|
new ODBDocument();
|
|
new ODBNull();
|
|
new ODBStringValue();
|
|
new ODBList();
|
|
new ODBInteger();
|
|
new ODBUInteger();
|
|
new ODBLong();
|
|
new ODBULong();
|
|
new ODBDouble();
|
|
new ODBGuid();
|
|
}
|
|
|
|
}
|
|
} |