protected override void PreParse()
        {
            ClearEFObject(_documentation);
            _documentation = null;

            base.PreParse();
        }
        protected override void OnChildDeleted(EFContainer efContainer)
        {
            if (efContainer is Documentation)
            {
                _documentation = null;
            }

            base.OnChildDeleted(efContainer);
        }
Example #3
0
        internal override void GetXLinqInsertPosition(EFElement child, out XNode insertAt, out bool insertBefore)
        {
            // If the child is a property, check its InsertPosition value.
            // If the value is not null, retrieve the insertAt and insertBefore values from the property.
            var childProperty = child as PropertyBase;

            if (childProperty != null &&
                childProperty.InsertPosition != null &&
                childProperty.InsertPosition.InsertAtProperty != null)
            {
                try
                {
                    Debug.Assert(
                        childProperty is Property || childProperty is NavigationProperty,
                        "Unexpected property type. Type name: " + childProperty.GetType().Name);

                    if (childProperty is Property ||
                        childProperty is NavigationProperty)
                    {
                        var insertAtProperty = childProperty.InsertPosition.InsertAtProperty;
                        Debug.Assert(
                            insertAtProperty is Property || insertAtProperty is NavigationProperty,
                            "Unexpected InsertAtProperty type. Type name: " + insertAtProperty.GetType().Name);

                        if (insertAtProperty is Property ||
                            insertAtProperty is NavigationProperty)
                        {
                            if ((insertAtProperty is Property && childProperty is NavigationProperty) ||
                                (insertAtProperty is NavigationProperty && childProperty is Property))
                            {
                                Debug.Fail(
                                    "The InsertAtProperty value is not valid. InsertAtProperty should have the same type as the Property that we try to insert");
                            }
                            else
                            {
                                // Check if the reference property (the property that will be the sibling of the to-be-created property) is one of the entity-type's property.
                                var parentOfInsertAtProperty = insertAtProperty.GetParentOfType(GetType()) as EntityType;
                                Debug.Assert(
                                    parentOfInsertAtProperty == this,
                                    "Expected sibling property's entityType: " + DisplayName + " , actual:" + parentOfInsertAtProperty
                                    == null
                                        ? "null"
                                        : parentOfInsertAtProperty.DisplayName);
                                if (parentOfInsertAtProperty == this)
                                {
                                    insertBefore = childProperty.InsertPosition.InsertBefore;
                                    insertAt     = childProperty.InsertPosition.InsertAtProperty.XElement;
                                    return;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    // Clear out the InsertPosition.
                    childProperty.InsertPosition = null;
                }
            }

            if (child is Key)
            {
                Documentation.GetInsertPositionForSiblingThatNeedsToBeAfterDocumentationElementButBeforeOtherElements(
                    this, out insertAt, out insertBefore);
            }
            else
            {
                base.GetXLinqInsertPosition(child, out insertAt, out insertBefore);
            }
        }
        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);
        }