private int deleteAllDefinedElements(string sourceName) { List <object> namesToBeRemovedFromEnvironment = new List <object>(); int result = 0; List <CoreFeature> elementsToBeRemoved; this.definedFeaturesBySource.TryGetValue(sourceName, out elementsToBeRemoved); if (elementsToBeRemoved != null) { foreach (CoreFeature modelElement in elementsToBeRemoved) { if (modelElement is CoreAttributeImpl) { CoreAttribute attr = (CoreAttribute)modelElement; namesToBeRemovedFromEnvironment.Add(attr.getName()); } else { CoreOperation oper = (CoreOperation)modelElement; namesToBeRemovedFromEnvironment.Add( CoreModelElementNameGeneratorImpl.getInstance().generateNameForOperation(oper.getName(), new List <object>(oper.getParametersTypesExceptReturn()))); } } result = elementsToBeRemoved.Count; foreach (string element in namesToBeRemovedFromEnvironment) { CoreFeature coreFeature; bool foudbefore = this.definedFeatures.TryGetValue(element, out coreFeature); this.definedFeatures.Remove(element); bool foundafter = this.definedFeatures.TryGetValue(element, out coreFeature); } if (this.definedFeaturesBySource.ContainsKey(sourceName)) { this.definedFeaturesBySource[sourceName] = new List <CoreFeature>(); } else { this.definedFeaturesBySource.Add(sourceName, new List <CoreFeature>()); } } return(result); }
public OclConstraint createAttributeDeriveConstraint(string source, CoreClassifier contextualClassifier, CoreAttribute attribute, ExpressionInOcl initialValue) { OclAttributeDeriveConstraint constraint = new OclAttributeDeriveConstraintImpl(); constraint.setSource(source); constraint.setContextualClassifier(contextualClassifier); constraint.setDerivedAttribute(attribute); constraint.setExpression(initialValue); contextualClassifier.addDeriveConstraint(attribute.getName(), constraint); attribute.setDerivedValueExpression(initialValue); // cachedObjects.add(constraint); return(constraint); }