-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathSqlScriptPublishEnums.cs
158 lines (147 loc) · 4.17 KB
/
SqlScriptPublishEnums.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using System;
using System.ComponentModel;
using System.Reflection;
namespace Microsoft.SqlServer.Management.SqlScriptPublish
{
/// <summary>
/// The type of output to create. Only one type is allowed, this enumeration exists for backward compatibility.
/// </summary>
public enum OutputType
{
/// <summary>
/// Generate script as text whose destination can be a file, a set of files, or the clipboard
/// </summary>
GenerateScript = 0,
}
/// <summary>
/// Generate script output destination
/// </summary>
public enum ScriptDestination
{
/// <summary>
/// Put all scripts in one file
/// </summary>
ToSingleFile = 0,
/// <summary>
/// Put all scripts on the clipboard as one string
/// </summary>
ToClipboard,
/// <summary>
/// Open the scripts in an editor window
/// </summary>
ToEditor,
/// <summary>
/// Create one file per database object
/// </summary>
ToFilePerObject,
/// <summary>
/// Create a Jupyter Notebook with one code cell per object
/// </summary>
ToNotebook,
/// <summary>
/// Hands persistence responsibility to a custom ISmoScriptWriter implementation provided by the caller
/// </summary>
ToCustomWriter
}
/// <summary>
/// Generate script unicode, ansi, and explicit utf8 type
/// </summary>
public enum ScriptFileType
{
/// <summary>
/// Encode in UTF-16
/// </summary>
Unicode = 0,
/// <summary>
/// Encode in ANSI using the default code page
/// </summary>
Ansi,
/// <summary>
/// Encode in UTF-8
/// </summary>
Utf8,
}
/// <summary>
/// Generate script file overwrite option
/// </summary>
public enum ScriptFileMode
{
/// <summary>
/// Overwrite existing files
/// </summary>
Overwrite = 0,
/// <summary>
/// Append contents to existing files
/// </summary>
Append
}
/// <summary>
/// Enum for database object types
/// To support localized description, it uses LocalizedEnumConverter.
/// </summary>
[TypeConverter(typeof(LocalizedEnumConverter))]
public enum DatabaseObjectType
{
Table,
View,
StoredProcedure,
UserDefinedFunction,
UserDefinedDataType,
User,
Default,
Rule,
DatabaseRole,
ApplicationRole,
SqlAssembly,
DdlTrigger,
Synonym,
XmlSchemaCollection,
Schema,
SecurityPolicy,
PlanGuide,
UserDefinedType,
UserDefinedAggregate,
FullTextCatalog,
UserDefinedTableType
}
/// <summary>
/// Result enum type
/// To support localized description, it uses LocalizedEnumConverter.
/// </summary>
[TypeConverter(typeof(LocalizedEnumConverter))]
public enum ResultType
{
None,
InProgress,
Success,
Warning,
Error
}
/// <summary>
/// Convert enum string to localized display string
/// </summary>
internal class LocalizedEnumConverter : EnumConverter
{
private const string srTypeFullName = "Microsoft.SqlServer.Management.SqlScriptPublish.SR";
public LocalizedEnumConverter(Type type)
: base(type)
{
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (value != null && destinationType == typeof(string))
{
Type srType = Type.GetType(srTypeFullName);
PropertyInfo propInfo = srType.GetProperty(value.ToString());
object locStr = propInfo.GetValue(null, null);
return locStr;
}
else
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
}