private void AddLink(IAssociation roleName, ObjectPlusPlus targetObject, object qualifier, int counter) { Dictionary <object, ObjectPlusPlus> objectLinks; if (roleName.VerifyInstance(this, targetObject) == false) { throw new Exception("obiekty nie pasuja do podanej asocjacji."); } if (counter < 1) { return; } if (targetObject.ContainsRole(roleName.GetOposite())) { if (roleName.GetOposite().GetMaxCardinality() != 0 && counter == 2 && !(targetObject.RoleSize(roleName.GetOposite()) < roleName.GetOposite().GetMaxCardinality())) { throw new Exception($"Maksymalna licznosc w {roleName.Class2.Name} osiagnieta i ma juz powiazane maksymalne: {targetObject.RoleSize(roleName.GetOposite())} obiektow typu {GetType().Name}."); } } if (Links.ContainsKey(roleName)) { objectLinks = Links[roleName]; if (roleName.GetMaxCardinality() != 0 && !(objectLinks.Count < roleName.GetMaxCardinality())) { throw new Exception($"Maksymalna licznosc w {GetType().Name} osiagnieta i juz powiazane maksymalne: {RoleSize(roleName)} obiektow typu {roleName.Class2.Name}."); } } else { objectLinks = new Dictionary <object, ObjectPlusPlus>(); Links.Add(roleName, objectLinks); } if (objectLinks.ContainsKey(qualifier) == false) { objectLinks.Add(qualifier, targetObject); targetObject.AddLink(roleName.GetOposite(), this, this, counter - 1); } }
private void RemoveLink(IAssociation roleName, ObjectPlusPlus targetObject, object qualifier, int counter) { if (counter < 1) { return; } Dictionary <object, ObjectPlusPlus> objectLinks; if (Links.ContainsKey(roleName) == false) { throw new Exception("Brak powiazan z rola: " + roleName); } objectLinks = Links[roleName]; if (objectLinks.ContainsKey(qualifier)) { objectLinks.Remove(qualifier); targetObject.RemoveLink(roleName.GetOposite(), this, this, counter - 1); } objectLinks.Remove(targetObject); targetObject.RemoveLink(roleName.GetOposite(), this, qualifier, counter - 1); }
public void AddLink(IAssociation roleName, ObjectPlusPlus targetObject) { AddLink(roleName, targetObject, targetObject); }
public void AddLink(IAssociation roleName, ObjectPlusPlus targetObject, object qualifier) { AddLink(roleName, targetObject, qualifier, 2); }
public void RemovePart(IAssociation roleName, ObjectPlusPlus targetObject) { targetObject.RemoveObject(); AllParts.Remove(targetObject); }
public void RemoveLink(IAssociation roleName, ObjectPlusPlus targetObject) { RemoveLink(roleName, targetObject, targetObject, 2); }