adds initial commit of entity cloning

This commit is contained in:
Shannon
2014-02-20 22:34:54 +11:00
parent a1067e676f
commit b7f7775b89
24 changed files with 406 additions and 137 deletions

View File

@@ -5,6 +5,7 @@ using System.Collections.Specialized;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
@@ -13,7 +14,7 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public class PropertyCollection : KeyedCollection<string, Property>, INotifyCollectionChanged
public class PropertyCollection : KeyedCollection<string, Property>, INotifyCollectionChanged, IDeepCloneable
{
private readonly ReaderWriterLockSlim _addLocker = new ReaderWriterLockSlim();
internal Action OnAdd;
@@ -195,5 +196,19 @@ namespace Umbraco.Core.Models
}
}
}
/// <summary>
/// Create a deep clone of this property collection
/// </summary>
/// <returns></returns>
public T DeepClone<T>() where T: IDeepCloneable
{
var newList = new PropertyCollection();
foreach (var p in this)
{
newList.Add(p.DeepClone<Property>());
}
return (T)(object)newList;
}
}
}