private ModelMeta GenerateModelMeta()
        {
            var modelMeta = new ModelMeta();
            modelMeta.ProjectName = Model.Project.Name;
            modelMeta.Name = Model.Name;

            foreach (var entity in Model.Entities)
            {
                if (entity is EnumType)
                {
                    var entityType = entity as EnumType;
                    var entityMeta = new EnumMeta();

                    entityMeta.EntityType = Enum.GetName(typeof(EntityType), entity.EntityType);
                    entityMeta.Access = Enum.GetName(typeof(AccessModifier), entityType.Access);
                    entityMeta.Name = entityType.Name;
                    entityMeta.ValuesCount = entityType.ValueCount;

                    foreach (var value in entityType.Values)
                    {
                        entityMeta.Values.Add(Enum.GetName(typeof(EnumValue), value));
                    }

                    modelMeta.Entities.Add(entityMeta);
                }
                else
                {
                    var entityType = entity as CompositeType;
                    var entityMeta = new CompositeMeta();

                    entityMeta.EntityType = Enum.GetName(typeof(EntityType), entity.EntityType);
                    entityMeta.Access = Enum.GetName(typeof(AccessModifier), entityType.Access);
                    entityMeta.Name = entityType.Name;
                    entityMeta.NHMTableName = entityType.NHMTableName;
                    entityMeta.IdentityGenerator = EnumExtensions.GetDescription((IdentityGeneratorType)Enum.Parse(typeof(IdentityGeneratorType), entityType.IdGenerator));

                    if (entityType.SupportsFields)
                    {
                        entityMeta.FieldsCount = entityType.FieldCount;

                        foreach (var field in entityType.Fields)
                        {
                            var fieldMeta = new FieldMeta();
                            fieldMeta.MemberType = Enum.GetName(typeof(MemberType), field.MemberType);
                            fieldMeta.Access = Enum.GetName(typeof(AccessModifier), field.Access);
                            fieldMeta.Name = field.Name;
                            fieldMeta.Type = field.Type;

                            entityMeta.Fields.Add(fieldMeta);
                        }
                    }

                    if (entityType.SupportsOperations)
                    {
                        entityMeta.OperationsCount = entityType.OperationCount;

                        foreach (var operation in entityType.Operations)
                        {
                            var operationMeta = new OperationMeta();
                            operationMeta.MemberType = Enum.GetName(typeof(MemberType), operation.MemberType);
                            operationMeta.Access = Enum.GetName(typeof(AccessModifier), operation.Access);
                            operationMeta.Name = operation.Name;
                            operationMeta.Type = operation.Type;
                            operationMeta.NHMColumnName = operation.NHMColumnName;
                            operationMeta.Identity = operation.IsIdentity;
                            operationMeta.ManyToOne = operation.ManyToOne;
                            operationMeta.Unique = operation.IsUnique;
                            operationMeta.NotNull = operation.IsNotNull;

                            entityMeta.Operations.Add(operationMeta);
                        }
                    }

                    modelMeta.Entities.Add(entityMeta);
                }
            }

            return modelMeta;
        }
        private ModelMeta GenerateModelMeta()
        {
            var modelMeta = new ModelMeta();

            modelMeta.ProjectName   = Model.Project.Name;
            modelMeta.Name          = Model.Name;
            modelMeta.EntitiesNames = Model.Entities.Select(x => x.Name).ToList();

            foreach (var entity in Model.Entities)
            {
                if (entity is EnumType)
                {
                    var entityType = entity as EnumType;
                    var entityMeta = new EnumMeta();

                    entityMeta.EntityType  = Enum.GetName(typeof(EntityType), entity.EntityType);
                    entityMeta.Access      = Enum.GetName(typeof(AccessModifier), entityType.Access);
                    entityMeta.Name        = entityType.Name;
                    entityMeta.ValuesCount = entityType.ValueCount;

                    foreach (var value in entityType.Values)
                    {
                        entityMeta.Values.Add(Enum.GetName(typeof(EnumValue), value));
                    }

                    modelMeta.Entities.Add(entityMeta);
                }
                else
                {
                    var entityType = entity as CompositeType;
                    var entityMeta = new CompositeMeta();

                    entityMeta.EntityType = Enum.GetName(typeof(EntityType), entity.EntityType);
                    entityMeta.Access     = Enum.GetName(typeof(AccessModifier), entityType.Access);
                    entityMeta.Name       = entityType.Name;

                    if (entityType.SupportsFields)
                    {
                        entityMeta.FieldsCount = entityType.FieldCount;

                        foreach (var field in entityType.Fields)
                        {
                            var fieldMeta = new FieldMeta();
                            fieldMeta.MemberType = Enum.GetName(typeof(MemberType), field.MemberType);
                            fieldMeta.Access     = Enum.GetName(typeof(AccessModifier), field.Access);
                            fieldMeta.Name       = field.Name;
                            fieldMeta.Type       = field.Type;

                            entityMeta.Fields.Add(fieldMeta);
                        }
                    }

                    if (entityType.SupportsOperations)
                    {
                        entityMeta.OperationsCount = entityType.OperationCount;

                        foreach (var operation in entityType.Operations)
                        {
                            var operationMeta = new OperationMeta();
                            operationMeta.MemberType = Enum.GetName(typeof(MemberType), operation.MemberType);
                            operationMeta.Access     = Enum.GetName(typeof(AccessModifier), operation.Access);
                            operationMeta.Name       = operation.Name;
                            operationMeta.Type       = operation.Type;

                            entityMeta.Operations.Add(operationMeta);
                        }
                    }

                    modelMeta.Entities.Add(entityMeta);
                }
            }

            foreach (var relationship in Model.Relationships)
            {
                var relationshipMeta = new RelationshipMeta();
                relationshipMeta.RelationshipType = Enum.GetName(typeof(RelationshipType), relationship.RelationshipType);
                relationshipMeta.SupportsLabel    = relationship.SupportsLabel;
                relationshipMeta.Label            = relationship.Label;

                relationshipMeta.FirstEntity.EntityType = Enum.GetName(typeof(EntityType), relationship.First.EntityType);
                relationshipMeta.FirstEntity.Name       = relationship.First.Name;

                relationshipMeta.SecondEntity.EntityType = Enum.GetName(typeof(EntityType), relationship.Second.EntityType);
                relationshipMeta.SecondEntity.Name       = relationship.Second.Name;

                modelMeta.Relationships.Add(relationshipMeta);
            }

            return(modelMeta);
        }