2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System . Threading . Tasks ;
5
- using Res = System . SR ;
6
5
7
- namespace System
8
- {
9
- internal static partial class SR
10
- {
11
- internal static string GetString ( string value )
12
- {
13
- return value ;
14
- }
15
-
16
- internal static string GetString ( string format , params object [ ] args )
17
- {
18
- return SR . Format ( format , args ) ;
19
- }
20
- }
21
- }
22
6
23
7
24
8
namespace System . Data . Common
25
9
{
26
10
internal static class ADP
27
11
{
28
- // The class ADP defines the exceptions that are specific to the Adapters.f
12
+ // The class ADP defines the exceptions that are specific to the Adapters.
29
13
// The class contains functions that take the proper informational variables and then construct
30
- // the appropriate exception with an error string obtained from the resource Framework.txt .
14
+ // the appropriate exception with an error string obtained from the resource framework .
31
15
// The exception is then returned to the caller, so that the caller may then throw from its
32
16
// location so that the catcher of the exception will have the appropriate call stack.
33
17
// This class is used so that there will be compile time checking of error messages.
34
- // The resource Framework.txt will ensure proper string text based on the appropriate
35
- // locale.
36
18
37
19
static internal Task < T > CreatedTaskWithException < T > ( Exception ex )
38
20
{
@@ -48,8 +30,9 @@ static internal Task<T> CreatedTaskWithCancellation<T>()
48
30
return completion . Task ;
49
31
}
50
32
33
+
51
34
// NOTE: Initializing a Task in SQL CLR requires the "UNSAFE" permission set (http://msdn.microsoft.com/en-us/library/ms172338.aspx)
52
- // Therefore we are lazily initializing these Tasks to avoid forcing customers to use the "UNSAFE" set when they are actually using no Async features (See Dev11
35
+ // Therefore we are lazily initializing these Tasks to avoid forcing customers to use the "UNSAFE" set when they are actually using no Async features
53
36
static private Task < bool > s_trueTask = null ;
54
37
static internal Task < bool > TrueTask
55
38
{
@@ -76,51 +59,42 @@ static internal Task<bool> FalseTask
76
59
}
77
60
}
78
61
79
- static internal void TraceExceptionAsReturnValue ( Exception e )
80
- {
81
- }
82
62
static internal ArgumentException Argument ( string error )
83
63
{
84
64
ArgumentException e = new ArgumentException ( error ) ;
85
- TraceExceptionAsReturnValue ( e ) ;
86
65
return e ;
87
66
}
88
67
static internal ArgumentException Argument ( string error , Exception inner )
89
68
{
90
69
ArgumentException e = new ArgumentException ( error , inner ) ;
91
- TraceExceptionAsReturnValue ( e ) ;
92
70
return e ;
93
71
}
94
72
static internal ArgumentException Argument ( string error , string parameter )
95
73
{
96
74
ArgumentException e = new ArgumentException ( error , parameter ) ;
97
- TraceExceptionAsReturnValue ( e ) ;
98
75
return e ;
99
76
}
100
77
static internal ArgumentNullException ArgumentNull ( string parameter )
101
78
{
102
79
ArgumentNullException e = new ArgumentNullException ( parameter ) ;
103
- TraceExceptionAsReturnValue ( e ) ;
104
80
return e ;
105
81
}
106
82
static internal InvalidOperationException InvalidOperation ( string error )
107
83
{
108
84
InvalidOperationException e = new InvalidOperationException ( error ) ;
109
- TraceExceptionAsReturnValue ( e ) ;
110
85
return e ;
111
86
}
112
87
static internal NotSupportedException NotSupported ( )
113
88
{
114
89
NotSupportedException e = new NotSupportedException ( ) ;
115
- TraceExceptionAsReturnValue ( e ) ;
116
90
return e ;
117
91
}
118
92
static internal void CheckArgumentLength ( string value , string parameterName )
119
93
{
120
94
CheckArgumentNull ( value , parameterName ) ;
121
95
if ( 0 == value . Length )
122
96
{
123
- throw Argument ( Res . GetString ( Res . ADP_EmptyString , parameterName ) ) ; // MDAC 94859
97
+ throw Argument ( SR . Format ( SR . ADP_EmptyString , parameterName ) ) ;
124
98
}
125
99
}
126
100
static internal void CheckArgumentNull ( object value , string parameterName )
@@ -135,23 +109,23 @@ static internal void CheckArgumentNull(object value, string parameterName)
135
109
//
136
110
static internal ArgumentException ConnectionStringSyntax ( int index )
137
111
{
138
- return Argument ( Res . GetString ( Res . ADP_ConnectionStringSyntax , index ) ) ;
112
+ return Argument ( SR . Format ( SR . ADP_ConnectionStringSyntax , index ) ) ;
139
113
}
140
114
static internal ArgumentException KeywordNotSupported ( string keyword )
141
115
{
142
- return Argument ( Res . GetString ( Res . ADP_KeywordNotSupported , keyword ) ) ;
116
+ return Argument ( SR . Format ( SR . ADP_KeywordNotSupported , keyword ) ) ;
143
117
}
144
118
static internal ArgumentException InvalidKeyname ( string parameterName )
145
119
{
146
- return Argument ( Res . GetString ( Res . ADP_InvalidKey ) , parameterName ) ;
120
+ return Argument ( SR . Format ( SR . ADP_InvalidKey ) , parameterName ) ;
147
121
}
148
122
static internal ArgumentException InvalidValue ( string parameterName )
149
123
{
150
- return Argument ( Res . GetString ( Res . ADP_InvalidValue ) , parameterName ) ;
124
+ return Argument ( SR . Format ( SR . ADP_InvalidValue ) , parameterName ) ;
151
125
}
152
126
static internal ArgumentException ConvertFailed ( Type fromType , Type toType , Exception innerException )
153
127
{
154
- return ADP . Argument ( Res . GetString ( Res . SqlConvert_ConvertFailed , fromType . FullName , toType . FullName ) , innerException ) ;
128
+ return ADP . Argument ( SR . Format ( SR . SqlConvert_ConvertFailed , fromType . FullName , toType . FullName ) , innerException ) ;
155
129
}
156
130
internal enum InternalErrorCode
157
131
{
@@ -194,13 +168,13 @@ internal enum InternalErrorCode
194
168
}
195
169
static internal Exception InternalError ( InternalErrorCode internalError )
196
170
{
197
- return InvalidOperation ( Res . GetString ( Res . ADP_InternalProviderError , ( int ) internalError ) ) ;
171
+ return InvalidOperation ( SR . Format ( SR . ADP_InternalProviderError , ( int ) internalError ) ) ;
198
172
}
199
173
internal const int DefaultConnectionTimeout = DbConnectionStringDefaults . ConnectTimeout ;
200
174
201
175
static internal bool IsEmpty ( string str )
202
176
{
203
- return ( ( null == str ) || ( 0 == str . Length ) ) ;
177
+ return string . IsNullOrEmpty ( str ) ;
204
178
}
205
179
}
206
180
}
0 commit comments