Exemplo n.º 1
0
        private void InitIndexItems(DataRow root)
        {
            DataRow folderRow = null;

            foreach (var node in GetTypeAttributes(_modelType, IsIndex).Select(CreateNode).Where(x => x != null))
            {
                if (folderRow == null)
                {
                    folderRow = AddRow(root, new FolderNode(UserMessages.FolderName_Index));
                }
                AddRow(folderRow, node);
            }

            bool IsIndex(AttributeData attribute)
            {
                return(IsDbIndex(attribute) || IsUniqueConstraint(attribute));
            }

            bool IsDbIndex(AttributeData attribute)
            {
                return(Compilation.GetKnownType(KnownTypes.DbIndexAttribute).Equals(attribute.AttributeClass));
            }

            Node CreateNode((INamedTypeSymbol Type, AttributeData Attribute) info)
            {
                if (IsDbIndex(info.Attribute))
                {
                    return(AttributeNode.CreateIndex(this, info));
                }
                else
                {
                    Debug.Assert(IsUniqueConstraint(info.Attribute));
                    return(AttributeNode.CreateUniqueConstraint(this, info));
                }
            }
        }