Ejemplo n.º 1
0
        internal override bool ReparseSingleElement(ICollection <XName> unprocessedElements, XElement element)
        {
            if (element.Name.LocalName == BaseEntityModel.ElementName ||
                element.Name.LocalName == MappingModel.ElementName)
            {
                // Update Model sometimes just replaces the Schema elements; if we undo this, we'll have to
                // parse a new Schema element, so find the entity model that contains it and parse it

                var entityModelXObj = element.Parent;
                Debug.Assert(
                    entityModelXObj != null &&
                    (entityModelXObj.Name.LocalName == "ConceptualModels" || entityModelXObj.Name.LocalName == "StorageModels" ||
                     entityModelXObj.Name.LocalName == "Mappings"),
                    "How could a Schema element be added underneath a parent that is not a ConceptualModel, StorageModel, or Mapping?");

                var conceptualModelsProcessed = false;
                var storageModelsProcessed    = false;
                var mappingsProcessed         = false;

                ParseSingleEntityModelElement(
                    entityModelXObj, ref conceptualModelsProcessed, ref storageModelsProcessed, ref mappingsProcessed);

                if (conceptualModelsProcessed)
                {
                    Debug.Assert(ConceptualModel != null, "If the conceptual model root was created, why isn't it in this artifact?");
                    ConceptualModel.Parse(new List <XName>());
                }
                else if (storageModelsProcessed)
                {
                    Debug.Assert(StorageModel != null, "If the storage model root was created, why isn't it in this artifact?");
                    StorageModel.Parse(new List <XName>());
                }
                else if (mappingsProcessed)
                {
                    Debug.Assert(MappingModel != null, "If the mappings root was created, why isn't it in this artifact?");
                    MappingModel.Parse(new List <XName>());
                }
                return(true);
            }
            else
            {
                return(base.ReparseSingleElement(unprocessedElements, element));
            }
        }