public static int GetPriority(this ConditionMatch matchType) { switch (matchType) { case ConditionMatch.Exact: return(6); case ConditionMatch.GeneralMatchMetadataId: return(5); case ConditionMatch.GeneralMatchModule: return(4); case ConditionMatch.GeneralMatchAll: return(3); case ConditionMatch.GeneralMatchProfile: return(2); case ConditionMatch.GeneralMatch: return(1); case ConditionMatch.No: return(0); } return(0); }
public ConditionMatchResult Append(ConditionMatch value) { _matchType = _matchType.And(value); if (ConditionMatch.Exact.Equals(value)) { NumberOfExacts++; } return(this); }
public ConditionMatchResult Append(String conditionString, String contextString) { var value = Calculate(conditionString, contextString); _matchType = _matchType.And(value); if (ConditionMatch.Exact.Equals(value)) { NumberOfExacts++; } return(this); }
public ConditionMatchResult AppendProfile(int?storedProfile, ICollection <int?> userProfiles) { if (storedProfile == null) { return(this); } if (userProfiles == null) { _matchType = _matchType.And(ConditionMatch.No); } else { var profileMatch = userProfiles.Contains(storedProfile) ? ConditionMatch.Exact : ConditionMatch.No; _matchType = _matchType.And(profileMatch); if (ConditionMatch.Exact.Equals(profileMatch)) { NumberOfExacts++; ProfileAsked = _profile != null; } } return(this); }
public ConditionMatchResult AppendModule(String conditionString, String contextString) { var value = Calculate(conditionString, contextString); if (value == ConditionMatch.GeneralMatch && contextString != null) { //if a module was asked it should be matched no option to general match here value = ConditionMatch.No; } _matchType = _matchType.And(value); if (ConditionMatch.Exact.Equals(value)) { NumberOfExacts++; ModuleAsked = _module != null; } if (ConditionMatch.GeneralMatchAll.Equals(value)) { //TODO:review ModuleAsked = _module != null; } return(this); }
public static ConditionMatch And(this ConditionMatch condition, ConditionMatch other) { //keep lowest priority as we do and ==> once "NO" or "GENERAL", no chance to go up to Exact for instance. //However, we could go down, like from instance from General to NO return(other.GetPriority() < condition.GetPriority() ? other : condition); }