// Constraints public bool MergeOrAddConstraint(CM1Group pGrp, long lCnstrDef, float fValue) { trace?.Write(TraceLevel.Debug, "CM1GroupsTree::MergeOrAddConstraint"); bool fnResult = true; try { if (pGrp == null) { throw new ArgumentNullException(nameof(pGrp), "pGrp is NULL"); } // TODO: Best control // If MergeConstraint fails I suppose that previosly this type of constraint // was not set ... so I add it. float?result = null; if (!pGrp.MergeConstraint(lCnstrDef, fValue, ref result)) { if (pGrp.AddConstraint(lCnstrDef, fValue)) { CM1Node pNode = GetFirstNodeFromIds(pGrp.GetGrpId()); if (pNode != null) { pNode.CnstrNum++; } } else { fnResult = false; } } } catch (Exception error) { trace?.Write(TraceLevel.Error, error.ToLogString()); fnResult = false; } return(fnResult); }