예제 #1
0
        public IEnumerator DownLoadDataBase()
        {
            string dbPath = string.Format("{0}/{1}", Application.persistentDataPath, DataBaseHelperExtend.DatabaseName);

            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }
            string path = string.Format("{0}/{1}", Application.streamingAssetsPath, DataBaseHelperExtend.DatabaseName);
            WWW    db   = new WWW(path);

            yield return(db);

            WriteCodeToFile codeToFile = new WriteCodeToFile();

            codeToFile.WriteFile(dbPath, db.bytes, 1024);
        }
예제 #2
0
        public static void GenerateCode()
        {
            string           sql        = "SELECT * FROM sqlite_master where type='table' AND tbl_name != 'sqlite_sequence'";
            SQLiteConnection connection = DataBaseHelperExtend.GetDefaultDataBaseConnnect();
            List <TableView> tableViews = connection.Query <TableView>(sql);

            string templematePath = string.Format("{0}/Helper/Templemate/TableTemplate.txt", Application.dataPath);
            string templemateStr  = File.ReadAllText(templematePath);

            WriteCodeToFile codeWrite = new WriteCodeToFile();

            IRegularExpressionHelper regularExpressionHelper = new TableStructHelper();

            foreach (TableView item in tableViews)
            {
                string code             = regularExpressionHelper.GetExpresionResult(item.tbl_name);
                string replaceClassName = templemateStr.Replace("#SCRIPTNAME#", item.name);
                string finalCode        = replaceClassName.Replace("#CodeList#", code);
                string finalSourcePath  = string.Format("{0}/DataBaseCode/{1}.cs", Application.dataPath, item.tbl_name);
                codeWrite.WriteToFile(finalSourcePath, finalCode);
            }
        }