Beispiel #1
0
        private static void create(LanuageTemplate lan, string sqlFile, int index, StringBuilder fieldBuilder, StringBuilder methodBuilder)
        {
            //parsh the sql file
            StreamReader sqlReader = new StreamReader(sqlFile, Encoding.UTF8);
            Dictionary <string, Hashtable> dicField = createSqlTemplate(sqlReader);


            string       fieldPath    = lan.Field_template_path;
            string       methodPath   = lan.Method_template_path;
            StreamReader fieldReader  = new StreamReader(fieldPath, Encoding.UTF8);
            StreamReader methodReader = new StreamReader(methodPath, Encoding.UTF8);

            //遍历所有的表进行生成相应的配置

            foreach (Hashtable table in dicField.Values)
            {
                string [] fieldArr = new string[table.Keys.Count];
                int       i        = 0;
                foreach (string key in table.Keys)
                {
                    fieldArr[i++] = key;
                }
                Array.Sort(fieldArr);

                foreach (string key in fieldArr)
                {
                    ClassTemplate meta    = (ClassTemplate)table[key];
                    ClassTemplate newMeta = (ClassTemplate)meta.Clone();
                    newMeta.Field_type = getFieldType(newMeta, lan.Language_type);
                    convertToField(index, fieldBuilder, fieldReader, newMeta, lan.Language_type);
                    convertToMethod(index, methodBuilder, methodReader, newMeta);
                }
            }
            sqlReader.Close();
            fieldReader.Close();
            methodReader.Close();
        }