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

SqlCharStream.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: e270bc00b86b1cc4621587f93ade23751adda0df (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
//------------------------------------------------------------------------------
// <copyright file="SqlStreamChars.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: SqlStreamChars.cs
//
// Create by:	JunFang
//
// Description: 
//
// Notes: 
//	
// History:
//
//   04/17/01  JunFang	Created.
//
// @EndHeader@
//**************************************************************************

namespace System.Data.SqlTypes 
	{
	using System;
	using System.IO;
	using System.Runtime.InteropServices;
	using System.Data.SqlTypes;

	internal abstract class SqlStreamChars: System.Data.SqlTypes.INullable, IDisposable
		{
		public abstract bool IsNull { get; }

		public abstract bool CanRead { get; }

		public abstract bool CanSeek { get; }

		public abstract bool CanWrite { get; }

		public abstract long Length { get; }

		public abstract long Position { get; set; }

		// --------------------------------------------------------------
		//	  Public methods
		// --------------------------------------------------------------
		public abstract int Read (char[] buffer, int offset, int count);

		public abstract void Write (char[] buffer, int offset, int count);

		public abstract long Seek (long offset, SeekOrigin origin);

		public abstract void SetLength (long value);

		public abstract void Flush ();

		public virtual void Close(){
			Dispose(true);
		}

		void IDisposable.Dispose() {
            Dispose(true);           
        }

		protected virtual void Dispose(bool disposing) {           
		}

		public virtual int ReadChar()
			{
			// Reads one char from the stream by calling Read(char[], int, int). 
			// Will return an char cast to an int or -1 on end of stream.
			// The performance of the default implementation on Stream is bad,
			// and any subclass with an internal buffer should override this method.
			char[] oneCharArray = new char[1];
			int r = Read(oneCharArray, 0, 1);
			if (r==0)
				return -1;
			return oneCharArray[0];
			}

		public virtual void WriteChar(char value)
			{
			// Writes one char from the stream by calling Write(char[], int, int).  
			// The performance of the default implementation on Stream is bad,
			// and any subclass with an internal buffer should override this method.
			char[] oneCharArray = new char[1];
			oneCharArray[0] = value;
			Write(oneCharArray, 0, 1);
			}


		// Private class: the Null SqlStreamChars
		private class NullSqlStreamChars : SqlStreamChars
			{
			// --------------------------------------------------------------
			//	  Constructor(s)
			// --------------------------------------------------------------

			internal NullSqlStreamChars()
				{
				}


			// --------------------------------------------------------------
			//	  Public properties
			// --------------------------------------------------------------

			public override bool IsNull 
				{
				get 
					{
					return true;
					}
				}

			public override bool CanRead
				{
				get
					{
					return false;
					}
				}

			public override bool CanSeek
				{
				get
					{
					return false;
					}
				}

			public override bool CanWrite
				{
				get
					{
					return false;
					}
				}

			public override long Length
				{
				get
					{
					throw new SqlNullValueException();
					}
				}

			public override long Position
				{
				get
					{
					throw new SqlNullValueException();
					}
				set
					{
					throw new SqlNullValueException();
					}
				}

			// --------------------------------------------------------------
			//	  Public methods
			// --------------------------------------------------------------
			public override int Read (char[] buffer, int offset, int count)
				{
				throw new SqlNullValueException();
				}

			public override void Write (char[] buffer, int offset, int count)
				{
				throw new SqlNullValueException();
				}

			public override long Seek (long offset, SeekOrigin origin)
				{
				throw new SqlNullValueException();
				}

			public override void SetLength (long value)
				{
				throw new SqlNullValueException();
				}

			public override void Flush ()
				{
				throw new SqlNullValueException();
				}

			public override void Close ()
				{
				}

			} // class NullSqlStreamChars


		// The Null instance
		public static SqlStreamChars Null {
                    get {
                        return new NullSqlStreamChars();
                    }
		}

		} // class SqlStreamChars

	} // namespace System.Data.SqlTypes