private void SetFormatter()
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter innerFormatter;
            if (radio_Formatting_Standard.Checked)
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(
                    txt_Indent.Text,
                    int.Parse(txt_IndentWidth.Text),
                    int.Parse(txt_MaxWidth.Text),
                    chk_ExpandCommaLists.Checked,
                    chk_TrailingCommas.Checked,
                    chk_SpaceAfterComma.Checked,
                    chk_ExpandBooleanExpressions.Checked,
                    chk_ExpandCaseStatements.Checked,
                    chk_ExpandBetweenConditions.Checked,
                    chk_BreakJoinOnSections.Checked,
                    chk_UppercaseKeywords.Checked,
                    chk_Coloring.Checked,
                    chk_EnableKeywordStandardization.Checked
                    );
            }
            else
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(chk_IdentityColoring.Checked);
            }

            innerFormatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix");
            _formatter = new PoorMansTSqlFormatterLib.Formatters.HtmlPageWrapper(innerFormatter);
        }
        public string FormatTSqlWithOptions(
            string inputString,
            bool reFormat,
            string indent,
            int spacesPerTab,
            int maxLineWidth,
            bool expandCommaLists,
            bool trailingCommas,
            bool spaceAfterExpandedComma,
            bool expandBooleanExpressions,
            bool expandCaseStatements,
            bool expandBetweenConditions,
            bool breakJoinOnSections,
            bool uppercaseKeywords,
            bool coloring,
            bool keywordStandardization,
            bool useParseErrorPlaceholder
            )
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter formatter = null;
            if (reFormat)
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(
                    indent,
                    spacesPerTab,
                    maxLineWidth,
                    expandCommaLists,
                    trailingCommas,
                    spaceAfterExpandedComma,
                    expandBooleanExpressions,
                    expandCaseStatements,
                    expandBetweenConditions,
                    breakJoinOnSections,
                    uppercaseKeywords,
                    coloring,
                    keywordStandardization
                    );
            }
            else
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(coloring);
            }

            if (useParseErrorPlaceholder)
            {
                formatter.ErrorOutputPrefix = "{PARSEERRORPLACEHOLDER}";
            }

            return(FormatTSqlWithFormatter(inputString, formatter));
        }
Example #3
0
        private void SetFormatter()
        {
            ISqlTreeFormatter innerFormatter;

            if (radio_Formatting_Standard.Checked)
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatterOptions
                {
                    IndentString             = txt_Indent.Text,
                    SpacesPerTab             = int.Parse(txt_IndentWidth.Text),
                    MaxLineWidth             = int.Parse(txt_MaxWidth.Text),
                    ExpandCommaLists         = chk_ExpandCommaLists.Checked,
                    TrailingCommas           = chk_TrailingCommas.Checked,
                    SpaceAfterExpandedComma  = chk_SpaceAfterComma.Checked,
                    ExpandBooleanExpressions = chk_ExpandBooleanExpressions.Checked,
                    ExpandCaseStatements     = chk_ExpandCaseStatements.Checked,
                    ExpandBetweenConditions  = chk_ExpandBetweenConditions.Checked,
                    ExpandInLists            = chk_ExpandInLists.Checked,
                    BreakJoinOnSections      = chk_BreakJoinOnSections.Checked,
                    UppercaseKeywords        = chk_UppercaseKeywords.Checked,
                    HTMLColoring             = chk_Coloring.Checked,
                    KeywordStandardization   = chk_EnableKeywordStandardization.Checked,
                    NewStatementLineBreaks   = int.Parse(txt_StatementBreaks.Text),
                    NewClauseLineBreaks      = int.Parse(txt_ClauseBreaks.Text)
                });
            }
            else if (radio_Formatting_Identity.Checked)
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(chk_IdentityColoring.Checked);
            }
            else
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlObfuscatingFormatter(
                    chk_RandomizeKeywordCase.Checked,
                    chk_RandomizeColor.Checked,
                    chk_RandomizeLineLength.Checked,
                    chk_PreserveComments.Checked,
                    chk_KeywordSubstitution.Checked
                    );
            }

            innerFormatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix") + Environment.NewLine;
            _formatter = new PoorMansTSqlFormatterLib.Formatters.HtmlPageWrapper(innerFormatter);
        }
        private void SetFormatter()
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter innerFormatter;
            if (radio_Formatting_Standard.Checked)
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(
                    txt_Indent.Text,
                    int.Parse(txt_IndentWidth.Text),
                    int.Parse(txt_MaxWidth.Text),
                    chk_ExpandCommaLists.Checked,
                    chk_TrailingCommas.Checked,
                    chk_SpaceAfterComma.Checked,
                    chk_ExpandBooleanExpressions.Checked,
                    chk_ExpandCaseStatements.Checked,
                    chk_ExpandBetweenConditions.Checked,
                    chk_BreakJoinOnSections.Checked,
                    chk_UppercaseKeywords.Checked,
                    chk_Coloring.Checked,
                    chk_EnableKeywordStandardization.Checked
                    );
            }
            else
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(chk_IdentityColoring.Checked);

            innerFormatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix");
            _formatter = new PoorMansTSqlFormatterLib.Formatters.HtmlPageWrapper(innerFormatter);
        }
        private void SetFormatter()
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter innerFormatter;
            if (radio_Formatting_Standard.Checked)
            {
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatterOptions
                    {
                        IndentString = txt_Indent.Text,
                        SpacesPerTab = int.Parse(txt_IndentWidth.Text),
                        MaxLineWidth = int.Parse(txt_MaxWidth.Text),
                        ExpandCommaLists = chk_ExpandCommaLists.Checked,
                        TrailingCommas = chk_TrailingCommas.Checked,
                        SpaceAfterExpandedComma = chk_SpaceAfterComma.Checked,
                        ExpandBooleanExpressions = chk_ExpandBooleanExpressions.Checked,
                        ExpandCaseStatements = chk_ExpandCaseStatements.Checked,
						ExpandBetweenConditions = chk_ExpandBetweenConditions.Checked,
						ExpandInLists = chk_ExpandInLists.Checked,
						BreakJoinOnSections = chk_BreakJoinOnSections.Checked,
                        UppercaseKeywords = chk_UppercaseKeywords.Checked,
                        HTMLColoring = chk_Coloring.Checked,
						KeywordStandardization = chk_EnableKeywordStandardization.Checked,
						NewStatementLineBreaks = int.Parse(txt_StatementBreaks.Text),
						NewClauseLineBreaks = int.Parse(txt_ClauseBreaks.Text)
					});
            }
            else if (radio_Formatting_Identity.Checked)
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(chk_IdentityColoring.Checked);
            else
                innerFormatter = new PoorMansTSqlFormatterLib.Formatters.TSqlObfuscatingFormatter(
                    chk_RandomizeKeywordCase.Checked,
                    chk_RandomizeColor.Checked,
                    chk_RandomizeLineLength.Checked,
                    chk_PreserveComments.Checked,
                    chk_KeywordSubstitution.Checked
                    );

            innerFormatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix") + Environment.NewLine;
            _formatter = new PoorMansTSqlFormatterLib.Formatters.HtmlPageWrapper(innerFormatter);
        }
Example #6
0
        public string FormatTSqlWithOptions(
            string inputString,
            bool reFormat,
            string indent,
            int spacesPerTab,
            int maxLineWidth,
            int statementBreaks,
            int clauseBreaks,
            bool expandCommaLists,
            bool trailingCommas,
            bool spaceAfterExpandedComma,
            bool expandBooleanExpressions,
            bool expandCaseStatements,
            bool expandBetweenConditions,
            bool breakJoinOnSections,
            bool uppercaseKeywords,
            bool coloring,
            bool keywordStandardization,
            bool useParseErrorPlaceholder,
            bool obfuscate,
            bool randomizeColor,
            bool randomizeLineLengths,
            bool randomizeKeywordCase,
            bool preserveComments,
            bool enableKeywordSubstitution,
            bool expandInLists
            )
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter formatter = null;
            if (reFormat)
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatterOptions
                {
                    IndentString             = indent,
                    SpacesPerTab             = spacesPerTab,
                    MaxLineWidth             = maxLineWidth,
                    NewStatementLineBreaks   = statementBreaks,
                    NewClauseLineBreaks      = clauseBreaks,
                    ExpandCommaLists         = expandCommaLists,
                    TrailingCommas           = trailingCommas,
                    SpaceAfterExpandedComma  = spaceAfterExpandedComma,
                    ExpandBooleanExpressions = expandBooleanExpressions,
                    ExpandCaseStatements     = expandCaseStatements,
                    ExpandBetweenConditions  = expandBetweenConditions,
                    BreakJoinOnSections      = breakJoinOnSections,
                    UppercaseKeywords        = uppercaseKeywords,
                    HTMLColoring             = coloring,
                    KeywordStandardization   = keywordStandardization,
                    ExpandInLists            = expandInLists
                });
            }
            else if (obfuscate)
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlObfuscatingFormatter(
                    randomizeKeywordCase,
                    randomizeColor,
                    randomizeLineLengths,
                    preserveComments,
                    enableKeywordSubstitution
                    );
            }
            else
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(coloring);
            }

            if (useParseErrorPlaceholder)
            {
                formatter.ErrorOutputPrefix = "{PARSEERRORPLACEHOLDER}";
            }

            return(FormatTSqlWithFormatter(inputString, formatter));
        }
        public string FormatTSqlWithOptions(
            string inputString,
            bool reFormat,
            string indent,
            int spacesPerTab,
            int maxLineWidth,
            bool expandCommaLists,
            bool trailingCommas,
            bool spaceAfterExpandedComma,
            bool expandBooleanExpressions,
            bool expandCaseStatements,
            bool expandBetweenConditions,
            bool breakJoinOnSections,
            bool uppercaseKeywords,
            bool coloring,
            bool keywordStandardization,
            bool useParseErrorPlaceholder,
            bool obfuscate,
            bool randomizeColor,
            bool randomizeLineLengths,
            bool randomizeKeywordCase,
            bool preserveComments,
            bool enableKeywordSubstitution
            )
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter formatter = null;
            if (reFormat)
            {
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatterOptions
                    {
                        IndentString = indent,
                        SpacesPerTab = spacesPerTab,
                        MaxLineWidth = maxLineWidth,
                        ExpandCommaLists = expandCommaLists,
                        TrailingCommas = trailingCommas,
                        SpaceAfterExpandedComma = spaceAfterExpandedComma,
                        ExpandBooleanExpressions = expandBooleanExpressions,
                        ExpandCaseStatements = expandCaseStatements,
                        ExpandBetweenConditions = expandBetweenConditions,
                        BreakJoinOnSections = breakJoinOnSections,
                        UppercaseKeywords = uppercaseKeywords,
                        HTMLColoring = coloring,
                        KeywordStandardization = keywordStandardization
                    });

            }
            else if (obfuscate)
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlObfuscatingFormatter(
                    randomizeKeywordCase,
                    randomizeColor,
                    randomizeLineLengths,
                    preserveComments,
                    enableKeywordSubstitution
                    );
            else
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(coloring);

            if (useParseErrorPlaceholder)
                formatter.ErrorOutputPrefix = "{PARSEERRORPLACEHOLDER}";

            return FormatTSqlWithFormatter(inputString, formatter);
        }
        public string FormatTSqlWithOptions(
            string inputString,
            bool reFormat,
            string indent,
            int spacesPerTab,
            int maxLineWidth,
            bool expandCommaLists,
            bool trailingCommas,
            bool spaceAfterExpandedComma,
            bool expandBooleanExpressions,
            bool expandCaseStatements,
            bool expandBetweenConditions,
            bool breakJoinOnSections,
            bool uppercaseKeywords,
            bool coloring,
            bool keywordStandardization,
            bool useParseErrorPlaceholder
            )
        {
            PoorMansTSqlFormatterLib.Interfaces.ISqlTreeFormatter formatter = null;
            if (reFormat)
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(
                    indent,
                    spacesPerTab,
                    maxLineWidth,
                    expandCommaLists,
                    trailingCommas,
                    spaceAfterExpandedComma,
                    expandBooleanExpressions,
                    expandCaseStatements,
                    expandBetweenConditions,
                    breakJoinOnSections,
                    uppercaseKeywords,
                    coloring,
                    keywordStandardization
                    );
            else
                formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlIdentityFormatter(coloring);

            if (useParseErrorPlaceholder)
                formatter.ErrorOutputPrefix = "{PARSEERRORPLACEHOLDER}";

            return FormatTSqlWithFormatter(inputString, formatter);
        }