Esempio n. 1
0
        public void AddParam(string type, string name, object value)
        {
            CSVar param = new CSVar(type, name, null);

            param.SetValue(value);
            attParamList.Add(param);
        }
Esempio n. 2
0
        public CSVar AddParam(string restrain, string type, string name)
        {
            CSVar param = new CSVar(restrain, type, name, null);

            paramArray.Add(param);
            return(param);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加参数
        /// </summary>
        /// <param name="type"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public CSVar AddParam(string type, string value)
        {
            CSVar param = new CSVar(type, "name", null);

            param.SetValue(value);
            paramArray.Add(param);
            return(param);
        }
Esempio n. 4
0
        public string GenerateFuncDefineString()
        {
            StringBuilder funcStringBuilder = new StringBuilder();

            //write func delc
            if (!string.IsNullOrEmpty(restrain))
            {
                funcStringBuilder.Append(restrain);
                funcStringBuilder.Append(" ");
            }
            funcStringBuilder.Append(type);
            funcStringBuilder.Append(" ");
            funcStringBuilder.Append(name);

            //func param list
            funcStringBuilder.Append("(");


            for (int i = 0; i < paramArray.Count; ++i)
            {
                CSVar param = paramArray[i];

                funcStringBuilder.Append(param.type);
                funcStringBuilder.Append(" ");
                funcStringBuilder.Append(param.name);
                if (i < paramArray.Count - 1)
                {
                    funcStringBuilder.Append(",");
                }
            }
            funcStringBuilder.Append(")");
            funcStringBuilder.AppendLine();

            //body
            funcStringBuilder.Append("\t");
            funcStringBuilder.Append("{");
            funcStringBuilder.AppendLine();

            GenerateFuncContent(funcStringBuilder);

            funcStringBuilder.AppendLine();
            funcStringBuilder.Append("\t");
            funcStringBuilder.Append("}");
            return(funcStringBuilder.ToString());
        }
        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);
        }