コード例 #1
0
        public void createClass(String XmlPath, string ClassComment)
        {
            MysqlClass classModellator = new MysqlClass();
            //classModellator.PathToSave = this.txtPath.Text;
            classModellator.Description = ClassComment;
            classModellator.DriverUsed = (TypeOfDriver)this.comboBoxTypeDrivedr.SelectedItem;
            classModellator.AccessModifier = this.comboBoxModifiers.SelectedItem.ToString();
            classModellator.NameSpace = this.textBoxProjectName.Text + (this.textBoxProjectName.Text.Length > 0 ? "." : "") + this.textBoxNamespace.Text;
            classModellator.Name = this.textBoxClassName.Text;

            XmlTextReader reader = new XmlTextReader(XmlPath);
            String Name = "";
            String Type = "";

            bool isColumnName = false;
            bool isDataType = false;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (reader.Name == "ColumnName")
                        {
                            isColumnName = true;
                        }
                        else if (reader.Name == "DataType")
                        {
                            isDataType = true;
                        }
                        //DataType
                        break;

                    case XmlNodeType.Text:
                        if (isColumnName)
                        {
                            Name = reader.Value;
                            isColumnName = false;
                        }
                        else if (isDataType)
                        {
                            Type = reader.Value;
                            String[] vetStr = Type.Split(',');
                            PropertyModellator tmpPM = new PropertyModellator();
                            tmpPM.Name = Name;
                            tmpPM.Type = vetStr[0];
                            classModellator.ListProperties.Add(tmpPM);
                            //classTable.addProperty(Name, vetStr[0]);
                            isColumnName = false;
                            isDataType = false;
                            Name = "";
                            Type = "";
                        }
                        //tmp=reader.Value;
                        break;

                    case XmlNodeType.EndElement:
                        //tmp = reader.Name;

                        break;

                }
            }

            StreamWriter sw = File.CreateText(this.txtPath.Text + "\\" + classModellator.FileName);

            sw.Write(classModellator.getClassModellated());

            //classModellator.writeClass();

            if (this.checkBoxOpenFile.Checked)
            {
                System.Diagnostics.Process.Start(this.txtPath.Text + "\\" + classModellator.FileName);
            }
        }
コード例 #2
0
        public void setClass()
        {
            _tableInformations = _mysqlInf.getTableInformations(tables.SelectedItem.ToString());

            _tableInformations.Schema = this.databaseList.SelectedItem.ToString();
            _tableInformations.PrimaryKey = _mysqlInf.getPrimaryKeyConstraints(_tableInformations.Schema, tables.SelectedItem.ToString());
            _tableInformations.ForeignConstraints = _mysqlInf.getForeignConstraints(_tableInformations.Schema, tables.SelectedItem.ToString());
            _tableInformations.UniqueConstraints = _mysqlInf.getUniqueConstraints(_tableInformations.Schema, tables.SelectedItem.ToString());

            _mysqlClassModellator = new MysqlClass();
            //creazione della classe
            _mysqlClassModellator.TableInformation = _tableInformations;
            String summary = this.textBoxClassSummary.Text;

            summary += Environment.NewLine + "Full Class Information";
            summary += Environment.NewLine + "Table Name : " + _tableInformations.Name;
            summary += Environment.NewLine + "Table Comment : " + _tableInformations.Comment;
            summary += Environment.NewLine + "Table Collation : " + _tableInformations.Collation;
            summary += Environment.NewLine + "Table Create_time : " + _tableInformations.Create_time;
            summary += Environment.NewLine + "Table Engine : " + _tableInformations.Engine;
            summary += Environment.NewLine + "Table Version : " + _tableInformations.Version;
            summary += Environment.NewLine + "Table Row_format : " + _tableInformations.Row_format;
            summary += Environment.NewLine + "Table Rows : " + _tableInformations.Rows;
            summary += Environment.NewLine + "Table Avg_row_length : " + _tableInformations.Avg_row_length;
            summary += Environment.NewLine + "Table Data_length : " + _tableInformations.Data_length;
            summary += Environment.NewLine + "Table Max_data_length : " + _tableInformations.Max_data_length;
            summary += Environment.NewLine + "Table Index_length : " + _tableInformations.Index_length;
            summary += Environment.NewLine + "Table Data_free : " + _tableInformations.Data_free;
            summary += Environment.NewLine + "Table Auto_increment : " + _tableInformations.Auto_increment;
            summary += Environment.NewLine + "Table Update_time : " + _tableInformations.Update_time;
            summary += Environment.NewLine + "Table Check_time : " + _tableInformations.Check_time;
            summary += Environment.NewLine + "Table Checksum : " + _tableInformations.Checksum;
            summary += Environment.NewLine + "Table Create_options : " + _tableInformations.Create_options;

            if (checkBoxInsertCreateTable.Checked)
            {
                summary += Environment.NewLine + Environment.NewLine + Environment.NewLine + "Create Table Statment:";
                summary += "" + Environment.NewLine + _mysqlInf.getCreateTableString(tables.SelectedItem.ToString());
            }

            //classModellator.PathToSave = this.txtPath.Text;
            _mysqlClassModellator.Description = summary;
            _mysqlClassModellator.DriverUsed = (TypeOfDriver)this.comboBoxTypeDrivedr.SelectedItem;
            if (this.checkBoxPersonalCodeClass.Checked)
            {
                _mysqlClassModellator.AccessModifier = ListAccessModifiers.PUBLIC_PARTIAL.Value;
            }
            else
            {
                _mysqlClassModellator.AccessModifier = this.comboBoxModifiers.SelectedItem.ToString();
            }
            _mysqlClassModellator.NameSpace = this.textBoxProjectName.Text+(this.textBoxProjectName.Text.Length>0 ? ".":"") + this.textBoxNamespace.Text;
            _mysqlClassModellator.Name = this.textBoxClassName.Text;
            _mysqlClassModellator.ListCouloumbInformations = _mysqlInf.getFullColumnsList(tables.SelectedItem.ToString());
            summary = "";
            foreach (CoulomnInformations tmp in _mysqlClassModellator.ListCouloumbInformations)
            {
                PropertyModellator tmpPM = new PropertyModellator();

                tmpPM.Name = tmp.Field;
                summary = Environment.NewLine + "Complete informations";
                summary += Environment.NewLine + "Field: " + tmp.Field;
                summary += Environment.NewLine + "Comment: " + tmp.Comment;
                summary += Environment.NewLine + "Type: " + tmp.Type;
                summary += Environment.NewLine + "Collation: " + tmp.Collation;
                summary += Environment.NewLine + "Null: " + tmp.Null;
                summary += Environment.NewLine + "Key: " + tmp.Key;
                summary += Environment.NewLine + "Default: " + tmp.Default;
                summary += Environment.NewLine + "Extra: " + tmp.Extra;
                summary += Environment.NewLine + "Privileges: " + tmp.Privileges;
                tmpPM.Description = summary;
                tmpPM.Type = MysqlTypeMapping.getCsharpType(tmp.Type);
                _mysqlClassModellator.ListProperties.Add(tmpPM);

                //this.groupBoxFunction.Enabled = true;
            }
        }