private static void AddConstraintToDic(SemanticConstraint constraint, int key, Dictionary <int, List <SemanticConstraint> > dic) { if (key < 0) { return; } List <SemanticConstraint> list; if (dic.ContainsKey(key)) { list = dic[key]; } else { list = new List <SemanticConstraint>(); dic.Add(key, list); } // Let's check if the constraint obj is already added to the list. if (!list.Contains(constraint)) { list.Add(constraint); } }
private static void AddConstraintToDic(SemanticConstraint constraint, int key, Dictionary<int, List<SemanticConstraint>> dic) { if (key < 0) { return; } List<SemanticConstraint> list; if (dic.ContainsKey(key)) { list = dic[key]; } else { list = new List<SemanticConstraint>(); dic.Add(key, list); } // Let's check if the constraint obj is already added to the list. if (!list.Contains(constraint)) { list.Add(constraint); } }
/// <summary> /// Register a constraint to this registry. /// </summary> public void RegisterConstraint(int elementTypeID, int ancestorTypeID, FileFormatVersions fileFormat, ApplicationType appType, SemanticConstraint constraint ) { if ((fileFormat & _format) == _format && (appType & _appType) == _appType) { AddConstraintToDic(constraint, ancestorTypeID, _cleanList); AddConstraintToDic(constraint, elementTypeID, _semConstraintMap); } }
/// <summary> /// Register a constraint to this registry. /// </summary> public void RegisterConstraint(int elementTypeID, int ancestorTypeID, FileFormatVersions fileFormat, ApplicationType appType, SemanticConstraint constraint) { if ((fileFormat & _format) == _format && (appType & _appType) == _appType) { AddConstraintToDic(constraint, ancestorTypeID, _cleanList); AddConstraintToDic(constraint, elementTypeID, _semConstraintMap); } }