Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Core / IncrementalReadDecoders.cs / 1305376 / 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();
}
#if !SILVERLIGHT // Needed only for XmlTextReader
//
// 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;
}
}
#endif
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// 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();
}
#if !SILVERLIGHT // Needed only for XmlTextReader
//
// 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;
}
}
#endif
}
// 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
- GraphicsPathIterator.cs
- EdmConstants.cs
- ContextInformation.cs
- EventSinkHelperWriter.cs
- MultipartContentParser.cs
- MatrixConverter.cs
- AndCondition.cs
- TrackingStringDictionary.cs
- DataException.cs
- CustomAttributeFormatException.cs
- PreservationFileReader.cs
- UrlMappingsModule.cs
- TableLayoutPanelCellPosition.cs
- WebScriptMetadataFormatter.cs
- WindowsFormsHost.cs
- Collection.cs
- CodeTypeMember.cs
- ClientApiGenerator.cs
- WebPartUtil.cs
- TaiwanCalendar.cs
- TextLineResult.cs
- EventSourceCreationData.cs
- RawStylusInput.cs
- Variable.cs
- PackageDigitalSignatureManager.cs
- ImagingCache.cs
- UnsafeNativeMethods.cs
- ValueUnavailableException.cs
- WorkflowInstanceExtensionCollection.cs
- WebReferenceOptions.cs
- XmlQualifiedName.cs
- Wildcard.cs
- DataContractSerializer.cs
- TrackingMemoryStreamFactory.cs
- XmlDocumentSurrogate.cs
- LocalBuilder.cs
- RegionInfo.cs
- WebPartCatalogCloseVerb.cs
- XslCompiledTransform.cs
- documentsequencetextcontainer.cs
- SymbolType.cs
- CssTextWriter.cs
- sqlser.cs
- WeakRefEnumerator.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- BindingContext.cs
- DiagnosticsConfiguration.cs
- MetadataSection.cs
- PropertyEmitter.cs
- SourceElementsCollection.cs
- ContextMenuStripGroup.cs
- ParsedAttributeCollection.cs
- AutomationTextAttribute.cs
- MaskInputRejectedEventArgs.cs
- ByteArrayHelperWithString.cs
- IndentedWriter.cs
- ScopedKnownTypes.cs
- KeyValueSerializer.cs
- ApplicationContext.cs
- MaskInputRejectedEventArgs.cs
- Component.cs
- TextEditorLists.cs
- TimelineGroup.cs
- SessionParameter.cs
- ByteStorage.cs
- DataGridCellsPanel.cs
- WindowsAuthenticationEventArgs.cs
- RichTextBoxContextMenu.cs
- HtmlInputReset.cs
- IImplicitResourceProvider.cs
- ArgumentValueSerializer.cs
- Attribute.cs
- Effect.cs
- CompareValidator.cs
- AxImporter.cs
- Soap.cs
- AdapterUtil.cs
- ResourceContainer.cs
- FontDifferentiator.cs
- FontCacheUtil.cs
- assertwrapper.cs
- SignedXmlDebugLog.cs
- GeneralTransform3D.cs
- QueryExpr.cs
- IntSecurity.cs
- PolyQuadraticBezierSegment.cs
- WebPartEditVerb.cs
- PlainXmlSerializer.cs
- StorageBasedPackageProperties.cs
- ImageAutomationPeer.cs
- GeometryCollection.cs
- DefaultPropertyAttribute.cs
- BindStream.cs
- MouseButton.cs
- Stackframe.cs
- SerTrace.cs
- SQLInt64.cs
- PkcsUtils.cs
- AssemblyUtil.cs
- ToolStripRendererSwitcher.cs