示例#1
0
 public void Add(CodeFormat code)
 {
     if (!codeFormats.Contains(code))
     {
         codeFormats.Add(code);
     }
 }
示例#2
0
        public string GetExpresionResult(string tableName)
        {
            SQLiteConnection   connection    = DataBaseHelperExtend.GetDefaultDataBaseConnnect();
            List <CodeFormat>  codeList      = new List <CodeFormat>();
            ICodeFormatManager formatManager = new CodeFormatManager();
            ISQLToSharp        sqlReplace    = new SQLToSharp();

            foreach (var item in connection.GetTableInfo(tableName))
            {
                string CodeType = string.Format("{0}", sqlReplace.ReplaceSQLType(item.ColumnType));

                CodeFormat codeFormat = new CodeFormat()
                {
                    CodeTypeName = item.Name, CodeType = CodeType
                };
                formatManager.Add(codeFormat);
            }
            string finalResult = formatManager.GetCodeResult();

            return(finalResult);
        }
示例#3
0
        public string GetExpresionResult(string input)
        {
            ISQLToSharp sqlReplace = new SQLToSharp();

            string finalResult = "";
            string pattern     = @"\((.*)";
            Match  match       = Regex.Match(input, pattern);

            pattern = @"\(|\sPRIMARY|KEY|ASC|AUTOINCREMENT|NOT|NULL|UNIQUE|DEFAULT\s\(\d+\)|,|\)|\bDEFAULT\s\w+|\d+\)\s|NULL|\'|DEFAULT";
            Regex  regex  = new Regex(pattern);
            string result = regex.Replace(match.Value, "");

            pattern = @"\w+";
            regex   = new Regex(pattern);
            MatchCollection    matchCollection = regex.Matches(result);
            List <CodeFormat>  codeList        = new List <CodeFormat>();
            ICodeFormatManager formatManager   = new CodeFormatManager();
            CodeFormat         codeFormat      = new CodeFormat();

            for (int i = 0; i < matchCollection.Count; i++)
            {
                string matchValue = matchCollection[i].Value;

                if ((i % 2) == 0)
                {
                    codeFormat.CodeTypeName = string.Format("{0}", matchCollection[i].Value);
                }
                else
                {
                    codeFormat.CodeType = string.Format("{0}", sqlReplace.ReplaceSQLType(matchCollection[i].Value));
                    formatManager.Add(codeFormat);
                }
            }


            finalResult = formatManager.GetCodeResult();
            return(finalResult);
        }