-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathSqlScriptGeneratorVisitor.ListGenerationOption.cs
More file actions
87 lines (74 loc) · 3.63 KB
/
Copy pathSqlScriptGeneratorVisitor.ListGenerationOption.cs
File metadata and controls
87 lines (74 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//------------------------------------------------------------------------------
// <copyright file="SqlScriptGeneratorVisitor.ListGenerationOption.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
namespace Microsoft.SqlServer.TransactSql.ScriptDom.ScriptGenerator
{
partial class SqlScriptGeneratorVisitor
{
internal class ListGenerationOption
{
internal enum SeparatorType
{
Comma,
Dot,
Space,
}
public Boolean Parenthesised { get; set; }
public Boolean AlwaysGenerateParenthesis { get; set; }
public Boolean IndentParentheses { get; set; }
public Boolean AlignParentheses { get; set; }
public Boolean NewLineBeforeOpenParenthesis { get; set; }
public Boolean NewLineAfterOpenParenthesis { get; set; }
public Boolean NewLineBeforeCloseParenthesis { get; set; }
public SeparatorType Separator { get; set; }
public Boolean NewLineBeforeFirstItem { get; set; }
public Boolean NewLineBeforeItems { get; set; }
public int MultipleIndentItems { get; set; }
public static readonly ListGenerationOption MultipleLineSelectElementOption = new ListGenerationOption()
{
Parenthesised = false,
AlwaysGenerateParenthesis = false,
IndentParentheses = false,
AlignParentheses = false,
Separator = SeparatorType.Comma,
NewLineBeforeFirstItem = false,
NewLineBeforeItems = true,
MultipleIndentItems = 0,
};
// Non-parenthesized, one-item-per-line list indented a single level. Used for
// CREATE/ALTER PROCEDURE parameters, which (unlike function parameters) are not wrapped
// in parentheses. The leading new line is produced by the option itself
// (NewLineBeforeFirstItem), so callers must not emit their own new line first.
public static readonly ListGenerationOption MultipleLineProcedureParameterOption = new ListGenerationOption()
{
Parenthesised = false,
AlwaysGenerateParenthesis = false,
IndentParentheses = false,
AlignParentheses = false,
Separator = SeparatorType.Comma,
NewLineBeforeFirstItem = true,
NewLineBeforeItems = true,
MultipleIndentItems = 1,
};
public static ListGenerationOption CreateOptionFromFormattingConfig(SqlScriptGeneratorOptions formatting)
{
ListGenerationOption option = new ListGenerationOption();
option.Parenthesised = true;
option.AlwaysGenerateParenthesis = true;
option.NewLineBeforeOpenParenthesis = formatting.NewLineBeforeOpenParenthesisInMultilineList;
option.NewLineAfterOpenParenthesis = true;
option.IndentParentheses = false;
option.NewLineBeforeCloseParenthesis = formatting.NewLineBeforeCloseParenthesisInMultilineList;
option.AlignParentheses = false;
option.NewLineBeforeItems = true;
option.NewLineBeforeFirstItem = false;
option.MultipleIndentItems = 1;
option.Separator = ListGenerationOption.SeparatorType.Comma;
return option;
}
}
}
}