public static void Highlighting(RichTextBox richTextBox, DatabaseType databaseType, bool keepPosition = true, int?startIndex = null, int?stopIndex = null) { int start = richTextBox.SelectionStart; var dataTypes = DataTypeManager.GetDataTypeSpecifications(databaseType).Select(item => item.Name); var keywords = KeywordManager.GetKeywords(databaseType); var functions = FunctionManager.GetFunctionSpecifications(databaseType).Select(item => item.Name).Except(keywords); string dataTypesRegex = $@"\b({string.Join("|", dataTypes)})\b"; string keywordsRegex = $@"\b({string.Join("|", keywords)})\b"; string functionsRegex = $@"\b({string.Join("|", functions)})\b"; string stringRegex = $@"(['][^'^(^)]*['])"; Highlighting(richTextBox, dataTypesRegex, RegexOptions.IgnoreCase, Color.Blue); Highlighting(richTextBox, keywordsRegex, RegexOptions.IgnoreCase, Color.Blue); Highlighting(richTextBox, functionsRegex, RegexOptions.IgnoreCase, ColorTranslator.FromHtml("#FF00FF")); Highlighting(richTextBox, stringRegex, RegexOptions.IgnoreCase, Color.Red); string commentString = databaseType == DatabaseType.MySql ? "#" : "--"; string commentRegex = $@"({commentString}).*[\n]?"; Highlighting(richTextBox, commentRegex, RegexOptions.IgnoreCase, Color.Green); richTextBox.SelectionStart = keepPosition ? start : 0; richTextBox.SelectionLength = 0; richTextBox.Focus(); }
public ColumnTranslator(DbInterpreter sourceInterpreter, DbInterpreter targetInterpreter, List <TableColumn> columns) : base(sourceInterpreter, targetInterpreter) { this.columns = columns; this.sourceDbType = sourceInterpreter.DatabaseType; this.targetDbType = targetInterpreter.DatabaseType; this.sourceDataTypeSpecs = DataTypeManager.GetDataTypeSpecifications(this.sourceDbType); this.targetDataTypeSpecs = DataTypeManager.GetDataTypeSpecifications(this.targetDbType); }
public static List <TableColumnDesingerInfo> GetTableColumnDesingerInfos(DbInterpreter dbInterpreter, Table table, List <TableColumn> columns, List <TablePrimaryKey> primaryKeys) { List <TableColumnDesingerInfo> columnDesingerInfos = new List <TableColumnDesingerInfo>(); IEnumerable <string> dataTypes = DataTypeManager.GetDataTypeSpecifications(dbInterpreter.DatabaseType).Select(item => item.Name); foreach (TableColumn column in columns) { DataTypeInfo dataTypeInfo = DataTypeHelper.GetDataTypeInfo(column.DataType); TableColumnDesingerInfo columnDesingerInfo = new TableColumnDesingerInfo() { OldName = column.Name, IsPrimary = primaryKeys.Any(item => item.Columns.Any(t => t.ColumnName == column.Name)), Length = dbInterpreter.GetColumnDataLength(column) }; ObjectHelper.CopyProperties(column, columnDesingerInfo); string dataType = column.IsUserDefined ? column.DataType : dataTypeInfo.DataType.ToLower(); if (!dataTypes.Contains(dataType)) { dataTypeInfo = DataTypeHelper.GetSpecialDataTypeInfo(dataType); dataType = dataTypeInfo.DataType; columnDesingerInfo.Length = dataTypeInfo.Args; } columnDesingerInfo.DataType = dataType; columnDesingerInfo.ExtraPropertyInfo = new TableColumnExtraPropertyInfo(); if (column.IsComputed) { columnDesingerInfo.ExtraPropertyInfo.Expression = column.ComputeExp; } if (table.IdentitySeed.HasValue) { columnDesingerInfo.ExtraPropertyInfo.Seed = table.IdentitySeed.Value; columnDesingerInfo.ExtraPropertyInfo.Increment = table.IdentityIncrement.Value; } columnDesingerInfos.Add(columnDesingerInfo); } return(columnDesingerInfos); }
public static IEnumerable <DataTypeDesignerInfo> GetDataTypeInfos(DatabaseType databaseType) { List <DataTypeDesignerInfo> dataTypeDesignerInfos = new List <DataTypeDesignerInfo>(); IEnumerable <DataTypeSpecification> dataTypeSpecifications = DataTypeManager.GetDataTypeSpecifications(databaseType); foreach (DataTypeSpecification dataTypeSpec in dataTypeSpecifications) { DataTypeDesignerInfo dataTypeDesingerInfo = new DataTypeDesignerInfo(); ObjectHelper.CopyProperties(dataTypeSpec, dataTypeDesingerInfo); dataTypeDesignerInfos.Add(dataTypeDesingerInfo); } return(dataTypeDesignerInfos); }
private void LoadDataTypes() { dataTypeSpecifications = DataTypeManager.GetDataTypeSpecifications(this.DatabaseType); List <DatabaseObject> dbObjects = new List <DatabaseObject>(); dbObjects.AddRange(dataTypeSpecifications.Select(item => new DatabaseObject { Name = item.Name })); if (this.UserDefinedTypes != null) { dbObjects.AddRange(this.UserDefinedTypes); } this.colDataType.DataSource = dbObjects; this.colDataType.DisplayMember = "Name"; this.colDataType.ValueMember = "Name"; this.colDataType.AutoComplete = true; }