コード例 #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();
        }
コード例 #2
0
        private List <LanuageTemplate> getTemplateList()
        {
            List <LanuageTemplate> templateList = new List <LanuageTemplate>();
            LanuageTemplate        java_lan     = new LanuageTemplate();

            java_lan.Language_type        = 1;
            java_lan.Field_template_path  = @path + @"\config\java_field_template.txt";
            java_lan.Class_template_path  = @path + @"\config\java_class_template.txt";
            java_lan.Field_type_map_path  = @path + @"\config\java_field_type_map.txt";
            java_lan.Method_template_path = @path + @"\config\java_method_template.txt";
            java_lan.Target_file_type     = ".java";
            templateList.Add(java_lan);

            LanuageTemplate csLan = new LanuageTemplate();

            csLan.Language_type        = 2;
            csLan.Field_template_path  = @path + @"\config\c#_field_template.txt";
            csLan.Class_template_path  = @path + @"\config\c#_class_template.txt";
            csLan.Method_template_path = @path + @"\config\c#_method_template.txt";
            csLan.Target_file_type     = ".cs";
            templateList.Add(csLan);

            return(templateList);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: agan112/convertSqlToEntity
        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();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: agan112/convertSqlToEntity
        private List<LanuageTemplate> getTemplateList()
        {
            List<LanuageTemplate> templateList = new List<LanuageTemplate>();
            LanuageTemplate java_lan = new LanuageTemplate();
            java_lan.Language_type = 1;
            java_lan.Field_template_path = @path+@"\config\java_field_template.txt";
            java_lan.Class_template_path = @path + @"\config\java_class_template.txt";
            java_lan.Field_type_map_path = @path + @"\config\java_field_type_map.txt";
            java_lan.Method_template_path = @path + @"\config\java_method_template.txt";
            java_lan.Target_file_type = ".java";
            templateList.Add(java_lan);

            LanuageTemplate csLan = new LanuageTemplate();
            csLan.Language_type = 2;
            csLan.Field_template_path = @path + @"\config\c#_field_template.txt";
            csLan.Class_template_path = @path + @"\config\c#_class_template.txt";
            csLan.Method_template_path = @path + @"\config\c#_method_template.txt";
            csLan.Target_file_type = ".cs";
            templateList.Add(csLan);

            return templateList;
        }