예제 #1
0
        public CSField AddVar(string restrain, string type, string name, string comment = null)
        {
            CSField var = new CSField(restrain, type, name, comment);

            varList.Add(var);
            return(var);
        }
예제 #2
0
        CSFileWriter ConvertTable(string dBName, string tableName, string comment, string[] impledInterface)
        {
            CSFileWriter writer = new CSFileWriter();

            string sqlString = string.Format("PRAGMA table_info([{0}]);", tableName);

            using (SQLiteCommand cmd = mSqliteConn.CreateCommand())
            {
                cmd.CommandText = sqlString;
                //using
                writer.AddReferencedLib("System");

                CSClass classObj = writer.AddCSClass("public", tableName, impledInterface);

                SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                DataTable         dt = new DataTable();
                da.Fill(dt);
                DataColumn nameCol = dt.Columns["name"];
                DataColumn typeCol = dt.Columns["type"];

                CSParseFunc parseFunc = new CSParseFunc("public", tableName, "ReadData");

                CSVar dataForm = parseFunc.AddParam(string.Empty, "ASteinGameDataHolder", "dataForm");
                classObj.AddFuncDeclare(parseFunc);

                foreach (DataRow row in dt.Rows)
                {
                    CSField dataVar = classObj.AddVar("public", SqliteType2CsType(row[typeCol].ToString()), row[nameCol].ToString());

                    CSFuncCall parseCall = new CSFuncCall(string.Empty, SqliteType2CsType(row[typeCol].ToString()), SqliteType2CsReadType(row[typeCol].ToString()));
                    parseCall.AddParam("string", row[nameCol].ToString());
                    parseCall.targetObj = dataForm;
                    parseCall.returnVar = dataVar;

                    parseFunc.AddParseCall(parseCall);
                }
            }

            //System.Diagnostics.Trace.WriteLine(writer.GenerateFilsString());

            return(writer);
        }