private static bool IsCsdlElement(EFElement element)
        {
            var entityModel = element.GetParentOfType(typeof(BaseEntityModel)) as BaseEntityModel;

            if (entityModel != null &&
                entityModel.IsCSDL)
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        // <summary>
        //     Helper method that determine whether an EFElement is represented in model browser.
        // </summary>
        internal static bool IsDisplayedInExplorer(EFElement efElement)
        {
            // If efElement type is StorageEntityContainer or EFDesignerInfoRoot, don't display it in Model Browser.
            // Note: GetParentOfType() will also return true if self is of passed-in type.
            if (null != efElement.GetParentOfType(typeof(StorageEntityContainer)))
            {
                return(false);
            }
            // We do not display Enum type members
            else if (efElement is EnumTypeMember)
            {
                return(false);
            }
            // For any Designer objects, check whether the map between the EFElement and ExplorerEFElement exists.
            else if (null != efElement.GetParentOfType(typeof(EFDesignerInfoRoot)))
            {
                return(_modelType2ExplorerViewModelType.ContainsKey(efElement.GetType()));
            }

            return(true);
        }
示例#3
0
        internal static NormalizedName NameNormalizer(EFElement parent, string refName)
        {
            Debug.Assert(parent != null, "parent should not be null");

            if (refName == null)
            {
                return(null);
            }

            var entityContainerName = string.Empty;

            var parentAssociationSet         = parent as AssociationSet;
            var parentAssociationSetMapping  = parent as AssociationSetMapping;
            var parentFunctionAssociationEnd = parent as FunctionAssociationEnd;

            if (parentAssociationSet != null)
            {
                // are we trying to normalize the name of actual association set in the EC?
                var ec = parentAssociationSet.Parent as BaseEntityContainer;
                if (ec != null)
                {
                    entityContainerName = ec.LocalName.Value;
                }
            }
            else if (parentAssociationSetMapping != null ||
                     parentFunctionAssociationEnd != null)
            {
                // we need to resolve a reference from the MSL to the AssociationSet
                var ecm = parent.GetParentOfType(typeof(EntityContainerMapping)) as EntityContainerMapping;
                if (ecm != null)
                {
                    entityContainerName = ecm.CdmEntityContainer.RefName;
                }
            }

            Symbol symbol = null;

            if (!string.IsNullOrEmpty(entityContainerName))
            {
                symbol = new Symbol(entityContainerName, refName);
            }

            if (symbol == null)
            {
                symbol = new Symbol(refName);
            }

            var normalizedName = new NormalizedName(symbol, null, null, refName);

            return(normalizedName);
        }
        internal static NormalizedName NameNormalizer(EFElement parent, string refName)
        {
            Debug.Assert(parent != null, "parent should not be null");

            if (refName == null)
            {
                return null;
            }

            var entityContainerName = string.Empty;

            var parentAssociationSet = parent as AssociationSet;
            var parentAssociationSetMapping = parent as AssociationSetMapping;
            var parentFunctionAssociationEnd = parent as FunctionAssociationEnd;

            if (parentAssociationSet != null)
            {
                // are we trying to normalize the name of actual association set in the EC?
                var ec = parentAssociationSet.Parent as BaseEntityContainer;
                if (ec != null)
                {
                    entityContainerName = ec.LocalName.Value;
                }
            }
            else if (parentAssociationSetMapping != null
                     || parentFunctionAssociationEnd != null)
            {
                // we need to resolve a reference from the MSL to the AssociationSet
                var ecm = parent.GetParentOfType(typeof(EntityContainerMapping)) as EntityContainerMapping;
                if (ecm != null)
                {
                    entityContainerName = ecm.CdmEntityContainer.RefName;
                }
            }

            Symbol symbol = null;
            if (!string.IsNullOrEmpty(entityContainerName))
            {
                symbol = new Symbol(entityContainerName, refName);
            }

            if (symbol == null)
            {
                symbol = new Symbol(refName);
            }

            var normalizedName = new NormalizedName(symbol, null, null, refName);
            return normalizedName;
        }