Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SQLUtility.cs « SQLTypes « Data « System « System.Data « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 253b85477f1fee741121f3049211fd3c12a8ff56 (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//------------------------------------------------------------------------------
// <copyright file="SQLUtility.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
// <owner current="true" primary="true">junfang</owner>
// <owner current="true" primary="false">Microsoft</owner>
// <owner current="true" primary="false">Microsoft</owner>
//------------------------------------------------------------------------------

//**************************************************************************
// @File: SQLUtility.cs
//
// Create by:	JunFang
//
// Purpose: Implementation of utilities in COM+ SQL Types Library.
//			Includes interface INullable, exceptions SqlNullValueException
//			and SqlTruncateException, and SQLDebug class.
//
// Notes:
//
// History:
//
//   09/17/99  JunFang	Created and implemented as first drop.
//
// @EndHeader@
//**************************************************************************

using System;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Serialization;

namespace System.Data.SqlTypes {

    internal enum EComparison {
        LT,
        LE,
        EQ,
        GE,
        GT,
        NE
    }

	// This enumeration is used to inquire about internal storage of a SqlBytes or SqlChars instance:
    public enum StorageState {
		Buffer = 0,
		Stream = 1,
		UnmanagedBuffer = 2
	}

    [Serializable]
    public class SqlTypeException : SystemException {

        public SqlTypeException() : this(Res.GetString(Res.SqlMisc_SqlTypeMessage), null) { // MDAC 82931, 84941
        }

        // Creates a new SqlTypeException with its message string set to message.
        public SqlTypeException(String message) : this(message, null) {
        }

        public SqlTypeException(String message, Exception e) : base(message, e) { // MDAC 82931
            HResult = HResults.SqlType; // MDAC 84941
        }

        // runtime will call even if private...
        // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
        protected SqlTypeException(SerializationInfo si, StreamingContext sc) : base(SqlTypeExceptionSerialization(si, sc), sc) {
        }

        static private SerializationInfo SqlTypeExceptionSerialization(SerializationInfo si, StreamingContext sc) {
            if ((null != si) && (1 == si.MemberCount)) {
                string message = si.GetString("SqlTypeExceptionMessage"); // WebData 104331
                SqlTypeException fakeValue = new SqlTypeException(message);
                fakeValue.GetObjectData(si, sc);
            }
            return si;
        }
    } // SqlTypeException

    [Serializable]
    public sealed class SqlNullValueException : SqlTypeException {

        // Creates a new SqlNullValueException with its message string set to the common string.
        public SqlNullValueException() : this(SQLResource.NullValueMessage, null) {
        }

        // Creates a new NullValueException with its message string set to message.
        public SqlNullValueException(String message) : this(message, null) {
        }

        public SqlNullValueException(String message, Exception e) : base(message, e) { // MDAC 82931
            HResult = HResults.SqlNullValue; // MDAC 84941
        }

        // runtime will call even if private...
        // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
        private SqlNullValueException(SerializationInfo si, StreamingContext sc) : base(SqlNullValueExceptionSerialization(si, sc), sc) {
        }

        static private SerializationInfo SqlNullValueExceptionSerialization(SerializationInfo si, StreamingContext sc) {
            if ((null != si) && (1 == si.MemberCount)) {
                string message = si.GetString("SqlNullValueExceptionMessage"); // WebData 104331
                SqlNullValueException fakeValue = new SqlNullValueException(message);
                fakeValue.GetObjectData(si, sc);
            }
            return si;
        }
    } // NullValueException

    [Serializable]
    public sealed class SqlTruncateException : SqlTypeException {

        // Creates a new SqlTruncateException with its message string set to the empty string.
        public SqlTruncateException() : this(SQLResource.TruncationMessage, null) {
        }

        // Creates a new SqlTruncateException with its message string set to message.
        public SqlTruncateException(String message) : this(message, null) {
        }

        public SqlTruncateException(String message, Exception e) : base(message, e) { // MDAC 82931
            HResult = HResults.SqlTruncate; // MDAC 84941
        }

        // runtime will call even if private...
        // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
        private SqlTruncateException(SerializationInfo si, StreamingContext sc) : base(SqlTruncateExceptionSerialization(si, sc), sc) {
        }

        static private SerializationInfo SqlTruncateExceptionSerialization(SerializationInfo si, StreamingContext sc) {
            if ((null != si) && (1 == si.MemberCount)) {
                string message = si.GetString("SqlTruncateExceptionMessage"); // WebData 104331
                SqlTruncateException fakeValue = new SqlTruncateException(message);
                fakeValue.GetObjectData(si, sc);
            }
            return si;
        }
    } // SqlTruncateException

	[Serializable]
    public sealed class SqlNotFilledException : SqlTypeException {
		// 


		// Creates a new SqlNotFilledException with its message string set to the common string.
		public SqlNotFilledException() : this(SQLResource.NotFilledMessage, null) {
		}

		// Creates a new NullValueException with its message string set to message.
		public SqlNotFilledException(String message) : this(message, null) {
        }

		public SqlNotFilledException(String message, Exception e) : base(message, e) { // MDAC 82931
			HResult = HResults.SqlNullValue; // MDAC 84941
		}

		// runtime will call even if private...
		// <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
		private SqlNotFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) {
		}
	} // SqlNotFilledException

	[Serializable]
    public sealed class SqlAlreadyFilledException : SqlTypeException {
		// 


		// Creates a new SqlNotFilledException with its message string set to the common string.
		public SqlAlreadyFilledException() : this(SQLResource.AlreadyFilledMessage, null) {
		}

		// Creates a new NullValueException with its message string set to message.
		public SqlAlreadyFilledException(String message) : this(message, null) {
        }

		public SqlAlreadyFilledException(String message, Exception e) : base(message, e) { // MDAC 82931
			HResult = HResults.SqlNullValue; // MDAC 84941
		}

		// runtime will call even if private...
		// <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
		private SqlAlreadyFilledException(SerializationInfo si, StreamingContext sc) : base(si, sc) {
		}
	} // SqlNotFilledException

	
    internal sealed class SQLDebug {
        private SQLDebug() { /* prevent utility class from being insantiated*/ }

        [System.Diagnostics.Conditional("DEBUG")]
        internal static void Check(bool condition) {
            Debug.Assert(condition, "", "");
        }

        [System.Diagnostics.Conditional("DEBUG")]
        internal static void Check(bool condition, String conditionString, string message) {
            Debug.Assert(condition, conditionString, message);
        }

        [System.Diagnostics.Conditional("DEBUG")]
        internal static void Check(bool condition, String conditionString) {
            Debug.Assert(condition, conditionString, "");
        }

        /*
        [System.Diagnostics.Conditional("DEBUG")]
        internal static void Message(String traceMessage) {
            Debug.WriteLine(SQLResource.MessageString + ": " + traceMessage);
        }
        */

    } // SQLDebug
} // namespace System.Data.SqlTypes