Index: /branches/New Persistence Exploration/Persistence/Persistence.sln
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence.sln (revision 1337)
+++ /branches/New Persistence Exploration/Persistence/Persistence.sln (revision 1338)
@@ -3,4 +3,6 @@
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistence", "Persistence\Persistence.csproj", "{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{E2245078-6F40-449E-A370-01A97A7C5E6A}"
EndProject
Global
@@ -18,4 +20,10 @@
{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}.Release|Any CPU.Build.0 = Release|Any CPU
{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}.Release|x86.ActiveCfg = Release|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E2245078-6F40-449E-A370-01A97A7C5E6A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Index: /branches/New Persistence Exploration/Persistence/Persistence/Persistence.csproj
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Persistence.csproj (revision 1337)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Persistence.csproj (revision 1338)
@@ -7,5 +7,5 @@
2.0{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}
- Exe
+ LibraryPropertiesPersistence
@@ -13,5 +13,6 @@
v3.5512
- Persistence.Test.NewSerializationTest
+
+
@@ -53,16 +54,20 @@
+
+
-
+
+ SubWCRev "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.frame" "$(ProjectDir)\Properties\AssemblyInfo.cs"
+
Index: /branches/New Persistence Exploration/Persistence/Persistence/Properties/AssemblyInfo.frame
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Properties/AssemblyInfo.frame (revision 1338)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Properties/AssemblyInfo.frame (revision 1338)
@@ -0,0 +1,54 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Persistence")]
+[assembly: AssemblyDescription("General Purpose Persistence Framework.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2009 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f28c9f48-64f8-4dfe-b6e3-53f5f4b9f429")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("3.0.0.$WCREV$")]
+[assembly: AssemblyFileVersion("3.0.0.$WCREV$")]
Index: /branches/New Persistence Exploration/Persistence/Persistence/StorableAttribute.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/StorableAttribute.cs (revision 1337)
+++ /branches/New Persistence Exploration/Persistence/Persistence/StorableAttribute.cs (revision 1338)
@@ -51,5 +51,5 @@
}
- class CloningFactory {
+ public class CloningFactory {
private static readonly CloningFactory instance = new CloningFactory();
@@ -208,21 +208,16 @@
}
}
- }
-
- public interface IDataMemberAccessor {
- string Name { get; }
- Type Type { get; }
- object DefaultValue { get; }
- object Get();
- void Set(object value);
- }
+ }
- public class DataMemberAccessor : IDataMemberAccessor {
+ public class DataMemberAccessor {
public delegate object Getter();
public delegate void Setter(object value);
- private readonly Getter getter;
- private readonly Setter setter;
+ public readonly Getter Get;
+ public readonly Setter Set;
+ public readonly string Name;
+ public readonly Type Type;
+ public readonly object DefaultValue;
public DataMemberAccessor(
@@ -232,6 +227,6 @@
if (memberInfo.MemberType == MemberTypes.Field) {
FieldInfo fieldInfo = (FieldInfo)memberInfo;
- getter = () => fieldInfo.GetValue(obj);
- setter = value => fieldInfo.SetValue(obj, value);
+ Get = () => fieldInfo.GetValue(obj);
+ Set = value => fieldInfo.SetValue(obj, value);
Type = fieldInfo.FieldType;
} else if (memberInfo.MemberType == MemberTypes.Property) {
@@ -241,6 +236,6 @@
"Storable properties must implement both a Get and a Set Accessor. ");
}
- getter = () => propertyInfo.GetValue(obj, null);
- setter = value => propertyInfo.SetValue(obj, value, null);
+ Get = () => propertyInfo.GetValue(obj, null);
+ Set = value => propertyInfo.SetValue(obj, value, null);
Type = propertyInfo.PropertyType;
} else {
@@ -258,24 +253,15 @@
Type = type;
DefaultValue = defaultValue;
- this.getter = getter;
- this.setter = setter;
+ Get = getter;
+ Set = setter;
}
public DataMemberAccessor(object o) {
+ Name = null;
Type = o.GetType();
DefaultValue = null;
- getter = () => o;
- setter = null;
- }
-
- public string Name { get; private set; }
- public Type Type { get; private set; }
- public object DefaultValue { get; private set; }
- public object Get() {
- return getter();
- }
- public void Set(object value) {
- setter(value);
- }
+ Get = () => o;
+ Set = null;
+ }
public override string ToString() {
return String.Format("DataMember({0}, {1}, {2}, {3}, {4}",
@@ -283,6 +269,6 @@
Type == null ? "" : Type.FullName,
DefaultValue ?? "",
- getter.Method,
- setter.Method);
+ Get.Method,
+ Set.Method);
}
}
Index: /branches/New Persistence Exploration/Persistence/Persistence/Test/NewSerializationTest.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Test/NewSerializationTest.cs (revision 1337)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Test/NewSerializationTest.cs (revision 1338)
@@ -141,132 +141,3 @@
}
}
-
- public class NewSerializationTest {
-
- public static void Test1() {
- Root r = new Root();
- r.selfReferences = new List {r, r};
- r.c = new Custom {r = r};
- r.dict.Add("one", 1);
- r.dict.Add("two", 2);
- r.dict.Add("three", 3);
- Serializer s = new Serializer(r);
- Persistence.XmlFormatter xmlFormatter = new XmlFormatter();
- //StreamWriter writer = new StreamWriter("test.xml");
- foreach (ISerializationToken token in s) {
- string line = xmlFormatter.Format(token);
- //writer.Write(line);
- Console.Out.Write(line);
- }
- //writer.Close();
- XmlParser parser = new XmlParser(new StreamReader("test.xml"));
- DeSerializer deSerializer = new DeSerializer();
- object o = deSerializer.DeSerialize(parser);
- Root t = CloningFactory.DefaultClone(r);
- Console.Out.WriteLine(Util.AutoFormat(o, true));
- }
-
- public static void Test2() {
- Manager m = new Manager();
- Serializer s = new Serializer(m);
- Persistence.XmlFormatter xmlFormatter = new XmlFormatter();
- StreamWriter writer = new StreamWriter("test2.xml");
- foreach (ISerializationToken token in s) {
- string line = xmlFormatter.Format(token);
- writer.Write(line);
- Console.Out.Write(line);
- }
- writer.Close();
- XmlParser parser = new XmlParser(new StreamReader("test2.xml"));
- DeSerializer deSerializer = new DeSerializer();
- object o = deSerializer.DeSerialize(parser);
- Manager n = CloningFactory.DefaultClone(m);
- Console.Out.WriteLine(Util.AutoFormat(o, true));
- }
-
- public static void SpeedTest() {
- StorableObject storable = new StorableObject();
- CloneableObject cloneable = new CloneableObject();
- Console.Write("initializing...");
- storable.Init();
- cloneable.Init();
- Console.WriteLine("done");
- List storableClones = new List();
- List clonableClones = new List();
- CloningFactory cloningFactory = new CloningFactory();
- for (int i = 0; i < 100000; i++) {
- Console.Write("cloning storable.. ");
- storableClones.Add(cloningFactory.Clone(storable));
- Console.WriteLine();
- Console.Write("cloning cloneable.. ");
- clonableClones.Add((CloneableObject)cloneable.Clone());
- Console.WriteLine();
- }
- }
-
- public static void SpeedTest2() {
- Root r = new Root();
- r.selfReferences = new List {r, r};
- r.c = new Custom {r = r};
- r.dict.Add("one", 1);
- r.dict.Add("two", 2);
- r.dict.Add("three", 3);
-
- CloneableRoot cr = new CloneableRoot();
- cr.selfReferences = new List {cr, cr};
- cr.c = new CloneableCustom {r = cr};
- cr.dict.Add("one", 1);
- cr.dict.Add("two", 2);
- cr.dict.Add("three", 3);
- List storableClones = new List();
- List clonableClones = new List();
- CloningFactory cloningFactory = new CloningFactory();
-
- DateTime start = DateTime.Now;
- Console.Write("cloning storable.. ");
- for (int i = 0; i < 100000; i++) {
- storableClones.Add(cloningFactory.Clone(r));
- }
- Console.WriteLine(new TimeSpan(DateTime.Now.Ticks - start.Ticks));
-
- start = DateTime.Now;
- Console.Write("cloning storable again.. ");
- for (int i = 0; i < 100000; i++) {
- storableClones.Add(cloningFactory.Clone(r));
- }
- Console.WriteLine(new TimeSpan(DateTime.Now.Ticks - start.Ticks));
-
- start = DateTime.Now;
- Console.Write("cloning cloneable.. ");
- for (int i = 0; i < 100000; i++) {
- clonableClones.Add((CloneableRoot)cr.Clone(new Dictionary