private IEnumerable <EnumNode> GetEnumReferences(EnumMetaData @enum)
        {
            Contract.Requires(@enum != null);

            return(classes
                   .SelectMany(c => c.Nodes.Where(n => n is EnumNode || (n as BaseWrapperNode)?.ResolveMostInnerNode() is EnumNode))
                   .Cast <EnumNode>()
                   .Where(e => e.MetaData == @enum));
        }
        public EnumReferencedException(EnumMetaData @enum, IEnumerable <ClassNode> references)
            : base($"The enum '{@enum.Name}' is referenced in other classes.")
        {
            Contract.Requires(@enum != null);
            Contract.Requires(references != null);
            Contract.Requires(Contract.ForAll(references, c => c != null));

            Enum       = @enum;
            References = references;
        }
        public void RemoveEnum(EnumMetaData @enum)
        {
            Contract.Requires(@enum != null);

            var refrences = GetEnumReferences(@enum).ToList();

            if (refrences.Any())
            {
                throw new EnumReferencedException(@enum, refrences.Select(e => e.GetParentClass()).Distinct());
            }

            enums.Remove(@enum);
        }
        public void AddEnum(EnumMetaData @enum)
        {
            Contract.Requires(@enum != null);

            enums.Add(@enum);
        }