adds initial commit of entity cloning
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user