Code:
/ DotNET / DotNET / 8.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
- ReadOnlyMetadataCollection.cs
- Activity.cs
- UnsafeCollabNativeMethods.cs
- ListViewSortEventArgs.cs
- DataPagerFieldCollection.cs
- DocumentReference.cs
- WindowsSecurityToken.cs
- XmlDataCollection.cs
- SID.cs
- DbConnectionStringBuilder.cs
- Transactions.cs
- StylusPointPropertyUnit.cs
- XmlSchemaSimpleContentRestriction.cs
- TypeUtil.cs
- IDQuery.cs
- HwndKeyboardInputProvider.cs
- PathGeometry.cs
- VBCodeProvider.cs
- UnaryExpression.cs
- PersonalizationDictionary.cs
- DefaultValueMapping.cs
- XsdDataContractExporter.cs
- WhitespaceRule.cs
- ScrollChrome.cs
- UserControl.cs
- ResolvedKeyFrameEntry.cs
- RotateTransform.cs
- DataSourceComponent.cs
- StandardRuntimeEnumValidator.cs
- Win32SafeHandles.cs
- Hex.cs
- CapabilitiesState.cs
- HandlerWithFactory.cs
- CacheDict.cs
- ToolStripDropDownItem.cs
- MetadataPropertyAttribute.cs
- XmlReaderSettings.cs
- QueryOptionExpression.cs
- ZipIOExtraFieldPaddingElement.cs
- TableCellCollection.cs
- BooleanStorage.cs
- Mouse.cs
- MenuTracker.cs
- DrawingBrush.cs
- DynamicDataRouteHandler.cs
- MdbDataFileEditor.cs
- MetadataExporter.cs
- HtmlDocument.cs
- Transform3DGroup.cs
- MultipartContentParser.cs
- SoapAttributeOverrides.cs
- TransportationConfigurationTypeInstallComponent.cs
- AnnotationHighlightLayer.cs
- DataQuery.cs
- Emitter.cs
- KeyInstance.cs
- DefaultExpressionVisitor.cs
- CollectionView.cs
- XmlEnumAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- PositiveTimeSpanValidatorAttribute.cs
- DelegateHelpers.Generated.cs
- PackUriHelper.cs
- PropertyRef.cs
- EncoderFallback.cs
- Serializer.cs
- BitmapCodecInfo.cs
- EqualityComparer.cs
- CharEntityEncoderFallback.cs
- XmlObjectSerializerReadContextComplexJson.cs
- CompensationDesigner.cs
- MessageLogger.cs
- CompiledXpathExpr.cs
- RowToParametersTransformer.cs
- SwitchElementsCollection.cs
- FlowLayoutPanelDesigner.cs
- _WebProxyDataBuilder.cs
- RelationHandler.cs
- WinInetCache.cs
- IItemContainerGenerator.cs
- EntityViewGenerationConstants.cs
- PrimitiveCodeDomSerializer.cs
- HandlerBase.cs
- DeferredRunTextReference.cs
- DataGridViewComboBoxEditingControl.cs
- SkewTransform.cs
- Pair.cs
- ObjectAnimationUsingKeyFrames.cs
- WebPartTracker.cs
- CheckPair.cs
- DataSourceListEditor.cs
- IconHelper.cs
- SyntaxCheck.cs
- MeasurementDCInfo.cs
- RecognizedWordUnit.cs
- XmlHierarchicalDataSourceView.cs
- CollectionChangeEventArgs.cs
- IPAddressCollection.cs
- BezierSegment.cs
- TraceProvider.cs