All cloners are now able to clone objects without default constructors; began work on a property-based expression tree cloner

git-svn-id: file:///srv/devel/repo-conversion/nusu@243 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2012-02-08 15:20:39 +00:00
parent 91da3679a8
commit db8c93eabd
8 changed files with 613 additions and 124 deletions

View file

@ -20,6 +20,7 @@ License along with this library
using System;
using System.Reflection;
using System.Runtime.Serialization;
namespace Nuclex.Support.Cloning {
@ -119,7 +120,7 @@ namespace Nuclex.Support.Cloning {
/// <returns>A clone of the original instance</returns>
private static object shallowCloneComplexFieldBased(object original) {
Type originalType = original.GetType();
object clone = Activator.CreateInstance(originalType);
object clone = FormatterServices.GetUninitializedObject(originalType);
FieldInfo[] fieldInfos = originalType.GetFields(
BindingFlags.Public | BindingFlags.NonPublic |
@ -196,7 +197,7 @@ namespace Nuclex.Support.Cloning {
/// <returns>A clone of the original instance</returns>
private static object deepCloneComplexFieldBased(object original) {
Type originalType = original.GetType();
object clone = Activator.CreateInstance(originalType);
object clone = FormatterServices.GetUninitializedObject(originalType);
FieldInfo[] fieldInfos = originalType.GetFields(
BindingFlags.Public | BindingFlags.NonPublic |