public static string Format(string query) { var rule = new SqlRule(); var formatter = new SqlFormatter(rule); return(formatter.Format(query)); }
public void SetAndExecuteSql(string sql = "") { if (!sqlManager.isConnected) { MessageBox.Show($"{formBar.SVCombo.Text}との接続が開かれていません。", "Reseacher"); return; } if (sql != "") { tabGrid.CurrentQuery.Text = sql; } SqlRule rule = new SqlRule(); SqlFormatter formatter = new SqlFormatter(rule); try { var xml = new XmlManager(); if (xml[new List <string>() { "format" }, "False"].ToUpper().Equals("TRUE")) { TabGrid.CurrentQuery.Text = formatter.Format(TabGrid.CurrentQuery.Text); } } catch { /* ignore */ } sqlManager.ExecuteSqlToServer(tabGrid.CurrentQuery.Text, tabGrid.CurrentTabIndex.ToString()); tabGrid.CurrentGridView.DataSource = sqlManager.Tables[tabGrid.CurrentTabIndex.ToString()]; tabGrid.CurrentQuery.SetSelection(tabGrid.CurrentQuery.Text.Length, tabGrid.CurrentQuery.Text.Length); RecCount = $"Rows : {TabGrid.CurrentGridView.Rows.Count} / Columns : {TabGrid.CurrentGridView.Columns.Count} "; }
public void FormatText(bool isUseNewline = false) { var rule = new SqlRule(); rule.IndentString = isUseNewline ? " " : ""; var formatter = new SqlFormatter(rule); var formattedText = formatter.Format(Text); if (!isUseNewline) { formattedText = formattedText.Replace(System.Environment.NewLine, " "); } ; Text = formattedText; }