protected MatchEnum(MatchEnum copy) : base(copy) { Ordinal = copy.Ordinal; Ordinal2 = copy.Ordinal2; Values = copy.Values; }
public bool Subsets(Match match) { if (Priority != match.Priority) { return(false); } MatchEnum that = match as MatchEnum; return(Ordinal >= that.Ordinal && Ordinal2 <= that.Ordinal2); }
// Overriden due to more restrictive conditions. public override bool CanMerge(Match match) { if (!base.CanMerge(match)) { return(false); } MatchEnum that = match as MatchEnum; // This match subsets, is subsetted by, or complements match. return(Subsets(that) || that.Subsets(this) || Complements(that)); }
public bool Complements(Match match) { // The different priorities cannot complement each other (e.g. "Quality" cannot complement "ItemLevel" and vice versa). if (Priority != match.Priority) { return(false); } MatchEnum that = match as MatchEnum; // Complements from left or right. // XXX: Don't have to take operator into account at all, due to conversion of all operators into Between ranges in constructor. return(Ordinal2 + 1 == that.Ordinal || Ordinal == that.Ordinal2 + 1); }
public void Merge(Match match) { MatchEnum that = match as MatchEnum; if (Complements(that)) { // Complements from left. if (Ordinal2 + 1 == that.Ordinal) { Ordinal2 = that.Ordinal2; } else // Ordinal == that.Ordinal2 + 1 { Ordinal = that.Ordinal; } } else // If we subset the match. if (Subsets(that)) { Ordinal = that.Ordinal; Ordinal2 = that.Ordinal2; } // Otherwise match subsets us, nothing to do. }