2017-07-20 11:21:28 +02:00
|
|
|
|
using System;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
2012-12-15 10:44:09 +05:00
|
|
|
|
namespace Umbraco.Core.Events
|
|
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public class CopyEventArgs<TEntity> : CancellableObjectEventArgs<TEntity>, IEquatable<CopyEventArgs<TEntity>>
|
2014-08-20 17:01:12 +02:00
|
|
|
|
{
|
|
|
|
|
|
public CopyEventArgs(TEntity original, TEntity copy, bool canCancel, int parentId)
|
|
|
|
|
|
: base(original, canCancel)
|
|
|
|
|
|
{
|
|
|
|
|
|
Copy = copy;
|
|
|
|
|
|
ParentId = parentId;
|
|
|
|
|
|
}
|
2012-12-16 06:44:46 +05:00
|
|
|
|
|
2014-08-20 17:01:12 +02:00
|
|
|
|
public CopyEventArgs(TEntity eventObject, TEntity copy, int parentId)
|
|
|
|
|
|
: base(eventObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
Copy = copy;
|
|
|
|
|
|
ParentId = parentId;
|
|
|
|
|
|
}
|
2012-12-16 06:44:46 +05:00
|
|
|
|
|
2014-08-20 17:01:12 +02:00
|
|
|
|
public CopyEventArgs(TEntity eventObject, TEntity copy, bool canCancel, int parentId, bool relateToOriginal)
|
|
|
|
|
|
: base(eventObject, canCancel)
|
|
|
|
|
|
{
|
|
|
|
|
|
Copy = copy;
|
|
|
|
|
|
ParentId = parentId;
|
|
|
|
|
|
RelateToOriginal = relateToOriginal;
|
|
|
|
|
|
}
|
2012-12-16 06:44:46 +05:00
|
|
|
|
|
2014-08-20 17:01:12 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The copied entity
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public TEntity Copy { get; set; }
|
2012-12-21 07:17:27 +05:00
|
|
|
|
|
2014-08-20 17:01:12 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The original entity
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public TEntity Original
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return EventObject; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or Sets the Id of the objects new parent.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int ParentId { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public bool RelateToOriginal { get; set; }
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
|
|
|
|
|
public bool Equals(CopyEventArgs<TEntity> other)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ReferenceEquals(null, other)) return false;
|
|
|
|
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
|
|
return base.Equals(other) && EqualityComparer<TEntity>.Default.Equals(Copy, other.Copy) && ParentId == other.ParentId && RelateToOriginal == other.RelateToOriginal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
|
|
|
|
if (ReferenceEquals(this, obj)) return true;
|
|
|
|
|
|
if (obj.GetType() != this.GetType()) return false;
|
|
|
|
|
|
return Equals((CopyEventArgs<TEntity>) obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
unchecked
|
|
|
|
|
|
{
|
|
|
|
|
|
int hashCode = base.GetHashCode();
|
|
|
|
|
|
hashCode = (hashCode * 397) ^ EqualityComparer<TEntity>.Default.GetHashCode(Copy);
|
|
|
|
|
|
hashCode = (hashCode * 397) ^ ParentId;
|
|
|
|
|
|
hashCode = (hashCode * 397) ^ RelateToOriginal.GetHashCode();
|
|
|
|
|
|
return hashCode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(CopyEventArgs<TEntity> left, CopyEventArgs<TEntity> right)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Equals(left, right);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator !=(CopyEventArgs<TEntity> left, CopyEventArgs<TEntity> right)
|
|
|
|
|
|
{
|
|
|
|
|
|
return !Equals(left, right);
|
|
|
|
|
|
}
|
2014-08-20 17:01:12 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|