Exemplo n.º 1
0
        public ExplorerTypes(string name, EditingContext context, ExplorerEFElement parent)
            : base(context, null, parent)
        {
            if (name != null)
            {
                base.Name = name;
            }

            _isConceptual = (typeof(ExplorerConceptualEntityModel) == parent.GetType()) ? true : false;
        }
Exemplo n.º 2
0
        protected override bool RemoveChild(ExplorerEFElement efElementToRemove)
        {
            var explorerProperty = efElementToRemove as ExplorerProperty;

            if (explorerProperty != null)
            {
                var indexOfRemovedChild = _properties.Remove(explorerProperty);
                return((indexOfRemovedChild < 0) ? false : true);
            }

            Debug.Fail(
                string.Format(
                    CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType,
                    efElementToRemove.GetType().FullName, Name, GetType().FullName));
            return(false);
        }
        protected override bool RemoveChild(ExplorerEFElement efElementToRemove)
        {
            var explorerAssocSet = efElementToRemove as ExplorerAssociationSet;

            if (explorerAssocSet == null)
            {
                Debug.Fail(
                    string.Format(
                        CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType,
                        efElementToRemove.GetType().FullName, Name, GetType().FullName));
                return(false);
            }

            var indexOfRemovedChild = _associationSets.Remove(explorerAssocSet);

            return((indexOfRemovedChild < 0) ? false : true);
        }
        protected override bool RemoveChild(ExplorerEFElement efElementToRemove)
        {
            var explorerEntityContainer = efElementToRemove as ExplorerConceptualEntityContainer;

            if (explorerEntityContainer == null)
            {
                Debug.Fail(
                    string.Format(
                        CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType,
                        efElementToRemove.GetType().FullName, Name, GetType().FullName));
                return(false);
            }

            var indexOfRemovedChild = _entityContainers.Remove(explorerEntityContainer);

            return((indexOfRemovedChild < 0) ? false : true);
        }
Exemplo n.º 5
0
        protected override bool RemoveChild(ExplorerEFElement efElementToRemove)
        {
            var explorerEntityTypeShape = efElementToRemove as ExplorerEntityTypeShape;

            if (explorerEntityTypeShape == null)
            {
                Debug.Fail(
                    string.Format(
                        CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType,
                        efElementToRemove.GetType().FullName, Name, GetType().FullName));
                return(false);
            }
            // We can't use TypedChildList's Remove to delete the entity-type-shape because the it will fail if the underlying entity-type has been deleted.
            // When the entity-type is deleted, the name of the entity-type-shape will change to an empty string and deletion will fail
            // until the list is re-sorted (see implementation of ExplorerEFElement's Remove).
            return(_explorerEntityTypeShapes.ChildList.Remove(explorerEntityTypeShape));
        }
        private static ExplorerEFElement GetNewOrExisting(
            EditingContext context, EFElement efElement, ExplorerEFElement parent, Type viewModelType, bool mustNotExist)
        {
            var xref   = GetModelToBrowserModelXRef(context);
            var result = xref.GetExisting(efElement);

            if (result != null)
            {
                if (mustNotExist)
                {
                    Debug.Fail(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Resources.BadInsertChildAlreadyExists, efElement.GetType().FullName, parent.GetType().FullName));
                    return(null);
                    // TODO: we need to provide a general exception-handling mechanism and replace the above Assert()
                    // by e.g. the excepiton below
                    // throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.BadInsertChildAlreadyExists, efElement.GetType().FullName, parent.GetType().FullName));
                }
                else
                {
                    result.Parent = parent;
                }
            }
            else
            {
                if (viewModelType != null)
                {
                    if (!xref.IsDisplayedInExplorerProtected(efElement))
                    {
                        Debug.Fail(
                            "Attempting to create an ExplorerEFElement of type " + viewModelType.FullName +
                            " based on an EFElement which is not displayed in the Explorer " + efElement.ToPrettyString());
                        return(null);
                    }

                    result = Activator.CreateInstance(viewModelType, context, efElement, parent) as ExplorerEFElement;
                    xref.Add(efElement, result);
                }
            }

            return(result);
        }