public override int GetHashCode() { unchecked { int result = base.GetHashCode(); result = (result * 397) ^ (TopLevelMediaType != null ? TopLevelMediaType.GetHashCode() : 0); result = (result * 397) ^ (Subtype != null ? Subtype.GetHashCode() : 0); foreach (string parameterName in Parameters.Keys) { result = (result * 397) ^ (parameterName + Parameters[parameterName]).GetHashCode(); } return(result); } }
public int CompareTo(MediaType other) { if (other == null) { return(MOVE_UP); } if (Equals(other)) { return(0); } // first, always move down */* if (IsWildCard) { if (other.IsWildCard) { return(0); } return(MOVE_DOWN); } // then sort by quality if (Quality != other.Quality) { return(Quality > other.Quality ? MOVE_UP : MOVE_DOWN); } // then, if the quality is the same, always move application/xml at the end if (MediaType == "application/xml") { return(MOVE_DOWN); } if (other.MediaType == "application/xml") { return(MOVE_UP); } if (TopLevelMediaType != other.TopLevelMediaType) { if (IsTopLevelWildcard) { return(MOVE_DOWN); } if (other.IsTopLevelWildcard) { return(MOVE_UP); } return(TopLevelMediaType.CompareTo(other.TopLevelMediaType)); } if (Subtype != other.Subtype) { if (IsSubtypeWildcard) { return(MOVE_DOWN); } if (other.IsSubtypeWildcard) { return(MOVE_UP); } return(Subtype.CompareTo(other.Subtype)); } return(0); }