コード例 #1
0
        //	private void getAllInvariants(Map allInvariants) {
        //		InvariantsCollector collector = new InvariantsCollector(this.getJmiClassifier(), allInvariants);
        //		collector.traverseAllAncestors();
        //	}
        public CoreModelElement addDefinedElement(
            string source,
            string name,
            CoreClassifier type)
        {
            List <object> allSubClasses = classifier.getAllSubClasses();

            foreach (CoreClassifier subClass in allSubClasses)
            {
                Environment env = subClass.getEnvironmentWithoutParents();

                if (env.lookup(name) != null)
                {
                    string errorMessage = "<{0}> already defined in a derived classifier";
                    throw new NameClashException(string.Format(errorMessage, new object[] { name }));
                }
            }

            CoreFeature element = createOclDefinedAttribute(source, name, type);

            element.setFeatureOwner(classifier);
            element.setElemOwner(classifier);

            this.definedFeatures.Add(name, element);
            addElementToDefinedFeaturesBySource(source, element);

            return(element);
        }