public override int GetHashCode()
 {
     if (string.IsNullOrWhiteSpace(RouteId))
     {
         return(0);
     }
     return(RouteId.GetHashCode());
 }
示例#2
0
        // Used to diff for config changes
        internal int GetConfigHash()
        {
            var hash = 0;

            if (!string.IsNullOrEmpty(RouteId))
            {
                hash ^= RouteId.GetHashCode();
            }

            if (Methods != null && Methods.Count > 0)
            {
                // Assumes un-ordered
                hash ^= Methods.Select(item => item.GetHashCode())
                        .Aggregate((total, nextCode) => total ^ nextCode);
            }

            if (!string.IsNullOrEmpty(Host))
            {
                hash ^= Host.GetHashCode();
            }

            if (!string.IsNullOrEmpty(Path))
            {
                hash ^= Path.GetHashCode();
            }

            if (Priority.HasValue)
            {
                hash ^= Priority.GetHashCode();
            }

            if (!string.IsNullOrEmpty(ClusterId))
            {
                hash ^= ClusterId.GetHashCode();
            }

            if (!string.IsNullOrEmpty(AuthorizationPolicy))
            {
                hash ^= AuthorizationPolicy.GetHashCode();
            }

            if (Metadata != null)
            {
                hash ^= Metadata.Select(item => HashCode.Combine(item.Key.GetHashCode(), item.Value.GetHashCode()))
                        .Aggregate((total, nextCode) => total ^ nextCode);
            }

            if (Transforms != null)
            {
                hash ^= Transforms.Select(transform =>
                                          transform.Select(item => HashCode.Combine(item.Key.GetHashCode(), item.Value.GetHashCode()))
                                          .Aggregate((total, nextCode) => total ^ nextCode)) // Unordered Dictionary
                        .Aggregate(seed: 397, (total, nextCode) => total * 31 ^ nextCode);   // Ordered List
            }

            return(hash);
        }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (RouteId != null ? RouteId.GetHashCode() : 0);
         result = (result * 397) ^ (RegionId != null ? RegionId.GetHashCode() : 0);
         result = (result * 397) ^ RouteDate.GetHashCode();
         return(result);
     }
 }
        public override int GetHashCode()
        {
            var hashCode = AgencyId.GetHashCode();

            hashCode = (hashCode * 397) ^ RouteId.GetHashCode();
            hashCode = (hashCode * 397) ^ RouteType.GetHashCode();
            hashCode = (hashCode * 397) ^ TripId.GetHashCode();
            hashCode = (hashCode * 397) ^ StopId.GetHashCode();

            return(hashCode);
        }