Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Data / System / Data / SQLTypes / SqlCharStream.cs / 1 / SqlCharStream.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// junfang
// [....]
// [....]
//-----------------------------------------------------------------------------
//*************************************************************************
// @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;
#if WINFSInternalOnly
public
#else
internal
#endif
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
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// junfang
// [....]
// [....]
//-----------------------------------------------------------------------------
//*************************************************************************
// @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;
#if WINFSInternalOnly
public
#else
internal
#endif
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
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeBuilderBamlTranslator.cs
- OverflowException.cs
- xamlnodes.cs
- DynamicControl.cs
- FormsAuthenticationModule.cs
- EncoderNLS.cs
- MobileSysDescriptionAttribute.cs
- ExpandButtonVisibilityConverter.cs
- LogSwitch.cs
- WebPartZoneBase.cs
- HotCommands.cs
- TokenBasedSetEnumerator.cs
- EndPoint.cs
- XmlByteStreamReader.cs
- SByte.cs
- InputDevice.cs
- RemoteHelper.cs
- DnsPermission.cs
- SiblingIterators.cs
- MergeLocalizationDirectives.cs
- ColorBuilder.cs
- HttpModulesSection.cs
- ForwardPositionQuery.cs
- DBCommandBuilder.cs
- ContentPresenter.cs
- UnionExpr.cs
- StorageSetMapping.cs
- StorageBasedPackageProperties.cs
- CompareValidator.cs
- Vector3DValueSerializer.cs
- OutputCacheProfileCollection.cs
- DependentTransaction.cs
- GroupItem.cs
- SQLString.cs
- Stylesheet.cs
- SystemInfo.cs
- LayoutEngine.cs
- Vector3DConverter.cs
- BamlLocalizer.cs
- ChangeBlockUndoRecord.cs
- XmlDomTextWriter.cs
- DriveNotFoundException.cs
- App.cs
- Membership.cs
- XmlRawWriterWrapper.cs
- NameValueSectionHandler.cs
- SqlCommandSet.cs
- DelegatedStream.cs
- CompilationRelaxations.cs
- ShapingEngine.cs
- Int16KeyFrameCollection.cs
- GenericUI.cs
- TextBoxBase.cs
- DocumentApplicationJournalEntry.cs
- MonitorWrapper.cs
- WebContext.cs
- TimeSpan.cs
- PieceDirectory.cs
- IndicFontClient.cs
- OrderedEnumerableRowCollection.cs
- ListParagraph.cs
- User.cs
- RenderingBiasValidation.cs
- Win32Interop.cs
- ToolStripSeparator.cs
- safesecurityhelperavalon.cs
- InlinedLocationReference.cs
- PerfService.cs
- TransformedBitmap.cs
- RuntimeHandles.cs
- BindToObject.cs
- RemotingException.cs
- UpdateRecord.cs
- ChooseAction.cs
- DrawingServices.cs
- DuplexClientBase.cs
- UnsafeNativeMethods.cs
- DataKeyCollection.cs
- HttpListenerRequest.cs
- NativeCompoundFileAPIs.cs
- ProvidersHelper.cs
- MobileCategoryAttribute.cs
- ExceptionAggregator.cs
- UpdateTracker.cs
- PortCache.cs
- XmlIncludeAttribute.cs
- XmlILAnnotation.cs
- StringValidator.cs
- BamlReader.cs
- ImageButton.cs
- AudioStateChangedEventArgs.cs
- DynamicMetaObject.cs
- COSERVERINFO.cs
- TransformCryptoHandle.cs
- DataGridColumnCollection.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- CompoundFileStreamReference.cs
- HealthMonitoringSectionHelper.cs
- Stylesheet.cs
- CopyEncoder.cs