Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / Core / IncrementalReadDecoders.cs / 1 / IncrementalReadDecoders.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System.Diagnostics;
namespace System.Xml {
//
// IncrementalReadDecoder abstract class
//
internal abstract class IncrementalReadDecoder {
internal abstract int DecodedCount { get; }
internal abstract bool IsFull { get; }
internal abstract void SetNextOutputBuffer( Array array, int offset, int len );
internal abstract int Decode( char[] chars, int startPos, int len );
internal abstract int Decode( string str, int startPos, int len );
internal abstract void Reset();
}
//
// Dummy IncrementalReadDecoder
//
internal class IncrementalReadDummyDecoder : IncrementalReadDecoder {
internal override int DecodedCount { get { return -1; } }
internal override bool IsFull { get { return false; } }
internal override void SetNextOutputBuffer( Array array, int offset, int len ) {}
internal override int Decode( char[] chars, int startPos, int len ) { return len; }
internal override int Decode( string str, int startPos, int len ) { return len; }
internal override void Reset() {}
}
//
// IncrementalReadDecoder for ReadChars
//
internal class IncrementalReadCharsDecoder : IncrementalReadDecoder {
char[] buffer;
int startIndex;
int curIndex;
int endIndex;
internal IncrementalReadCharsDecoder() {
}
internal override int DecodedCount {
get {
return curIndex - startIndex;
}
}
internal override bool IsFull {
get {
return curIndex == endIndex;
}
}
internal override int Decode( char[] chars, int startPos, int len ) {
Debug.Assert( chars != null );
Debug.Assert( len >= 0 );
Debug.Assert( startPos >= 0 );
Debug.Assert( chars.Length - startPos >= len );
Debug.Assert( len > 0 );
int copyCount = endIndex - curIndex;
if ( copyCount > len ) {
copyCount = len;
}
Buffer.BlockCopy( chars, startPos * 2, buffer, curIndex * 2, copyCount * 2 );
curIndex += copyCount;
return copyCount;
}
internal override int Decode( string str, int startPos, int len ) {
Debug.Assert( str != null );
Debug.Assert( len >= 0 );
Debug.Assert( startPos >= 0 );
Debug.Assert( str.Length - startPos >= len );
Debug.Assert( len > 0 );
int copyCount = endIndex - curIndex;
if ( copyCount > len ) {
copyCount = len;
}
str.CopyTo( startPos, buffer, curIndex, copyCount );
curIndex += copyCount;
return copyCount;
}
internal override void Reset() {
}
internal override void SetNextOutputBuffer( Array buffer, int index, int count ) {
Debug.Assert( buffer != null );
Debug.Assert( count >= 0 );
Debug.Assert( index >= 0 );
Debug.Assert( buffer.Length - index >= count );
Debug.Assert( ( buffer as char[] ) != null );
this.buffer = (char[])buffer;
this.startIndex = index;
this.curIndex = index;
this.endIndex = index + count;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientConfigurationHost.cs
- LocatorManager.cs
- Constants.cs
- ToolStrip.cs
- GridSplitter.cs
- ServiceManagerHandle.cs
- ValueQuery.cs
- EntryPointNotFoundException.cs
- SqlDataSourceFilteringEventArgs.cs
- ObjectToken.cs
- CursorEditor.cs
- Simplifier.cs
- TextRunTypographyProperties.cs
- WebPartConnection.cs
- LogAppendAsyncResult.cs
- MessageBox.cs
- ListCollectionView.cs
- BCLDebug.cs
- DeflateEmulationStream.cs
- CharAnimationBase.cs
- SimpleHandlerBuildProvider.cs
- CompositeKey.cs
- Int32Storage.cs
- XPathNavigatorReader.cs
- Stack.cs
- ConfigXmlWhitespace.cs
- TransportElement.cs
- BoundField.cs
- ConversionHelper.cs
- OptimizedTemplateContent.cs
- CryptoApi.cs
- KeyValueSerializer.cs
- FullTextLine.cs
- GetImportFileNameRequest.cs
- DataTransferEventArgs.cs
- _HTTPDateParse.cs
- CodeTypeOfExpression.cs
- FixedSOMLineCollection.cs
- DiscardableAttribute.cs
- AppModelKnownContentFactory.cs
- Inline.cs
- PropertyChangedEventArgs.cs
- QuaternionRotation3D.cs
- UrlPath.cs
- Transform3DGroup.cs
- GenericXmlSecurityToken.cs
- WebAdminConfigurationHelper.cs
- ParallelLoopState.cs
- QueryOutputWriter.cs
- RecognitionEventArgs.cs
- SchemaTableColumn.cs
- WmlCommandAdapter.cs
- UrlPath.cs
- DockProviderWrapper.cs
- TransactionFlowBindingElementImporter.cs
- ResourceProviderFactory.cs
- HoistedLocals.cs
- ResourcesChangeInfo.cs
- PaperSize.cs
- PolicyException.cs
- HttpChannelHelpers.cs
- NumberFunctions.cs
- QualifiedCellIdBoolean.cs
- TemplateKeyConverter.cs
- HttpInputStream.cs
- DATA_BLOB.cs
- CollectionDataContractAttribute.cs
- ParallelTimeline.cs
- RuleRef.cs
- DefaultValueTypeConverter.cs
- XmlElementList.cs
- ByteStream.cs
- ChangePasswordDesigner.cs
- CryptoApi.cs
- ListCollectionView.cs
- bindurihelper.cs
- ImpersonateTokenRef.cs
- CompilationRelaxations.cs
- FontConverter.cs
- ImageFormatConverter.cs
- Html32TextWriter.cs
- GreenMethods.cs
- ThreadExceptionEvent.cs
- LoginNameDesigner.cs
- Point3DCollection.cs
- RangeBase.cs
- Roles.cs
- GridViewRowPresenter.cs
- CookielessHelper.cs
- Util.cs
- FontCacheUtil.cs
- DecimalConstantAttribute.cs
- DocumentPageViewAutomationPeer.cs
- WebPartsPersonalizationAuthorization.cs
- KeyGesture.cs
- ThreadInterruptedException.cs
- Operand.cs
- Token.cs
- AttributeEmitter.cs
- ZeroOpNode.cs