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,9 +14,10 @@ namespace Umbraco.Core.Models
/// </summary>
[Serializable]
[DataContract]
public class PropertyGroupCollection : KeyedCollection<string, PropertyGroup>, INotifyCollectionChanged
public class PropertyGroupCollection : KeyedCollection<string, PropertyGroup>, INotifyCollectionChanged, IDeepCloneable
{
private readonly ReaderWriterLockSlim _addLocker = new ReaderWriterLockSlim();
internal Action OnAdd;
internal PropertyGroupCollection()
@@ -131,5 +133,15 @@ namespace Umbraco.Core.Models
CollectionChanged(this, args);
}
}
public T DeepClone<T>() where T : IDeepCloneable
{
var newGroup = new PropertyGroupCollection();
foreach (var p in this)
{
newGroup.Add(p.DeepClone<PropertyGroup>());
}
return (T)(object)newGroup;
}
}
}