Ejemplo n.º 1
0
 public void BuildTest()
 {
     var builder = new DBBuilder(new DBConnection
     {
         Account = "gonnatour",
         DBType = DataBaseType.MSSQL,
         Name = "gonnatour",
         Password = "******",
         Server = "localhost"
     });
     DataBase database = builder.Build();
     var parameter = new BuilderParameters { DataBase = database, OutputDirectory = new DirectoryInfo("./../DAO/"), Template = new FileInfo("./testdata/test2.tpl"),Namespace = "xCode.Test.Objects"};
     var daoBuilder = new ClassBuilder(parameter);
     var files = daoBuilder.Build();
     foreach (var file in files)
     {
         Console.WriteLine(file);
     }
     var hbmBuilder = new HBMBuilder (parameter);
     files = hbmBuilder.Build();
     foreach (var file in files)
     {
         Console.WriteLine(file);
     }
 }
Ejemplo n.º 2
0
        public void ParserTest()
        {
            var builder = new DBBuilder(new DBConnection
                                            {
                                                Account = "gonnatour",
                                                DBType = DataBaseType.MSSQL,
                                                Name = "gonnatour",
                                                Password = "******",
                                                Server = "localhost"
                                            });
            DataBase database = builder.Build();
            var options = new ParserOption();

            foreach (Table table in database.Tables)
            {
                options.VariableParameter = table;
                table.Columns = table.Columns.OrderByDescending(t => t.PrimaryKey).ThenBy(t => t.Name).ToList();
                options.StatementParameters = new object[] { database, table };
                options.Namesapces.Add("xCoder.DB2Project.Data");
                options.References.Add("System.dll");
                options.References.Add(@".\xCoder.DB2Project.dll");
                options.SourceCode = new FileInfo("./testdata/test2.tpl");
                var parser = new Parser(options);
                string temp = parser.Parse(ParserType.XCODER);
                Console.WriteLine(temp);
            }
        }
Ejemplo n.º 3
0
        public void Read()
        {
            var builder = new DBBuilder(new DBConnection
                                            {
                                                Account = "gonnatour",
                                                DBType = DataBaseType.MSSQL,
                                                Name = "gonnatour",
                                                Password = "******",
                                                Server = "localhost"
                                            });
            DataBase database = builder.Build();
            Console.WriteLine(database.Tables.Count);

            foreach (Table table in database.Tables)
            {
                string json = JsonUtil.Convert(table);
                Console.WriteLine("TABLE : " + json);
                foreach (Column column in table.Columns)
                {
                    json = JsonUtil.Convert(column);
                    Console.WriteLine("     COLUMN : " + json);
                    foreach (ForeignKey foreignKey in column.ForeignKeys)
                    {
                        json = JsonUtil.Convert(foreignKey);
                        Console.WriteLine("         Foreign Key : " + json);
                    }
                }
            }

            var nhBuilder =
                new HBMBuilder(new BuilderParameters
                                          {
                                              DataBase = database,
                                              Namespace = "test",
                                              OutputDirectory =
                                                  new DirectoryInfo(@"D:\Personal\VS2010\xCoder\xCoder.Test\test\nh\")
                                          });
            string[] files = nhBuilder.Build();
            foreach (string file in files)
            {
                Console.WriteLine(file);
            }
        }