diff --git a/Source/Cloning/ExpressionTreeCloner.Test.cs b/Source/Cloning/ExpressionTreeCloner.Test.cs
index 618338a..f8461b7 100644
--- a/Source/Cloning/ExpressionTreeCloner.Test.cs
+++ b/Source/Cloning/ExpressionTreeCloner.Test.cs
@@ -27,23 +27,35 @@ using NUnit.Framework;
namespace Nuclex.Support.Cloning {
- /// Unit Test for the expression tree-based cloner
- [TestFixture]
- public class ExpressionTreeClonerTest : CloneFactoryTest {
+ /// Unit Test for the expression tree-based cloner
+ [TestFixture]
+ public class ExpressionTreeClonerTest : CloneFactoryTest {
- /// Initializes a new unit test suite for the reflection cloner
- public ExpressionTreeClonerTest() {
- this.cloneFactory = new ExpressionTreeCloner();
- }
+ /// Initializes a new unit test suite for the reflection cloner
+ public ExpressionTreeClonerTest() {
+ this.cloneFactory = new ExpressionTreeCloner();
+ }
- /// Verifies that clones of primitive types can be created
- [Test]
- public void PrimitiveTypesCanBeCloned() {
- int original = 12345;
- int clone = this.cloneFactory.ShallowClone(original, false);
- Assert.AreEqual(original, clone);
- }
+ /// Verifies that clones of primitive types can be created
+ [Test]
+ public void PrimitiveTypesCanBeCloned() {
+ int original = 12345;
+ int clone = this.cloneFactory.DeepClone(original, false);
+ Assert.AreEqual(original, clone);
+ }
+ /// Verifies that shallow clones of arrays can be made
+ [Test]
+ public void ReferenceTypesCanBeCloned() {
+ var original = new TestReferenceType() { TestField = 123, TestProperty = 456 };
+ TestReferenceType clone = this.cloneFactory.DeepClone(original, false);
+
+ Assert.AreNotSame(original, clone);
+ //Assert.AreEqual(original.TestField, clone.TestField);
+ //Assert.AreEqual(original.TestProperty, clone.TestProperty);
+ }
+
+#if false
/// Verifies that shallow clones of arrays can be made
[Test]
public void ShallowClonesOfArraysCanBeMade() {
@@ -166,11 +178,12 @@ namespace Nuclex.Support.Cloning {
HierarchicalReferenceType clone = this.cloneFactory.DeepClone(original, true);
VerifyClone(original, clone, isDeepClone: true, isPropertyBasedClone: true);
}
+#endif
- /// Clone factory being tested
- private ICloneFactory cloneFactory;
+ /// Clone factory being tested
+ private ICloneFactory cloneFactory;
- }
+ }
} // namespace Nuclex.Support.Cloning
diff --git a/Source/Cloning/ExpressionTreeCloner.cs b/Source/Cloning/ExpressionTreeCloner.cs
index cedc9af..1e0d38a 100644
--- a/Source/Cloning/ExpressionTreeCloner.cs
+++ b/Source/Cloning/ExpressionTreeCloner.cs
@@ -22,91 +22,168 @@ License along with this library
using System;
using System.Collections.Concurrent;
+using System.Reflection;
+using System.Linq.Expressions;
+using System.Collections.Generic;
namespace Nuclex.Support.Cloning {
- /// An action that takes its arguments as references to a structure
- /// Type of the first argument to the method
- /// Type of the second argument to the method
- /// First argument to the method
- /// Second argument to the method
- public delegate void ReferenceAction(ref TFirst first, ref TSecond second)
- where TFirst : struct
- where TSecond : struct;
+ /// An action that takes its arguments as references to a structure
+ /// Type of the first argument to the method
+ /// Type of the second argument to the method
+ /// First argument to the method
+ /// Second argument to the method
+ public delegate void ReferenceAction(ref TFirst first, ref TSecond second)
+ where TFirst : struct
+ where TSecond : struct;
- ///
- /// Cloning factory which uses expression trees to improve performance when cloning
- /// is a high-frequency action.
- ///
- public class ExpressionTreeCloner : ICloneFactory {
+ ///
+ /// Cloning factory which uses expression trees to improve performance when cloning
+ /// is a high-frequency action.
+ ///
+ public class ExpressionTreeCloner : ICloneFactory {
- /// Initializes the static members of the expression tree cloner
- static ExpressionTreeCloner() {
- shallowCloners = new ConcurrentDictionary>();
- deepCloners = new ConcurrentDictionary>();
- }
+ /// Initializes the static members of the expression tree cloner
+ static ExpressionTreeCloner() {
+ shallowCloners = new ConcurrentDictionary>();
+ deepCloners = new ConcurrentDictionary>();
+ }
- ///
- /// Creates a deep clone of the specified object, also creating clones of all
- /// child objects being referenced
- ///
- /// Type of the object that will be cloned
- /// Object that will be cloned
- ///
- /// Whether to clone the object based on its properties only
- ///
- /// A deep clone of the provided object
- public static TCloned DeepClone(
- TCloned objectToClone, bool usePropertyBasedClone
- ) {
- throw new NotImplementedException("Not implemented yet");
- }
+ ///
+ /// Creates a deep clone of the specified object, also creating clones of all
+ /// child objects being referenced
+ ///
+ /// Type of the object that will be cloned
+ /// Object that will be cloned
+ ///
+ /// Whether to clone the object based on its properties only
+ ///
+ /// A deep clone of the provided object
+ public static TCloned DeepClone(
+ TCloned objectToClone, bool usePropertyBasedClone
+ ) {
+ if(usePropertyBasedClone) {
+ throw new NotImplementedException("Not implemented yet");
+ } else {
+ Func