using System; using System.Runtime.Serialization; using System.Threading.Tasks; using Umbraco.Core.Dynamics; namespace Umbraco.Web.Models { [DataContract(Name = "imageCropData")] public class ImageCropData : CaseInsensitiveDynamicObject, IEquatable { [DataMember(Name = "alias")] public string Alias { get; set; } [DataMember(Name = "width")] public int Width { get; set; } [DataMember(Name = "height")] public int Height { get; set; } [DataMember(Name = "coordinates")] public ImageCropCoordinates Coordinates { get; set; } /// /// Indicates whether the current object is equal to another object of the same type. /// /// /// true if the current object is equal to the parameter; otherwise, false. /// /// An object to compare with this object. public bool Equals(ImageCropData other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return string.Equals(Alias, other.Alias) && Width == other.Width && Height == other.Height && Equals(Coordinates, other.Coordinates); } /// /// Determines whether the specified object is equal to the current object. /// /// /// true if the specified object is equal to the current object; otherwise, false. /// /// The object to compare with the current object. 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((ImageCropData) obj); } /// /// Serves as the default hash function. /// /// /// A hash code for the current object. /// public override int GetHashCode() { unchecked { var hashCode = (Alias != null ? Alias.GetHashCode() : 0); hashCode = (hashCode*397) ^ Width; hashCode = (hashCode*397) ^ Height; hashCode = (hashCode*397) ^ (Coordinates != null ? Coordinates.GetHashCode() : 0); return hashCode; } } public static bool operator ==(ImageCropData left, ImageCropData right) { return Equals(left, right); } public static bool operator !=(ImageCropData left, ImageCropData right) { return !Equals(left, right); } } }