/// <summary>
        /// The method that is called when an End element is encountered.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the EndElement.</param>
        private void HandleEndElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd(this);

            end.Parse(reader);

            if (end.Role == null)
            {
                // we will resolve the role name later and put it in the
                // normal _relationshipEnds dictionary
                _rolelessEnds.Add(end);
                return;
            }

            if (HasEnd(end.Role))
            {
                end.AddError(ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, reader,
                             System.Data.Entity.Strings.DuplicateEndName(end.Name));
                return;
            }

            _relationshipEnds.Add(end.Role, end);
        }
Beispiel #2
0
        internal override SchemaElement Clone(SchemaElement parentElement)
        {
            EntityContainerAssociationSetEnd setEnd = new EntityContainerAssociationSetEnd((EntityContainerAssociationSet)parentElement);

            setEnd._unresolvedRelationshipEndRole = _unresolvedRelationshipEndRole;
            setEnd.EntitySet = this.EntitySet;

            return(setEnd);
        }
        internal override SchemaElement Clone(SchemaElement parentElement)
        {
            EntityContainerAssociationSet associationSet = new EntityContainerAssociationSet((EntityContainer)parentElement);

            associationSet.Name         = this.Name;
            associationSet.Relationship = this.Relationship;

            foreach (EntityContainerAssociationSetEnd end in this.Ends)
            {
                EntityContainerAssociationSetEnd clonedEnd = (EntityContainerAssociationSetEnd)end.Clone(associationSet);
                associationSet._relationshipEnds.Add(clonedEnd.Role, clonedEnd);
            }

            return(associationSet);
        }
        /// <summary>
        /// Create and add a EntityContainerEnd from the IRelationshipEnd provided
        /// </summary>
        /// <param name="relationshipEnd">The relationship end of the end to add.</param>
        /// <param name="entitySet">The entitySet to associate with the relationship end.</param>
        protected override void AddEnd(IRelationshipEnd relationshipEnd, EntityContainerEntitySet entitySet)
        {
            Debug.Assert(relationshipEnd != null);
            Debug.Assert(!_relationshipEnds.ContainsKey(relationshipEnd.Name));
            // we expect set to be null sometimes

            EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd(this);

            end.Role            = relationshipEnd.Name;
            end.RelationshipEnd = relationshipEnd;

            end.EntitySet = entitySet;
            if (end.EntitySet != null)
            {
                _relationshipEnds.Add(end.Role, end);
            }
        }
        /// <summary>
        /// The method that is called when an End element is encountered.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the EndElement.</param>
        private void HandleEndElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            var end = new EntityContainerAssociationSetEnd(this);
            end.Parse(reader);

            if (end.Role == null)
            {
                // we will resolve the role name later and put it in the 
                // normal _relationshipEnds dictionary
                _rolelessEnds.Add(end);
                return;
            }

            if (HasEnd(end.Role))
            {
                end.AddError(
                    ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, reader,
                    Strings.DuplicateEndName(end.Name));
                return;
            }

            _relationshipEnds.Add(end.Role, end);
        }
        /// <summary>
        /// Create and add a EntityContainerEnd from the IRelationshipEnd provided
        /// </summary>
        /// <param name="relationshipEnd">The relationship end of the end to add.</param>
        /// <param name="entitySet">The entitySet to associate with the relationship end.</param>
        protected override void AddEnd(IRelationshipEnd relationshipEnd, EntityContainerEntitySet entitySet)
        {
            Debug.Assert(relationshipEnd != null);
            Debug.Assert(!_relationshipEnds.ContainsKey(relationshipEnd.Name));
            // we expect set to be null sometimes

            var end = new EntityContainerAssociationSetEnd(this);
            end.Role = relationshipEnd.Name;
            end.RelationshipEnd = relationshipEnd;

            end.EntitySet = entitySet;
            if (end.EntitySet != null)
            {
                _relationshipEnds.Add(end.Role, end);
            }
        }
        internal override SchemaElement Clone(SchemaElement parentElement)
        {
            EntityContainerAssociationSetEnd setEnd = new EntityContainerAssociationSetEnd((EntityContainerAssociationSet)parentElement);
            setEnd._unresolvedRelationshipEndRole = _unresolvedRelationshipEndRole;
            setEnd.EntitySet = this.EntitySet;

            return setEnd;
        }