Example #1
0
        protected override void DoParse(ICollection <XName> unprocessedElements)
        {
            // call base DoParse first
            base.DoParse(unprocessedElements);

            // now see if this has an attribute called "TypeName"
            if (GetAttributeValue(EntityTypeMapping.AttributeTypeName) != null)
            {
                if (_entityTypeMappings.Count == 0)
                {
                    // TypeName attribute and no EntityTypeMapping children.  Create a "ghost-node".
                    var etm = new EntityTypeMapping(this, XElement);
                    _entityTypeMappings.Add(etm);
                    etm.Parse(unprocessedElements);

                    // Add an error - we don't want to support this syntax in the designer.
                    var msg = String.Format(
                        CultureInfo.CurrentCulture, Resources.ModelParse_GhostNodeNotSupportedByDesigner,
                        EntityTypeMapping.AttributeTypeName, ElementName);
                    Artifact.AddParseErrorForObject(this, msg, ErrorCodes.ModelParse_GhostNodeNotSupportedByDesigner);
                }
                else
                {
                    // TypeName attribute and EntityTypeMapping children.  These are mutually exclusive.
                    var msg = String.Format(
                        CultureInfo.CurrentCulture, Resources.ModelParse_MutuallyExclusiveAttributeAndChildElement,
                        EntityTypeMapping.AttributeTypeName, EntityTypeMapping.ElementName);
                    Artifact.AddParseErrorForObject(this, msg, ErrorCodes.ModelParse_MutuallyExclusiveAttributeAndChildElement);
                }
            }
        }
Example #2
0
 internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem)
 {
     if (elem.Name.LocalName == CommandText.ElementName)
     {
         if (_commandText != null)
         {
             // multiple CommandText elements
             var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem.Name.LocalName);
             Artifact.AddParseErrorForObject(this, msg, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED);
         }
         else
         {
             _commandText = new CommandText(this, elem);
             _commandText.Parse(unprocessedElements);
         }
     }
     else if (elem.Name.LocalName == Parameter.ElementName)
     {
         var param = new Parameter(this, elem);
         param.Parse(unprocessedElements);
         _parameters.Add(param);
     }
     else
     {
         return(base.ParseSingleElement(unprocessedElements, elem));
     }
     return(true);
 }
Example #3
0
 internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem)
 {
     if (elem.Name.LocalName == AssociationEnd.ElementName)
     {
         var assocEnd = new AssociationEnd(this, elem);
         _ends.Add(assocEnd);
         assocEnd.Parse(unprocessedElements);
     }
     else if (elem.Name.LocalName == ReferentialConstraint.ElementName)
     {
         if (_referentialConstraint != null)
         {
             var msg = String.Format(
                 CultureInfo.CurrentCulture, Resources.TOO_MANY_REFERENTIAL_CONSTRAINTS_IN_ASSOCIATION, LocalName.Value);
             Artifact.AddParseErrorForObject(this, msg, ErrorCodes.TOO_MANY_REFERENTIAL_CONSTRAINTS_IN_ASSOCIATION);
         }
         else
         {
             _referentialConstraint = new ReferentialConstraint(this, elem);
             _referentialConstraint.Parse(unprocessedElements);
         }
     }
     else
     {
         return(base.ParseSingleElement(unprocessedElements, elem));
     }
     return(true);
 }
Example #4
0
        protected override void DoParse(ICollection <XName> unprocessedElements)
        {
            // call base's DoParse() first to process elements
            base.DoParse(unprocessedElements);

            // next see if we have a StoreEntitySet attribute
            if (GetAttributeValue(MappingFragment.AttributeStoreEntitySet) != null)
            {
                if (_fragments.Count == 0)
                {
                    // create a "ghost-node"
                    var frag = new MappingFragment(this, XElement);
                    _fragments.Add(frag);
                    frag.Parse(unprocessedElements);

                    // Add an error - we don't want to support this syntax in the designer.  This can be on an EntitySetMapping or an EntityTypeMapping node
                    var elementName = XElement.Name.LocalName;
                    var msg         = String.Format(
                        CultureInfo.CurrentCulture, Resources.ModelParse_GhostNodeNotSupportedByDesigner,
                        MappingFragment.AttributeStoreEntitySet, elementName);
                    Artifact.AddParseErrorForObject(this, msg, ErrorCodes.ModelParse_GhostNodeNotSupportedByDesigner);
                }
                else
                {
                    // TypeName attribute and EntityTypeMapping children.  These are mutually exclusive.
                    var msg = String.Format(
                        CultureInfo.CurrentCulture, Resources.ModelParse_MutuallyExclusiveAttributeAndChildElement,
                        MappingFragment.AttributeStoreEntitySet, MappingFragment.ElementName);
                    Artifact.AddParseErrorForObject(this, msg, ErrorCodes.ModelParse_MutuallyExclusiveAttributeAndChildElement);
                }
            }
        }
Example #5
0
        protected override void PostParse(ICollection <XName> unprocessedElements)
        {
            if (String.IsNullOrEmpty(GetAttributeValue(AttributeKey)))
            {
                Artifact.AddParseErrorForObject(
                    this, Resources.ModelParse_AliasElementMissingKeyAttribute, ErrorCodes.ModelParse_AliasElementMissingKeyAttribute);
            }

            if (String.IsNullOrEmpty(GetAttributeValue(AttributeValue)))
            {
                Artifact.AddParseErrorForObject(
                    this, Resources.ModelParse_AliasElementMissingValueAttribute, ErrorCodes.ModelParse_AliasElementMissingValueAttribute);
            }

            base.PostParse(unprocessedElements);
        }
 internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem)
 {
     // Conceptual EntityModel needs to create Conceptual EntityContainer objects
     if (elem.Name.LocalName == BaseEntityContainer.ElementName)
     {
         if (_entityContainers.Count > 0)
         {
             // multiple EntityContainers detected, report an error
             var msg   = String.Format(CultureInfo.CurrentCulture, Resources.TOO_MANY_ENTITY_CONTAINER_ELEMENTS, Namespace.Value);
             var error = new ErrorInfo(
                 ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.TOO_MANY_ENTITY_CONTAINER_ELEMENTS, ErrorClass.ParseError);
             Artifact.AddParseErrorForObject(this, error);
         }
         var ec = new ConceptualEntityContainer(this, elem);
         _entityContainers.Add(ec);
         ec.Parse(unprocessedElements);
     }
     else if (elem.Name.LocalName == ComplexType.ElementName)
     {
         var complexType = new ComplexType(this, elem);
         _complexTypes.Add(complexType);
         complexType.Parse(unprocessedElements);
     }
     else if (elem.Name.LocalName == UsingElement.ElementName)
     {
         var use = new UsingElement(this, elem);
         _usings.Add(use);
         use.Parse(unprocessedElements);
     }
     else if (elem.Name.LocalName == EnumType.ElementName)
     {
         // Check if enumType that represents the XElement <see DoParse method>
         var enumType = ModelItemAnnotation.GetModelItem(elem) as EnumType;
         if (enumType == null ||
             enumType.IsDisposed)
         {
             enumType = new EnumType(this, elem);
             _enumTypes.Add(enumType);
             enumType.Parse(unprocessedElements);
         }
     }
     else
     {
         return(base.ParseSingleElement(unprocessedElements, elem));
     }
     return(true);
 }
Example #7
0
        internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement element)
        {
            if (element.Name.LocalName == Documentation.ElementName)
            {
                if (_documentation != null)
                {
                    // multiple Documentation elements
                    Artifact.AddParseErrorForObject(
                        this, Resources.TOO_MANY_DOCUMENTATION_ELEMENTS, ErrorCodes.TOO_MANY_DOCUMENTATION_ELEMENTS);
                }
                else
                {
                    _documentation = new Documentation(this, element);
                    _documentation.Parse(unprocessedElements);
                }

                return(true);
            }

            return(base.ParseSingleElement(unprocessedElements, element));
        }
Example #8
0
 internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem)
 {
     if (elem.Name.LocalName == Key.ElementName)
     {
         if (_key != null)
         {
             // multiple key elements
             Artifact.AddParseErrorForObject(this, Resources.TOO_MANY_KEY_ELEMENTS, ErrorCodes.TOO_MANY_KEY_ELEMENTS);
         }
         else
         {
             _key = new Key(this, elem);
             _key.Parse(unprocessedElements);
         }
     }
     else
     {
         return(base.ParseSingleElement(unprocessedElements, elem));
     }
     return(true);
 }
Example #9
0
 internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem)
 {
     if (elem.Name.LocalName == DefiningQuery.ElementName)
     {
         if (_definingQuery != null)
         {
             // multiple DefiningQuery elements
             var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem.Name.LocalName);
             Artifact.AddParseErrorForObject(this, msg, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED);
         }
         else
         {
             _definingQuery = new DefiningQuery(this, elem);
             _definingQuery.Parse(unprocessedElements);
         }
     }
     else
     {
         return(base.ParseSingleElement(unprocessedElements, elem));
     }
     return(true);
 }