protected override void OnChildDeleted(EFContainer efContainer)
        {
            var child2 = efContainer as DesignerInfo;

            if (child2 != null)
            {
                var infoEnum = _designerInfos.GetEnumerator();
                while (infoEnum.MoveNext())
                {
                    if (infoEnum.Current.Value == child2)
                    {
                        _designerInfos.Remove(infoEnum.Current.Key);
                        break;
                    }
                }
                return;
            }

            if (efContainer.Equals(_diagrams))
            {
                _diagrams = null;
            }

            base.OnChildDeleted(efContainer);
        }
 protected override void OnChildDeleted(EFContainer efContainer)
 {
     if (efContainer == _designerInfoRoot)
     {
         _designerInfoRoot = null;
     }
 }
Esempio n. 3
0
        internal static bool IsUniqueNameInsideContainer(
            EFContainer container, string proposedName, bool uniquenessIsCaseSensitive, HashSet <EFObject> childEFObjectsToIgnore = null)
        {
            if (string.IsNullOrEmpty(proposedName)
                ||
                container == null)
            {
                return(false);
            }

            var isUniqueName = true;

            var comparisonType =
                uniquenessIsCaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

            foreach (var child in container.Children)
            {
                var nameableChild = child as EFNameableItem;
                if (nameableChild != null
                    &&
                    (childEFObjectsToIgnore != null ? !childEFObjectsToIgnore.Contains(nameableChild) : true))
                {
                    if (nameableChild.LocalName.Value.Equals(proposedName, comparisonType))
                    {
                        isUniqueName = false;
                        break;
                    }
                }
            }

            return(isUniqueName);
        }
Esempio n. 4
0
        private static EFNameableItem FindNameableItemViaIdentifierInternal(EFContainer currentContainer, Queue <string> nameQueue)
        {
            if (currentContainer != null)
            {
                var namePart = nameQueue.Dequeue();
                foreach (var childObject in currentContainer.Children.OfType <EFObject>())
                {
                    var nameableItem       = childObject as EFNameableItem;
                    var itemBinding        = childObject as ItemBinding;
                    var foundNamePartMatch = false;

                    // first examine the name. We can use the name as the type or the actual name.
                    if (namePart.StartsWith("*", StringComparison.Ordinal) &&
                        namePart.EndsWith("*", StringComparison.Ordinal))
                    {
                        var trimmedNamePart = namePart.Trim('*');
                        if (itemBinding != null &&
                            itemBinding.ResolvedTargets.FirstOrDefault() != null
                            &&
                            itemBinding.ResolvedTargets.FirstOrDefault().GetType().Name == trimmedNamePart)
                        {
                            foundNamePartMatch = true;
                            nameableItem       = itemBinding.ResolvedTargets.FirstOrDefault() as EFNameableItem;
                        }
                    }
                    else if (nameableItem != null &&
                             nameableItem.LocalName.Value.Equals(namePart, StringComparison.CurrentCulture))
                    {
                        foundNamePartMatch = true;
                    }

                    // if we have found a match, either recurse if there are more names or return this one.
                    if (foundNamePartMatch)
                    {
                        if (nameQueue.Count > 0)
                        {
                            return(FindNameableItemViaIdentifierInternal(nameableItem, nameQueue));
                        }
                        else
                        {
                            return(nameableItem);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 5
0
        internal static void NormalizeAndResolve(EFContainer efContainer)
        {
            if (efContainer == null)
            {
                return;
            }

            // revert this item and its children to the Parsed State, if we don't do this
            // then they will be skipped by the other visitors. Also Unbind so resolving will
            // rebind any references.
            var stateChangingVisitor = new StateChangingVisitor(EFElementState.Parsed);

            stateChangingVisitor.Traverse(efContainer);
            var unbindingVisitor = new UnbindingVisitor();

            unbindingVisitor.Traverse(efContainer);

            ModelManager.NormalizeItem(efContainer);
            efContainer.Artifact.ModelManager.ResolveItem(efContainer);
        }
        protected override void OnChildDeleted(EFContainer efContainer)
        {
            if (efContainer == _designerInfoRoot)
            {
                _designerInfoRoot = null;
            }
            else if (efContainer == _mappingModel)
            {
                _mappingModel = null;
            }
            else if (efContainer == _conceptualEntityModel)
            {
                _conceptualEntityModel = null;
            }
            else if (efContainer == _storageEntityModel)
            {
                _storageEntityModel = null;
            }

            base.OnChildDeleted(efContainer);
        }
Esempio n. 7
0
        /// <summary>
        ///     Asks the passed in item all of its children to create its normalized name
        ///     and load that into the global symbol table.
        /// </summary>
        internal static void NormalizeItem(EFContainer item)
        {
            var visitor = new NormalizingVisitor();

            var lastMissedCount = -1;

            while (visitor.MissedCount != 0)
            {
                visitor.ResetMissedCount();
                visitor.Traverse(item);

                // every item should be able to normalize
                if (lastMissedCount == visitor.MissedCount)
                {
                    // subsequent passes didn't normalize any new items
                    throw new InvalidDataException();
                }

                lastMissedCount = visitor.MissedCount;
            }
        }
Esempio n. 8
0
        protected EFObject(EFContainer parent, XObject xobject)
        {
            // note that it is OK if parent is null here; derived classes should assert
            // in their own constructor if they want to ensure that parent is not null
            _parent = parent;

            if (xobject == null)
            {
                // Incase parent is null, elements will be created without any namespace
                // the implementation of AddToXLinq will add the model item annotation.
                AddToXlinq();
            }
            else
            {
                _xobject = xobject;
                ModelItemAnnotation.SetModelItem(_xobject, this);
            }

            Debug.Assert(_xobject == null || ModelItemAnnotation.GetModelItem(_xobject) != null, "xobject didn't have a model annotation!");

            SetState(IS_CONSTRUCTION_COMPLETED);
        }
Esempio n. 9
0
        /// <summary>
        ///     Asks the passed in item and all its children to resolve references to other
        ///     EFElements across the entire model, i.e., a ScalarProperty will link up to its
        ///     entity and storage properties.
        /// </summary>
        internal void ResolveItem(EFContainer item)
        {
            lock (this)
            {
                var visitor = new ResolvingVisitor(item.Artifact.ArtifactSet);

                var lastMissedCount = visitor.MissedCount;

                while (visitor.MissedCount != 0)
                {
                    visitor.ResetMissedCount();
                    visitor.Traverse(item);

                    // if we can't resolve any more then we are done
                    if (lastMissedCount == visitor.MissedCount)
                    {
                        break;
                    }

                    lastMissedCount = visitor.MissedCount;
                }
            }
        }
Esempio n. 10
0
 protected EFElement(EFContainer parent, XElement element)
     : base(parent, element)
 {
 }
Esempio n. 11
0
 protected EFNormalizableItem(EFContainer parent, XElement element)
     : base(parent, element)
 {
 }
Esempio n. 12
0
 protected EFContainer(EFContainer parent, XContainer xcontainer)
     : base(parent, xcontainer)
 {
 }
Esempio n. 13
0
 protected virtual void OnChildDeleted(EFContainer efContainer)
 {
 }
Esempio n. 14
0
 protected EFAttribute(EFContainer parent, XAttribute xattribute)
     : base(parent, xattribute)
 {
 }
Esempio n. 15
0
        /// <summary>
        ///     Find an EFObject given a delimited name identifier. For example,
        ///     to find the property 'SomeProperty' within the EntityType 'SomeEntity',
        ///     the delimitedNameIdentifier will be 'SomeProperty.SomeEntity' and the
        ///     startingObject will be the artifact
        /// </summary>
        /// <param name="delimitedNameIdentifier"></param>
        /// <returns></returns>
        internal static EFNameableItem FindNameableItemViaIdentifier(EFContainer excludedAncestor, string delimitedNameIdentifier)
        {
            var ids = new Queue <string>(delimitedNameIdentifier.Split('.'));

            return(FindNameableItemViaIdentifierInternal(excludedAncestor, ids));
        }
Esempio n. 16
0
 protected ItemBinding(EFContainer parent, XAttribute xattribute)
     : base(parent, xattribute)
 {
 }
Esempio n. 17
0
 internal EFNameableItem(EFContainer parent, XElement element)
     :
     base(parent, element)
 {
 }