Exemplo n.º 1
0
        /// <summary>
        /// Returns true if HalLink instances are equal
        /// </summary>
        /// <param name="other">Instance of HalLink to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(HalLink other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Href == other.Href ||
                     Href != null &&
                     Href.Equals(other.Href)
                     ) &&
                 (
                     Templated == other.Templated ||

                     Templated.Equals(other.Templated)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Deprecation == other.Deprecation ||
                     Deprecation != null &&
                     Deprecation.Equals(other.Deprecation)
                 ) &&
                 (
                     Profile == other.Profile ||
                     Profile != null &&
                     Profile.Equals(other.Profile)
                 ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     Hreflang == other.Hreflang ||
                     Hreflang != null &&
                     Hreflang.Equals(other.Hreflang)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ));
        }
Exemplo n.º 2
0
 // To reduce code duplication, a new link defined for one resource type can be applied
 // to another resource type.  This is common with resource view models.  The view model
 // represents the same resource but a different view of the information.
 internal virtual void CopyTo <TNewResourceType>(ActionLink actionLink)
     where TNewResourceType : class, IResource
 {
     actionLink.RelationName = RelationName;
     actionLink.Href         = Href;
     actionLink.HrefLang     = HrefLang;
     actionLink.Methods      = Methods;
     actionLink.Name         = Name;
     actionLink.Title        = Title;
     actionLink.Type         = Type;
     actionLink.Deprecation  = Deprecation?.CreateCopyFor <TNewResourceType>();
     actionLink.Profile      = Profile?.CreateCopyFor <TNewResourceType>();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Href != null)
                {
                    hashCode = hashCode * 59 + Href.GetHashCode();
                }

                hashCode = hashCode * 59 + Templated.GetHashCode();
                if (Type != null)
                {
                    hashCode = hashCode * 59 + Type.GetHashCode();
                }
                if (Deprecation != null)
                {
                    hashCode = hashCode * 59 + Deprecation.GetHashCode();
                }
                if (Profile != null)
                {
                    hashCode = hashCode * 59 + Profile.GetHashCode();
                }
                if (Title != null)
                {
                    hashCode = hashCode * 59 + Title.GetHashCode();
                }
                if (Hreflang != null)
                {
                    hashCode = hashCode * 59 + Hreflang.GetHashCode();
                }
                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }
                return(hashCode);
            }
        }