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

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

            bool IsConstraint(AttributeData attribute)
            {
                return(IsCheckConstraint(attribute) || IsUniqueConstraint(attribute));
            }

            bool IsCheckConstraint(AttributeData attribute)
            {
                return(Compilation.GetKnownType(KnownTypes.CheckConstraintAttribute).Equals(attribute.AttributeClass));
            }

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