private void ModifyWeightsByElement(IDsmElement element, ModifyWeight modifyWeight) { foreach (DsmRelation relation in _relationsById.Values) { if ((element.Id == relation.ConsumerId) || (element.Id == relation.ProviderId)) { UpdateWeights(relation, modifyWeight); } } foreach (IDsmElement child in element.Children) { ModifyWeightsByElement(child, modifyWeight); } }
private void UpdateWeights(IDsmRelation relation, ModifyWeight modifyWeight) { int consumerId = relation.ConsumerId; int providerId = relation.ProviderId; IDsmElement currentConsumer = _elementsDataModel.FindElementById(consumerId); while (currentConsumer != null) { IDsmElement currentProvider = _elementsDataModel.FindElementById(providerId); while (currentProvider != null) { modifyWeight(currentConsumer.Id, currentProvider.Id, relation.Weight); currentProvider = currentProvider.Parent; } currentConsumer = currentConsumer.Parent; } }