예제 #1
0
        public virtual IModelElementInstance GetModelElementById(string id)
        {
            if (id == null)
            {
                return(null);
            }
            IDomElement element = document.GetElementById(id);

            if (element != null)
            {
                return(ModelUtil.GetModelElement(element, this));
            }
            return(null);
        }
        protected internal virtual IList <IDomElement> GetView(ModelElementInstanceImpl referenceSourceParentElement)
        {
            IDomDocument          document = referenceSourceParentElement.ModelInstance.Document;
            ICollection <TSource> referenceSourceElements = _referenceSourceCollection.Get <TSource>(referenceSourceParentElement);
            IList <IDomElement>   referenceTargetElements = new List <IDomElement>();

            foreach (TSource referenceSourceElement in referenceSourceElements)
            {
                string identifier = GetReferenceIdentifier(referenceSourceElement);

                IDomElement referenceTargetElement = document.GetElementById(identifier);
                if (referenceTargetElement != null)
                {
                    referenceTargetElements.Add(referenceTargetElement);
                }
                else
                {
                    throw new ModelException("Unable to find a model element instance for id " + identifier);
                }
            }
            return(referenceTargetElements);
        }
        private ICollection <IDomElement> GetView(IModelElementInstance referenceSourceElement)
        {
            IDomDocument document = referenceSourceElement.ModelInstance.Document;

            string         identifier = GetReferenceIdentifier(referenceSourceElement);
            IList <string> references = StringUtil.SplitListBySeparator(identifier, Separator);

            ICollection <IDomElement> referenceTargetElements = new List <IDomElement>();

            foreach (string reference in references)
            {
                //TODO document.getElementById可能获取不到值
                IDomElement referenceTargetElement = document.GetElementById(reference);
                if (referenceTargetElement != null)
                {
                    referenceTargetElements.Add(referenceTargetElement);
                }
                else
                {
                    throw new ModelException("Unable to find a model element instance for id " + identifier);
                }
            }
            return(referenceTargetElements);
        }