diff --git a/.gitignore b/.gitignore
index bf793ed..2452a0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,5 @@ Thumbs.db
# dotCover
*.dotCover
+
+ln.logging
\ No newline at end of file
diff --git a/ln.types.csproj b/ln.types.csproj
index 9eb57fa..65f6970 100644
--- a/ln.types.csproj
+++ b/ln.types.csproj
@@ -53,7 +53,6 @@
-
@@ -121,6 +120,15 @@
+
+
+
+
+
+
+
+
+
@@ -143,7 +151,7 @@
-
+
{D471A566-9FB6-41B2-A777-3C32874ECD0E}
ln.logging
diff --git a/ln.types.sln b/ln.types.sln
new file mode 100644
index 0000000..c542083
--- /dev/null
+++ b/ln.types.sln
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.types", "ln.types.csproj", "{8D9AB9A5-E513-4BA7-A450-534F6456BF28}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.types.test", "ln.types.test\ln.types.test.csproj", "{E39D8B11-7CF6-4C78-B723-F7E100121704}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.logging", "ln.logging\ln.logging.csproj", "{D471A566-9FB6-41B2-A777-3C32874ECD0E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E39D8B11-7CF6-4C78-B723-F7E100121704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E39D8B11-7CF6-4C78-B723-F7E100121704}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E39D8B11-7CF6-4C78-B723-F7E100121704}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E39D8B11-7CF6-4C78-B723-F7E100121704}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/ln.types.test/Program.cs b/ln.types.test/Program.cs
new file mode 100644
index 0000000..dabeed0
--- /dev/null
+++ b/ln.types.test/Program.cs
@@ -0,0 +1,90 @@
+// /**
+// * File: Program.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.ng.storage;
+using ln.types.odb.ng;
+using ln.logging;
+using System.Linq;
+
+namespace ln.types.test
+{
+ class MainClass
+ {
+ public static void Main(string[] args)
+ {
+ Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGDETAIL;
+ Logging.Log(LogLevel.DEBUG, "ln.types.odb.ng test suite");
+
+ using (IStorageContainer container = new Session(new FSStorageContainer(".")))
+ {
+ container.Open();
+
+ IStorage storage = container.GetStorage("test");
+
+ if (!storage.IsOpen)
+ storage.Open();
+
+ foreach (Guid documentID in storage.GetDocumentIDs())
+ {
+ Logging.Log(LogLevel.INFO, "DocumentID: {0}", documentID);
+ Document doc = storage.Load(documentID);
+ Logging.Log(LogLevel.INFO, doc.ToString());
+ doc["FeldC"] = doc["FeldC"].AsLong + 1;
+ storage.Save(doc);
+ }
+
+ Document document = new Document();
+
+ document["FeldA"] = "Ich bin das Feld A";
+ document["FeldB"] = "Ich bin das Feld B";
+ document["FeldC"] = new Random().Next();
+
+ storage.Save(document);
+ storage.Save(document);
+
+ ODBMapper mapper = new ODBMapper(container);
+
+ foreach (MapableClass mapableClass in mapper.GetDocumentIDs().Select((id)=>mapper.Load(id)))
+ {
+ Logging.Log(LogLevel.INFO, "mapper found: {0}",mapableClass);
+ mapableClass.ANumber++;
+ mapper.Save(mapableClass);
+ }
+
+ MapableClass mapable = new MapableClass();
+ mapper.Save(mapable);
+
+
+ storage.Close();
+ container.Close();
+ }
+ }
+ }
+
+ class MapableClass
+ {
+ public int ANumber { get; set; }
+ public String MyString;
+
+ public MapableClass()
+ {
+ ANumber = new Random().Next();
+ MyString = ANumber.ToString();
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[MapableClass ANumber={0} MyString={1}]",ANumber,MyString);
+ }
+
+
+ }
+
+}
diff --git a/ln.types.test/Properties/AssemblyInfo.cs b/ln.types.test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d21506a
--- /dev/null
+++ b/ln.types.test/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+// /**
+// * File: AssemblyInfo.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.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("ln.types.test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/ln.types.test/ln.types.test.csproj b/ln.types.test/ln.types.test.csproj
new file mode 100644
index 0000000..d4b68a2
--- /dev/null
+++ b/ln.types.test/ln.types.test.csproj
@@ -0,0 +1,47 @@
+
+
+
+ Debug
+ AnyCPU
+ {E39D8B11-7CF6-4C78-B723-F7E100121704}
+ Exe
+ ln.types.test
+ ln.types.test
+ v4.7
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ true
+
+
+ true
+ bin\Release
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}
+ ln.types
+
+
+ {D471A566-9FB6-41B2-A777-3C32874ECD0E}
+ ln.logging
+
+
+
+
\ No newline at end of file
diff --git a/odb/Storage.cs b/odb/Storage.cs
deleted file mode 100644
index 45b2c21..0000000
--- a/odb/Storage.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-namespace ln.types.odb
-{
- //public abstract class Storage
- //{
- // public Storage()
- // {
- // }
-
-
- // public abstract bool Contains(Guid persistenceID);
-
- // public abstract bool Store(PreparedObject preparedObject);
- // public abstract bool Load(PreparedObject preparedObject);
-
-
-
- //}
-}
diff --git a/odb/ng/Document.cs b/odb/ng/Document.cs
index 03b72f5..c811f54 100644
--- a/odb/ng/Document.cs
+++ b/odb/ng/Document.cs
@@ -10,13 +10,19 @@ namespace ln.types.odb.ng
private Dictionary properties = new Dictionary();
public Document()
- :base(0x1000)
+ :base(0x1001)
{
- ID = Guid.NewGuid();
+ ID = Guid.NewGuid();
}
- public Guid ID { get; }
- public DateTime StorageTimeStamp { get; private set; }
+ public Document(Guid id)
+ :base(0x1001)
+ {
+ ID = id;
+ }
+
+ public Guid ID { get; }
+ public DateTime StorageTimeStamp { get; set; }
public ODBCollection Collection { get; internal set; }
@@ -24,7 +30,7 @@ namespace ln.types.odb.ng
: this(documentID, bytes, 0, bytes.Length)
{ }
public Document(Guid documentID,byte[] bytes,int offset,int length)
- :this()
+ :this(documentID)
{
ID = documentID;
@@ -53,9 +59,10 @@ namespace ln.types.odb.ng
}
set
{
- if (ODBNull.Instance.Equals(value) && properties.ContainsKey(propName))
+ if (ODBNull.Instance.Equals(value))
{
- properties.Remove(propName);
+ if (properties.ContainsKey(propName))
+ properties.Remove(propName);
}
else
{
@@ -73,11 +80,22 @@ namespace ln.types.odb.ng
return !ODBNull.Instance.Equals(this[propName]);
}
- public override byte[] ToStorage()
+ public override ODBValue Clone()
+ {
+ Document clone = new Document(ID);
+ foreach (ODBValue fieldName in properties.Keys)
+ {
+ clone[fieldName] = this[fieldName].Clone();
+ }
+ return clone;
+ }
+
+ public override byte[] ToStorage()
{
MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
+ writer.Write(ID.ToByteArray());
writer.Write(properties.Count);
foreach (ODBValue propName in properties.Keys)
@@ -101,15 +119,15 @@ namespace ln.types.odb.ng
}
public override bool Equals(object obj)
{
- if (obj is ODBDocument)
+ if (obj is Document)
{
- ODBDocument you = obj as ODBDocument;
+ Document you = obj as Document;
return ID.Equals(you.ID);
}
return false;
}
- public bool ContentEquals(ODBDocument other)
+ public bool ContentEquals(Document other)
{
if (object.ReferenceEquals(null, other))
return false;
@@ -127,10 +145,10 @@ namespace ln.types.odb.ng
public override bool ValueEquals(ODBValue other)
{
- return ContentEquals(other as ODBDocument);
+ return ContentEquals(other as Document);
}
- public int CompareContent(ODBDocument other)
+ public int CompareContent(Document other)
{
ODBValue[] keys = Keys.Union(other.Keys).ToArray();
@@ -149,11 +167,11 @@ namespace ln.types.odb.ng
public override int CompareInType(ODBValue other)
{
- return CompareContent(other as ODBDocument);
+ return CompareContent(other as Document);
}
public override int CompareValueInType(ODBValue other)
{
- return CompareContent(other as ODBDocument);
+ return CompareContent(other as Document);
}
static Document()
diff --git a/odb/ng/IStorage.cs b/odb/ng/IStorage.cs
index b7185fb..74d2867 100644
--- a/odb/ng/IStorage.cs
+++ b/odb/ng/IStorage.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+
namespace ln.types.odb.ng
{
public interface IStorage
@@ -8,8 +9,8 @@ namespace ln.types.odb.ng
void Close();
bool IsOpen { get; }
- ODBDocument Load(Guid documentID);
- ODBDocument Save(ODBDocument document);
+ Document Load(Guid documentID);
+ void Save(Document document);
IEnumerable GetDocumentIDs();
}
diff --git a/odb/ng/IStorageContainer.cs b/odb/ng/IStorageContainer.cs
new file mode 100644
index 0000000..74932fe
--- /dev/null
+++ b/odb/ng/IStorageContainer.cs
@@ -0,0 +1,23 @@
+// /**
+// * File: IStorageContainer.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.Collections.Generic;
+namespace ln.types.odb.ng
+{
+ public interface IStorageContainer : IDisposable
+ {
+ void Open();
+ void Close();
+ bool IsOpen { get; }
+
+ IStorage GetStorage(string storageName);
+ IEnumerable GetStorageNames();
+ }
+}
diff --git a/odb/ng/ODBMapper.API.cs b/odb/ng/ODBMapper.API.cs
new file mode 100644
index 0000000..93e8712
--- /dev/null
+++ b/odb/ng/ODBMapper.API.cs
@@ -0,0 +1,88 @@
+using ln.types.btree;
+using System.Collections.Generic;
+using System;
+
+namespace ln.types.odb.ng
+{
+
+ public partial class ODBMapper
+ {
+ BTree forwardCache = new BTree();
+ Dictionary