Exemplo n.º 1
0
            public override bool matches(Node node)
            {
                if (!base.matches(node))
                {
                    return(false);
                }
                ModelElementInstance modelElement = ModelUtil.getModelElement(new DomElementImpl((Element)node), model);

                return(type.IsAssignableFrom(modelElement.GetType()));
            }
Exemplo n.º 2
0
        /// <summary>
        /// Find the index of the type of a model element in a list of element types
        /// </summary>
        /// <param name="modelElement"> the model element which type is searched for </param>
        /// <param name="childElementTypes"> the list to search the type </param>
        /// <returns> the index of the model element type in the list or -1 if it is not found </returns>
        public static int getIndexOfElementType(ModelElementInstance modelElement, IList <ModelElementType> childElementTypes)
        {
            for (int index = 0; index < childElementTypes.Count; index++)
            {
                ModelElementType childElementType = childElementTypes[index];
                Type             instanceType     = childElementType.InstanceType;
                if (instanceType.IsAssignableFrom(modelElement.GetType()))
                {
                    return(index);
                }
            }
            ICollection <string> childElementTypeNames = new List <string>();

            foreach (ModelElementType childElementType in childElementTypes)
            {
                childElementTypeNames.Add(childElementType.TypeName);
            }
            throw new ModelException("New child is not a valid child element type: " + modelElement.ElementType.TypeName + "; valid types are: " + childElementTypeNames);
        }