Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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. // //[....] //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StickyNoteHelper.cs
- InputReportEventArgs.cs
- LocatorPart.cs
- DbConnectionInternal.cs
- StateWorkerRequest.cs
- LinqDataSourceDisposeEventArgs.cs
- Rotation3DKeyFrameCollection.cs
- MemberDomainMap.cs
- TypeToken.cs
- PipelineModuleStepContainer.cs
- ParserContext.cs
- XamlTreeBuilder.cs
- Attributes.cs
- HttpRequest.cs
- DatatypeImplementation.cs
- DocumentGridContextMenu.cs
- UniqueEventHelper.cs
- SafeNativeMethodsOther.cs
- NumericPagerField.cs
- TabControlCancelEvent.cs
- TraceProvider.cs
- PartialCachingControl.cs
- DataGridBoolColumn.cs
- WebPartConnectionsCancelEventArgs.cs
- DynamicPropertyReader.cs
- WindowsAuthenticationEventArgs.cs
- DesignerInterfaces.cs
- RuntimeResourceSet.cs
- CodeTypeParameter.cs
- ResourceCategoryAttribute.cs
- UniformGrid.cs
- WindowsGraphics.cs
- fixedPageContentExtractor.cs
- SqlNodeAnnotation.cs
- SizeConverter.cs
- PackageStore.cs
- LocationUpdates.cs
- NamespaceExpr.cs
- SecUtil.cs
- DesignerVerbCollection.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- IteratorDescriptor.cs
- TextBox.cs
- WebPartDescription.cs
- SolidBrush.cs
- ContourSegment.cs
- JapaneseCalendar.cs
- Fault.cs
- OleDbStruct.cs
- PrintDialogDesigner.cs
- DrawingBrush.cs
- Message.cs
- HostingEnvironmentSection.cs
- DrawToolTipEventArgs.cs
- KeySplineConverter.cs
- CompositeCollectionView.cs
- InvokeWebServiceDesigner.cs
- AlternationConverter.cs
- PropertyChangedEventManager.cs
- BrowserCapabilitiesCompiler.cs
- Registry.cs
- MenuDesigner.cs
- WindowsListViewGroupSubsetLink.cs
- DataGridViewColumnHeaderCell.cs
- TextChange.cs
- HybridDictionary.cs
- DataGridColumnDropSeparator.cs
- RuntimeEnvironment.cs
- GeneralTransform2DTo3DTo2D.cs
- CustomAttribute.cs
- PathFigure.cs
- ToolStripItemRenderEventArgs.cs
- FastPropertyAccessor.cs
- DbParameterHelper.cs
- SchemaContext.cs
- LocalizableResourceBuilder.cs
- Schema.cs
- CriticalFinalizerObject.cs
- NoneExcludedImageIndexConverter.cs
- SecureUICommand.cs
- DateTimeFormatInfo.cs
- UrlMappingsModule.cs
- MsmqIntegrationProcessProtocolHandler.cs
- CommentEmitter.cs
- PrimarySelectionGlyph.cs
- MetafileHeaderWmf.cs
- XslAst.cs
- SvcMapFile.cs
- UpdateCompiler.cs
- DateTimePicker.cs
- TrayIconDesigner.cs
- LoginUtil.cs
- HttpEncoder.cs
- RuleSetDialog.Designer.cs
- HwndSubclass.cs
- TextTreeUndo.cs
- Timer.cs
- TriggerActionCollection.cs
- ConstraintConverter.cs
- HttpModulesSection.cs